1 2 /* Terminality - a portable terminal handling library 3 * Copyright (C) 1998-2002, Emil Mikulic. 4 * This is LGPL - look at COPYING.LIB 5 */ 6 7 /* $Id: tn.h,v 1.26 2002/07/27 07:40:37 darkmoon Exp $ */ 8 9 /* Project: Terminality 10 * File: tn.h 11 * Author: Emil Mikulic 12 * Description: Provide a general interface to the Terminality library 13 */ 14 15 #ifndef _tn_h_ 16 #define _tn_h_ 17 18 /* Version-specifics */ 19 #define TN_VERSION "2.1" 20 #define TN_BUILD 21 21 22 #include "colors.h" 23 24 /* Platform-dependent includes */ 25 #ifdef __unix__ 26 # include "tn_h_nc.h" 27 #endif 28 #ifdef _WIN32 29 # include "tn_h_w32.h" 30 #endif 31 32 /* Safeguard */ 33 #ifndef TN_H_IMPLEMENTED 34 # error Unrecognised platform 35 #endif 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* Colors */ 42 typedef enum { 43 Default = -1, /* Not a real color, needed for listing */ 44 Black = 0, 45 Blue = 1, 46 Green = 2, 47 Cyan = 3, 48 Red = 4, 49 Magenta = 5, 50 Brown = 6, 51 LightGray = 7, 52 /* Bright [foreground] */ 53 DarkGray = 8, 54 LightBlue = 9, 55 LightGreen = 10, 56 LightCyan = 11, 57 LightRed = 12, 58 LightMagenta = 13, 59 Yellow = 14, 60 White = 15 61 } color; 62 63 #define LightGrey LightGray 64 #define DarkGrey DarkGray 65 #define LightBrown Yellow 66 67 #define colour color 68 #define COLOUR COLOR 69 70 /* Cursor type */ 71 typedef enum { 72 none, /* hidden */ 73 line, /* thin */ 74 rect /* fat */ 75 } cursor; 76 77 78 79 /* Functions */ 80 void initcons(void); /* Initialise console */ 81 void donecons(void); /* Done with console */ 82 void clrscr(void); /* Clear screen */ 83 void textcolor(color c); /* Set foreground (text) color */ 84 void textbackground(color c); /* Set background color */ 85 void setcolor(color f, color b); /* Set color to f, b */ 86 color getbgcolor(void); /* Get bg color */ 87 color getfgcolor(void); /* Get fg color */ 88 key readkey(void); /* Get keypress */ 89 int keypressed(void); /* Key pressed? */ 90 #ifndef __DJGPP__ 91 void delay(int ms); /* Delay for <ms> milliseconds */ 92 #endif 93 void gotoxy(int x, int y); /* Move cursor to x,y */ 94 void writech(chtype c); /* Write character */ 95 int update_set(int want); /* Enable / disable screen updates */ 96 void update(void); /* Update screen */ 97 int has_color(void); /* Do we have colors? */ 98 void clreol(void); /* Clear to end of line */ 99 int wherey(void); /* Return cursor Y position */ 100 int wherex(void); /* Return cursor X position */ 101 int beep(void); /* Audible beep/bell/alarm thing */ 102 int printw(const char *format, ...); /* printf to screen */ 103 104 /* No-color terminal functions */ 105 void highvideo(void); /* Bright text */ 106 void lowvideo(void); /* Dim text */ 107 void normvideo(void); /* Normal text */ 108 void reversevideo(void); /* Reverse/standout text */ 109 110 /* Cursor functions */ 111 cursor get_cursor(void); /* Gets cursor */ 112 void set_cursor(cursor c); /* Sets cursor */ 113 114 /* Color scheme functions: */ 115 color get_scheme_color(int name); /* Returns color by constant */ 116 void set_scheme(color *scheme); /* Sets color scheme */ 117 void default_scheme(void); /* Sets default color scheme */ 118 119 120 121 /* Compatibility with older Terminality releases */ 122 #define fgcolor textcolor 123 #define bgcolor textbackground 124 125 /* COLOR attribute array */ 126 extern int COLOR[16][8]; 127 128 /* Global cursor */ 129 extern cursor glb_cursor; 130 131 /* The following special characters must be supported or emulated: 132 * HLINE - Horizontal line 133 * VLINE - Vertical line 134 * CROSS - Cross/plus 135 * C_UL - Upper left corner 136 * C_UR - Upper right 137 * C_LL - Lower left 138 * C_LR - Lower right 139 * BLOCK_1 - 25%-full block 140 * BLOCK_2 - 50%-full block 141 * BLOCK_3 - 75%-full block 142 * BLOCK_4 - Solid block 143 * TEE_L - Tee pointing left 144 * TEE_R - Tee pointing right 145 * TEE_U - Tee pointing up 146 * TEE_D - Tee pointing down 147 * ARROW_L - Arrow pointing left 148 * ARROW_R - Arrow pointing right 149 * ARROW_U - Arrow pointing up 150 * ARROW_D - Arrow pointing down 151 * 152 * 153 * The macro _c(x) should be provided. It is used to create a 154 * chtype value from an integer specifying a regular ASCII 155 * character code. i.e. BLOCK_4 = _c(219) 156 * 157 * 158 * The following keys must be provided: 159 * KEY_ENTER 160 * KEY_TAB 161 * KEY_BACKSPACE 162 * KEY_DEL 163 * KEY_UP 164 * KEY_DOWN 165 * KEY_LEFT 166 * KEY_RIGHT 167 * KEY_HOME 168 * KEY_END 169 * KEY_PGUP 170 * KEY_PGDOWN 171 */ 172 173 /* To obtain the size of the terminal, Terminality backends must 174 provide CON_COLS and CON_ROWS as macros or variables. */ 175 176 177 178 /* Types */ 179 typedef enum { 180 Unknown = 0, 181 Checkbox = 1, 182 Radio = 2, 183 Textbox = 3, 184 Textarea = 4, 185 Button = 5, 186 Menu = 6, 187 Hmenu = 7, 188 Listing = 8, 189 Form = 9, 190 Custom = 10, /* Custom type for drawing graphics that are persistant 191 even when redraw is called */ 192 Textview = 11, 193 } element_type; 194 195 196 197 #ifdef __cplusplus 198 } 199 #endif 200 201 #endif 202 203