2df34b43 |
1 | /* |
2 | * Internals of the Terminal structure, for those other modules |
3 | * which need to look inside it. It would be nice if this could be |
4 | * folded back into terminal.c in future, with an abstraction layer |
5 | * to handle everything that other modules need to know about it; |
6 | * but for the moment, this will do. |
7 | */ |
8 | |
9 | #ifndef PUTTY_TERMINAL_H |
10 | #define PUTTY_TERMINAL_H |
11 | |
12 | #include "tree234.h" |
13 | |
14 | struct beeptime { |
15 | struct beeptime *next; |
16 | unsigned long ticks; |
17 | }; |
18 | |
19 | typedef struct { |
20 | int y, x; |
21 | } pos; |
22 | |
341eb978 |
23 | #ifdef OPTIMISE_SCROLL |
24 | struct scrollregion { |
25 | struct scrollregion *next; |
26 | int topline; /* Top line of scroll region. */ |
27 | int botline; /* Bottom line of scroll region. */ |
28 | int lines; /* Number of lines to scroll by - +ve is forwards. */ |
29 | }; |
30 | #endif /* OPTIMISE_SCROLL */ |
31 | |
2df34b43 |
32 | struct terminal_tag { |
33 | |
34 | int compatibility_level; |
35 | |
36 | tree234 *scrollback; /* lines scrolled off top of screen */ |
37 | tree234 *screen; /* lines on primary screen */ |
38 | tree234 *alt_screen; /* lines on alternate screen */ |
39 | int disptop; /* distance scrolled back (0 or -ve) */ |
4683b9b6 |
40 | int tempsblines; /* number of lines in temporary |
41 | scrollback */ |
2df34b43 |
42 | |
43 | unsigned long *cpos; /* cursor position (convenience) */ |
44 | |
45 | unsigned long *disptext; /* buffer of text on real screen */ |
46 | unsigned long *dispcurs; /* location of cursor on real screen */ |
47 | unsigned long curstype; /* type of cursor on real screen */ |
48 | |
49 | #define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */ |
50 | |
51 | struct beeptime *beephead, *beeptail; |
52 | int nbeeps; |
53 | int beep_overloaded; |
54 | long lastbeep; |
55 | |
3d88e64d |
56 | #define TTYPE unsigned long |
57 | #define TSIZE (sizeof(TTYPE)) |
2df34b43 |
58 | #define fix_cpos do { \ |
59 | term->cpos = lineptr(term->curs.y) + term->curs.x; \ |
60 | } while(0) |
61 | |
341eb978 |
62 | #ifdef OPTIMISE_SCROLL |
63 | struct scrollregion *scrollhead, *scrolltail; |
64 | #endif /* OPTIMISE_SCROLL */ |
65 | |
092dd01c |
66 | unsigned long default_attr, curr_attr, save_attr; |
2df34b43 |
67 | unsigned long erase_char; |
68 | |
69 | bufchain inbuf; /* terminal input buffer */ |
70 | pos curs; /* cursor */ |
71 | pos savecurs; /* saved cursor position */ |
72 | int marg_t, marg_b; /* scroll margins */ |
73 | int dec_om; /* DEC origin mode flag */ |
74 | int wrap, wrapnext; /* wrap flags */ |
75 | int insert; /* insert-mode flag */ |
76 | int cset; /* 0 or 1: which char set */ |
77 | int save_cset, save_csattr; /* saved with cursor position */ |
78 | int save_utf, save_wnext; /* saved with cursor position */ |
79 | int rvideo; /* global reverse video flag */ |
80 | unsigned long rvbell_startpoint; /* for ESC[?5hESC[?5l vbell */ |
81 | int cursor_on; /* cursor enabled flag */ |
82 | int reset_132; /* Flag ESC c resets to 80 cols */ |
83 | int use_bce; /* Use Background coloured erase */ |
84 | int blinker; /* When blinking is the cursor on ? */ |
85 | int tblinker; /* When the blinking text is on */ |
86 | int blink_is_real; /* Actually blink blinking text */ |
87 | int term_echoing; /* Does terminal want local echo? */ |
88 | int term_editing; /* Does terminal want local edit? */ |
89 | int sco_acs, save_sco_acs; /* CSI 10,11,12m -> OEM charset */ |
90 | int vt52_bold; /* Force bold on non-bold colours */ |
91 | int utf; /* Are we in toggleable UTF-8 mode? */ |
92 | int utf_state; /* Is there a pending UTF-8 character */ |
93 | int utf_char; /* and what is it so far. */ |
94 | int utf_size; /* The size of the UTF character. */ |
95 | int printing, only_printing; /* Are we doing ANSI printing? */ |
96 | int print_state; /* state of print-end-sequence scan */ |
97 | bufchain printer_buf; /* buffered data for printer */ |
98 | printer_job *print_job; |
99 | |
100 | int rows, cols, savelines; |
101 | int has_focus; |
102 | int in_vbell; |
103 | unsigned long vbell_startpoint; |
104 | int app_cursor_keys, app_keypad_keys, vt52_mode; |
105 | int repeat_off, cr_lf_return; |
106 | int seen_disp_event; |
107 | int big_cursor; |
108 | |
109 | long last_blink; /* used for real blinking control */ |
110 | long last_tblink; |
111 | |
112 | int xterm_mouse; /* send mouse messages to app */ |
b9d7bcad |
113 | int mouse_is_down; /* used while tracking mouse buttons */ |
2df34b43 |
114 | |
115 | unsigned long cset_attr[2]; |
116 | |
117 | /* |
118 | * Saved settings on the alternate screen. |
119 | */ |
120 | int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins; |
121 | int alt_cset, alt_sco_acs, alt_utf; |
122 | int alt_t, alt_b; |
123 | int alt_which; |
876e5d5e |
124 | int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */ |
2df34b43 |
125 | |
126 | #define ARGS_MAX 32 /* max # of esc sequence arguments */ |
127 | #define ARG_DEFAULT 0 /* if an arg isn't specified */ |
128 | #define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) ) |
129 | int esc_args[ARGS_MAX]; |
130 | int esc_nargs; |
131 | int esc_query; |
132 | #define ANSI(x,y) ((x)+((y)<<8)) |
133 | #define ANSI_QUE(x) ANSI(x,TRUE) |
134 | |
135 | #define OSC_STR_MAX 2048 |
136 | int osc_strlen; |
137 | char osc_string[OSC_STR_MAX + 1]; |
138 | int osc_w; |
139 | |
140 | char id_string[1024]; |
141 | |
142 | unsigned char *tabs; |
143 | |
144 | enum { |
145 | TOPLEVEL, |
146 | SEEN_ESC, |
147 | SEEN_CSI, |
148 | SEEN_OSC, |
149 | SEEN_OSC_W, |
150 | |
151 | DO_CTRLS, |
152 | |
153 | SEEN_OSC_P, |
154 | OSC_STRING, OSC_MAYBE_ST, |
155 | VT52_ESC, |
156 | VT52_Y1, |
157 | VT52_Y2, |
158 | VT52_FG, |
159 | VT52_BG |
160 | } termstate; |
161 | |
162 | enum { |
163 | NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED |
164 | } selstate; |
165 | enum { |
166 | LEXICOGRAPHIC, RECTANGULAR |
167 | } seltype; |
168 | enum { |
169 | SM_CHAR, SM_WORD, SM_LINE |
170 | } selmode; |
171 | pos selstart, selend, selanchor; |
172 | |
173 | short wordness[256]; |
174 | |
2647b103 |
175 | /* Mask of attributes to pay attention to when painting. */ |
176 | unsigned long attr_mask; |
177 | |
2df34b43 |
178 | wchar_t *paste_buffer; |
179 | int paste_len, paste_pos, paste_hold; |
180 | long last_paste; |
51470298 |
181 | |
182 | void (*resize_fn)(void *, int, int); |
183 | void *resize_ctx; |
b9d7bcad |
184 | |
185 | void *ldisc; |
a8327734 |
186 | |
187 | void *frontend; |
188 | |
189 | void *logctx; |
f6b14226 |
190 | |
21d2b241 |
191 | struct unicode_data *ucsdata; |
192 | |
64734920 |
193 | /* |
194 | * We maintain a full _copy_ of a Config structure here, not |
195 | * merely a pointer to it. That way, when we're passed a new |
196 | * one for reconfiguration, we can check the differences and |
197 | * adjust the _current_ setting of (e.g.) auto wrap mode rather |
198 | * than only the default. |
199 | */ |
200 | Config cfg; |
74aca06d |
201 | |
202 | /* |
203 | * from_backend calls term_out, but it can also be called from |
204 | * the ldisc if the ldisc is called _within_ term_out. So we |
205 | * have to guard against re-entrancy - if from_backend is |
206 | * called recursively like this, it will simply add data to the |
207 | * end of the buffer term_out is in the process of working |
208 | * through. |
209 | */ |
210 | int in_term_out; |
2df34b43 |
211 | }; |
212 | |
21d2b241 |
213 | #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8) |
2df34b43 |
214 | |
215 | #endif |