Fix up documentation/usage messages for r6572.
[u/mdw/putty] / terminal.h
CommitLineData
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
14struct beeptime {
15 struct beeptime *next;
16 unsigned long ticks;
17};
18
19typedef struct {
20 int y, x;
21} pos;
22
341eb978 23#ifdef OPTIMISE_SCROLL
24struct 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
36566009 32typedef struct termchar termchar;
33typedef struct termline termline;
34
35struct termchar {
c6958dfe 36 /*
37 * Any code in terminal.c which definitely needs to be changed
38 * when extra fields are added here is labelled with a comment
39 * saying FULL-TERMCHAR.
40 */
36566009 41 unsigned long chr;
42 unsigned long attr;
c6958dfe 43
44 /*
45 * The cc_next field is used to link multiple termchars
46 * together into a list, so as to fit more than one character
47 * into a character cell (Unicode combining characters).
48 *
49 * cc_next is a relative offset into the current array of
50 * termchars. I.e. to advance to the next character in a list,
51 * one does `tc += tc->next'.
52 *
53 * Zero means end of list.
54 */
55 int cc_next;
36566009 56};
57
58struct termline {
59 unsigned short lattr;
c6958dfe 60 int cols; /* number of real columns on the line */
61 int size; /* number of allocated termchars
62 * (cc-lists may make this > cols) */
36566009 63 int temporary; /* TRUE if decompressed from scrollback */
c6958dfe 64 int cc_free; /* offset to first cc in free list */
36566009 65 struct termchar *chars;
66};
67
2caf3cd8 68struct bidi_cache_entry {
69 int width;
70 struct termchar *chars;
3c5a620c 71 int *forward, *backward; /* the permutations of line positions */
2caf3cd8 72};
73
2df34b43 74struct terminal_tag {
75
76 int compatibility_level;
77
78 tree234 *scrollback; /* lines scrolled off top of screen */
79 tree234 *screen; /* lines on primary screen */
80 tree234 *alt_screen; /* lines on alternate screen */
81 int disptop; /* distance scrolled back (0 or -ve) */
4683b9b6 82 int tempsblines; /* number of lines in temporary
83 scrollback */
2df34b43 84
36566009 85 termline **disptext; /* buffer of text on real screen */
86 int dispcursx, dispcursy; /* location of cursor on real screen */
87 int curstype; /* type of cursor on real screen */
2df34b43 88
89#define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
90
91 struct beeptime *beephead, *beeptail;
92 int nbeeps;
93 int beep_overloaded;
94 long lastbeep;
95
36566009 96#define TTYPE termchar
3d88e64d 97#define TSIZE (sizeof(TTYPE))
2df34b43 98
341eb978 99#ifdef OPTIMISE_SCROLL
100 struct scrollregion *scrollhead, *scrolltail;
101#endif /* OPTIMISE_SCROLL */
102
36566009 103 int default_attr, curr_attr, save_attr;
104 termchar basic_erase_char, erase_char;
2df34b43 105
106 bufchain inbuf; /* terminal input buffer */
107 pos curs; /* cursor */
108 pos savecurs; /* saved cursor position */
109 int marg_t, marg_b; /* scroll margins */
110 int dec_om; /* DEC origin mode flag */
111 int wrap, wrapnext; /* wrap flags */
112 int insert; /* insert-mode flag */
113 int cset; /* 0 or 1: which char set */
114 int save_cset, save_csattr; /* saved with cursor position */
115 int save_utf, save_wnext; /* saved with cursor position */
116 int rvideo; /* global reverse video flag */
117 unsigned long rvbell_startpoint; /* for ESC[?5hESC[?5l vbell */
118 int cursor_on; /* cursor enabled flag */
119 int reset_132; /* Flag ESC c resets to 80 cols */
120 int use_bce; /* Use Background coloured erase */
39934deb 121 int cblinker; /* When blinking is the cursor on ? */
2df34b43 122 int tblinker; /* When the blinking text is on */
123 int blink_is_real; /* Actually blink blinking text */
124 int term_echoing; /* Does terminal want local echo? */
125 int term_editing; /* Does terminal want local edit? */
126 int sco_acs, save_sco_acs; /* CSI 10,11,12m -> OEM charset */
127 int vt52_bold; /* Force bold on non-bold colours */
128 int utf; /* Are we in toggleable UTF-8 mode? */
129 int utf_state; /* Is there a pending UTF-8 character */
130 int utf_char; /* and what is it so far. */
131 int utf_size; /* The size of the UTF character. */
132 int printing, only_printing; /* Are we doing ANSI printing? */
133 int print_state; /* state of print-end-sequence scan */
134 bufchain printer_buf; /* buffered data for printer */
135 printer_job *print_job;
136
137 int rows, cols, savelines;
138 int has_focus;
139 int in_vbell;
39934deb 140 long vbell_end;
2df34b43 141 int app_cursor_keys, app_keypad_keys, vt52_mode;
142 int repeat_off, cr_lf_return;
143 int seen_disp_event;
144 int big_cursor;
145
2df34b43 146 int xterm_mouse; /* send mouse messages to app */
b9d7bcad 147 int mouse_is_down; /* used while tracking mouse buttons */
2df34b43 148
36566009 149 int cset_attr[2];
2df34b43 150
151/*
152 * Saved settings on the alternate screen.
153 */
154 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;
155 int alt_cset, alt_sco_acs, alt_utf;
156 int alt_t, alt_b;
157 int alt_which;
876e5d5e 158 int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */
2df34b43 159
160#define ARGS_MAX 32 /* max # of esc sequence arguments */
161#define ARG_DEFAULT 0 /* if an arg isn't specified */
162#define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )
163 int esc_args[ARGS_MAX];
164 int esc_nargs;
165 int esc_query;
166#define ANSI(x,y) ((x)+((y)<<8))
167#define ANSI_QUE(x) ANSI(x,TRUE)
168
169#define OSC_STR_MAX 2048
170 int osc_strlen;
171 char osc_string[OSC_STR_MAX + 1];
172 int osc_w;
173
174 char id_string[1024];
175
176 unsigned char *tabs;
177
178 enum {
179 TOPLEVEL,
180 SEEN_ESC,
181 SEEN_CSI,
182 SEEN_OSC,
183 SEEN_OSC_W,
184
185 DO_CTRLS,
186
187 SEEN_OSC_P,
188 OSC_STRING, OSC_MAYBE_ST,
189 VT52_ESC,
190 VT52_Y1,
191 VT52_Y2,
192 VT52_FG,
193 VT52_BG
194 } termstate;
195
196 enum {
197 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
198 } selstate;
199 enum {
200 LEXICOGRAPHIC, RECTANGULAR
201 } seltype;
202 enum {
203 SM_CHAR, SM_WORD, SM_LINE
204 } selmode;
205 pos selstart, selend, selanchor;
206
207 short wordness[256];
208
2647b103 209 /* Mask of attributes to pay attention to when painting. */
36566009 210 int attr_mask;
2647b103 211
2df34b43 212 wchar_t *paste_buffer;
213 int paste_len, paste_pos, paste_hold;
214 long last_paste;
51470298 215
216 void (*resize_fn)(void *, int, int);
217 void *resize_ctx;
b9d7bcad 218
219 void *ldisc;
a8327734 220
221 void *frontend;
222
223 void *logctx;
f6b14226 224
21d2b241 225 struct unicode_data *ucsdata;
226
64734920 227 /*
228 * We maintain a full _copy_ of a Config structure here, not
229 * merely a pointer to it. That way, when we're passed a new
230 * one for reconfiguration, we can check the differences and
231 * adjust the _current_ setting of (e.g.) auto wrap mode rather
232 * than only the default.
233 */
234 Config cfg;
74aca06d 235
236 /*
237 * from_backend calls term_out, but it can also be called from
238 * the ldisc if the ldisc is called _within_ term_out. So we
239 * have to guard against re-entrancy - if from_backend is
240 * called recursively like this, it will simply add data to the
241 * end of the buffer term_out is in the process of working
242 * through.
243 */
244 int in_term_out;
f0fccd51 245
246 /*
39934deb 247 * We schedule a window update shortly after receiving terminal
248 * data. This tracks whether one is currently pending.
249 */
250 int window_update_pending;
251 long next_update;
252
253 /*
254 * Track pending blinks and tblinks.
255 */
256 int tblink_pending, cblink_pending;
257 long next_tblink, next_cblink;
258
259 /*
f0fccd51 260 * These are buffers used by the bidi and Arabic shaping code.
261 */
36566009 262 termchar *ltemp;
c6958dfe 263 int ltemp_size;
f0fccd51 264 bidi_char *wcFrom, *wcTo;
c6958dfe 265 int wcFromTo_size;
2caf3cd8 266 struct bidi_cache_entry *pre_bidi_cache, *post_bidi_cache;
f0fccd51 267 int bidi_cache_size;
2df34b43 268};
269
21d2b241 270#define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)
2df34b43 271
272#endif