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.
9 #ifndef PUTTY_TERMINAL_H
10 #define PUTTY_TERMINAL_H
15 struct beeptime *next;
23 #ifdef OPTIMISE_SCROLL
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. */
30 #endif /* OPTIMISE_SCROLL */
32 typedef struct termchar termchar;
33 typedef struct termline termline;
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.
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).
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'.
53 * Zero means end of list.
60 int cols; /* number of real columns on the line */
61 int size; /* number of allocated termchars
62 * (cc-lists may make this > cols) */
63 int temporary; /* TRUE if decompressed from scrollback */
64 int cc_free; /* offset to first cc in free list */
65 struct termchar *chars;
68 struct bidi_cache_entry {
70 struct termchar *chars;
71 int *forward, *backward; /* the permutations of line positions */
76 int compatibility_level;
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) */
82 int tempsblines; /* number of lines of .scrollback that
83 can be retrieved onto the terminal
84 ("temporary scrollback") */
86 termline **disptext; /* buffer of text on real screen */
87 int dispcursx, dispcursy; /* location of cursor on real screen */
88 int curstype; /* type of cursor on real screen */
90 #define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
92 struct beeptime *beephead, *beeptail;
97 #define TTYPE termchar
98 #define TSIZE (sizeof(TTYPE))
100 #ifdef OPTIMISE_SCROLL
101 struct scrollregion *scrollhead, *scrolltail;
102 #endif /* OPTIMISE_SCROLL */
104 int default_attr, curr_attr, save_attr;
105 termchar basic_erase_char, erase_char;
107 bufchain inbuf; /* terminal input buffer */
108 pos curs; /* cursor */
109 pos savecurs; /* saved cursor position */
110 int marg_t, marg_b; /* scroll margins */
111 int dec_om; /* DEC origin mode flag */
112 int wrap, wrapnext; /* wrap flags */
113 int insert; /* insert-mode flag */
114 int cset; /* 0 or 1: which char set */
115 int save_cset, save_csattr; /* saved with cursor position */
116 int save_utf, save_wnext; /* saved with cursor position */
117 int rvideo; /* global reverse video flag */
118 unsigned long rvbell_startpoint; /* for ESC[?5hESC[?5l vbell */
119 int cursor_on; /* cursor enabled flag */
120 int reset_132; /* Flag ESC c resets to 80 cols */
121 int use_bce; /* Use Background coloured erase */
122 int cblinker; /* When blinking is the cursor on ? */
123 int tblinker; /* When the blinking text is on */
124 int blink_is_real; /* Actually blink blinking text */
125 int term_echoing; /* Does terminal want local echo? */
126 int term_editing; /* Does terminal want local edit? */
127 int sco_acs, save_sco_acs; /* CSI 10,11,12m -> OEM charset */
128 int vt52_bold; /* Force bold on non-bold colours */
129 int utf; /* Are we in toggleable UTF-8 mode? */
130 int utf_state; /* Is there a pending UTF-8 character */
131 int utf_char; /* and what is it so far. */
132 int utf_size; /* The size of the UTF character. */
133 int printing, only_printing; /* Are we doing ANSI printing? */
134 int print_state; /* state of print-end-sequence scan */
135 bufchain printer_buf; /* buffered data for printer */
136 printer_job *print_job;
138 /* ESC 7 saved state for the alternate screen */
141 int alt_save_cset, alt_save_csattr;
142 int alt_save_utf, alt_save_wnext;
143 int alt_save_sco_acs;
145 int rows, cols, savelines;
149 int app_cursor_keys, app_keypad_keys, vt52_mode;
150 int repeat_off, cr_lf_return;
154 int xterm_mouse; /* send mouse messages to app */
155 int mouse_is_down; /* used while tracking mouse buttons */
160 * Saved settings on the alternate screen.
162 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;
163 int alt_cset, alt_sco_acs, alt_utf;
166 int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */
168 #define ARGS_MAX 32 /* max # of esc sequence arguments */
169 #define ARG_DEFAULT 0 /* if an arg isn't specified */
170 #define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )
171 int esc_args[ARGS_MAX];
174 #define ANSI(x,y) ((x)+((y)<<8))
175 #define ANSI_QUE(x) ANSI(x,TRUE)
177 #define OSC_STR_MAX 2048
179 char osc_string[OSC_STR_MAX + 1];
182 char id_string[1024];
196 OSC_STRING, OSC_MAYBE_ST,
205 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
208 LEXICOGRAPHIC, RECTANGULAR
211 SM_CHAR, SM_WORD, SM_LINE
213 pos selstart, selend, selanchor;
217 /* Mask of attributes to pay attention to when painting. */
220 wchar_t *paste_buffer;
221 int paste_len, paste_pos, paste_hold;
224 void (*resize_fn)(void *, int, int);
233 struct unicode_data *ucsdata;
236 * We maintain a full _copy_ of a Config structure here, not
237 * merely a pointer to it. That way, when we're passed a new
238 * one for reconfiguration, we can check the differences and
239 * adjust the _current_ setting of (e.g.) auto wrap mode rather
240 * than only the default.
245 * from_backend calls term_out, but it can also be called from
246 * the ldisc if the ldisc is called _within_ term_out. So we
247 * have to guard against re-entrancy - if from_backend is
248 * called recursively like this, it will simply add data to the
249 * end of the buffer term_out is in the process of working
255 * We schedule a window update shortly after receiving terminal
256 * data. This tracks whether one is currently pending.
258 int window_update_pending;
262 * Track pending blinks and tblinks.
264 int tblink_pending, cblink_pending;
265 long next_tblink, next_cblink;
268 * These are buffers used by the bidi and Arabic shaping code.
272 bidi_char *wcFrom, *wcTo;
274 struct bidi_cache_entry *pre_bidi_cache, *post_bidi_cache;
278 #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)