2 PuTTY is copyright 1997-2004 Simon Tatham.
4 Portions copyright Robert de Bath, Joris van Rantwijk, Delian
5 Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
6 Justin Bradford, Ben Harris, and CORE SDI S.A.
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
23 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Internals of the Terminal structure, for those other modules
30 * which need to look inside it. It would be nice if this could be
31 * folded back into terminal.c in future, with an abstraction layer
32 * to handle everything that other modules need to know about it;
33 * but for the moment, this will do.
36 #ifndef PUTTY_TERMINAL_H
37 #define PUTTY_TERMINAL_H
42 struct beeptime *next;
50 #ifdef OPTIMISE_SCROLL
52 struct scrollregion *next;
53 int topline; /* Top line of scroll region. */
54 int botline; /* Bottom line of scroll region. */
55 int lines; /* Number of lines to scroll by - +ve is forwards. */
57 #endif /* OPTIMISE_SCROLL */
61 int compatibility_level;
63 tree234 *scrollback; /* lines scrolled off top of screen */
64 tree234 *screen; /* lines on primary screen */
65 tree234 *alt_screen; /* lines on alternate screen */
66 int disptop; /* distance scrolled back (0 or -ve) */
67 int tempsblines; /* number of lines in temporary
70 struct attr_tag *cpos; /* cursor position (convenience) */
72 struct attr_tag *disptext; /* buffer of text on real screen */
73 struct attr_tag *dispcurs; /* location of cursor on real screen */
74 unsigned long curstype; /* type of cursor on real screen */
76 #define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
78 struct beeptime *beephead, *beeptail;
83 #define TTYPE struct attr_tag
84 #define TSIZE (sizeof(TTYPE))
85 #define fix_cpos do { \
86 term->cpos = lineptr(term->curs.y) + term->curs.x; \
89 #ifdef OPTIMISE_SCROLL
90 struct scrollregion *scrollhead, *scrolltail;
91 #endif /* OPTIMISE_SCROLL */
93 struct attr_tag default_attr, curr_attr, save_attr;
94 struct attr_tag erase_char;
96 bufchain inbuf; /* terminal input buffer */
97 pos curs; /* cursor */
98 pos savecurs; /* saved cursor position */
99 int marg_t, marg_b; /* scroll margins */
100 int dec_om; /* DEC origin mode flag */
101 int wrap, wrapnext; /* wrap flags */
102 int insert; /* insert-mode flag */
103 int cset; /* 0 or 1: which char set */
104 int save_cset; /* saved with cursor position */
105 struct attr_tag save_csattr; /* saved with cursor position */
106 int save_utf, save_wnext; /* saved with cursor position */
107 int rvideo; /* global reverse video flag */
108 unsigned long rvbell_startpoint; /* for ESC[?5hESC[?5l vbell */
109 int cursor_on; /* cursor enabled flag */
110 int reset_132; /* Flag ESC c resets to 80 cols */
111 int use_bce; /* Use Background coloured erase */
112 int blinker; /* When blinking is the cursor on ? */
113 int tblinker; /* When the blinking text is on */
114 int blink_is_real; /* Actually blink blinking text */
115 int term_echoing; /* Does terminal want local echo? */
116 int term_editing; /* Does terminal want local edit? */
117 int sco_acs, save_sco_acs; /* CSI 10,11,12m -> OEM charset */
118 int vt52_bold; /* Force bold on non-bold colours */
119 int utf; /* Are we in toggleable UTF-8 mode? */
120 int utf_state; /* Is there a pending UTF-8 character */
121 uint32_t utf_char; /* and what is it so far. */
122 int utf_size; /* The size of the UTF character. */
123 int printing, only_printing; /* Are we doing ANSI printing? */
124 int print_state; /* state of print-end-sequence scan */
125 bufchain printer_buf; /* buffered data for printer */
126 printer_job *print_job;
128 int rows, cols, savelines;
131 unsigned long vbell_startpoint;
132 int app_cursor_keys, app_keypad_keys, vt52_mode;
133 int repeat_off, cr_lf_return;
137 long last_blink; /* used for real blinking control */
140 int xterm_mouse; /* send mouse messages to app */
141 int mouse_is_down; /* used while tracking mouse buttons */
143 struct attr_tag cset_attr[2];
146 * Saved settings on the alternate screen.
148 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;
149 int alt_cset, alt_sco_acs, alt_utf;
152 int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */
154 #define ARGS_MAX 32 /* max # of esc sequence arguments */
155 #define ARG_DEFAULT 0 /* if an arg isn't specified */
156 #define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )
157 int esc_args[ARGS_MAX];
160 #define ANSI(x,y) ((x)+((y)<<8))
161 #define ANSI_QUE(x) ANSI(x,TRUE)
163 #define OSC_STR_MAX 2048
165 char osc_string[OSC_STR_MAX + 1];
168 char id_string[1024];
182 OSC_STRING, OSC_MAYBE_ST,
191 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
194 LEXICOGRAPHIC, RECTANGULAR
197 SM_CHAR, SM_WORD, SM_LINE
199 pos selstart, selend, selanchor;
203 /* Mask of attributes to pay attention to when painting. */
204 struct attr_tag attr_mask;
206 wchar_t *paste_buffer;
207 int paste_len, paste_pos, paste_hold;
210 void (*resize_fn)(void *, int, int);
219 struct unicode_data *ucsdata;
222 * We maintain a full _copy_ of a Config structure here, not
223 * merely a pointer to it. That way, when we're passed a new
224 * one for reconfiguration, we can check the differences and
225 * adjust the _current_ setting of (e.g.) auto wrap mode rather
226 * than only the default.
231 * from_backend calls term_out, but it can also be called from
232 * the ldisc if the ldisc is called _within_ term_out. So we
233 * have to guard against re-entrancy - if from_backend is
234 * called recursively like this, it will simply add data to the
235 * end of the buffer term_out is in the process of working
241 #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)