1 /* 2 Console 3 Routines for handling the mixed proportional/fixed font display 4 JBS 15 June 1994 5 */ 6 7 #ifndef _CONSOLE_ 8 9 #define _CONSOLE_ 10 11 #include "config.h" 12 #include "types.h" 13 14 15 #ifndef MAX_HEIGHT 16 #define MAX_HEIGHT 80 17 #endif 18 19 #ifndef MAX_FIXED 20 #define MAX_FIXED 160 21 #endif 22 23 #ifndef MAX_SLACK 24 #define MAX_SLACK ((MAX_FIXED * 3) / 2) 25 #endif 26 27 #define MAX_MAX_FIXED 160 /* Status bar buffer size */ 28 29 /* Font attributes */ 30 /* Modified from bitset to ordinal to pack better and avoid 9/10 */ 31 32 #define FONT_NORMAL 1 33 #define FONT_REVS 2 34 #define FONT_BOLD 3 35 #define FONT_EMPH 4 36 #define FONT_FIXED 5 37 #define FONT_FIXED_REVS 6 38 39 #define is_reverse(f) ((f)==FONT_REVS || (f)==FONT_FIXED_REVS) 40 #define is_fixed(f) ((f)==FONT_FIXED || (f)==FONT_FIXED_REVS) 41 42 #define mark(n,b) (((n)<<8)|((byte)(b))) 43 #define kind(c) (((c)>>8)&0xFF) 44 45 #define make_attr(f,b) (((f)<<4)+(b)) 46 47 #define attr_get_fore(a) (((a)>>4)&0x0F) 48 #define attr_get_back(a) ((a)&0x0F) 49 50 #define make_font_request(f) mark(1,f) 51 #define make_attr_request(a) mark(2,a) 52 53 #define request_get_data(r) ((r)&0xFF) 54 55 #define is_font_request(c) (kind(c)==1) 56 #define is_attr_request(c) (kind(c)==2) 57 58 typedef struct 59 { 60 #ifdef OLD 61 unsigned font : 4, fore : 4, back : 4; 62 #else 63 byte font, fore, back, dummy; 64 #endif 65 66 } console_attr; 67 68 typedef struct 69 { 70 byte text; 71 console_attr attr; 72 } console_cell; 73 74 typedef struct 75 { 76 unsigned flag : 1, just : 1, fix : 1; 77 int held; 78 console_cell *fixed; 79 console_cell *slack; 80 } console_row; 81 82 typedef struct 83 { 84 int x; 85 int y; 86 bool align; 87 console_attr attr; 88 } console_context; 89 90 typedef struct 91 { 92 int fixed; 93 int height; 94 } console_shape; 95 96 typedef struct 97 { 98 console_context cursor; 99 console_shape shape; 100 int top, bottom; 101 console_row row[MAX_HEIGHT]; 102 } console; 103 104 extern console con; 105 106 int find_eol(int); 107 void init_console(int, int); 108 void touch(int); 109 void start_update(void); 110 void finish_update(void); 111 void force_update(void); 112 void set_xy(int, int); 113 void goto_xy(int, int); 114 void force_font(int); 115 void put_char(word); 116 void use_window(int); 117 void erase_to_eoln(void); 118 void erase_window(word, word); 119 void swap_font_status(int *); 120 void save_attributes(int); 121 void restore_attributes(int); 122 void get_xy(int *, int *); 123 void clip_attributes(void); 124 #ifdef OLD 125 int is_a_space(const console_cell *); 126 #else 127 #define is_a_space(c) ((c).text==' ' && (c).attr.font!=FONT_FIXED_REVS) 128 #endif 129 void allocate_console(void); 130 131 #endif 132 133