As usual, gcc is better at warnings than MSVC, so here are some
[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
2df34b43 32struct 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) */
40
41 unsigned long *cpos; /* cursor position (convenience) */
42
43 unsigned long *disptext; /* buffer of text on real screen */
44 unsigned long *dispcurs; /* location of cursor on real screen */
45 unsigned long curstype; /* type of cursor on real screen */
46
47#define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
48
49 struct beeptime *beephead, *beeptail;
50 int nbeeps;
51 int beep_overloaded;
52 long lastbeep;
53
54#define TSIZE (sizeof(unsigned long))
55#define fix_cpos do { \
56 term->cpos = lineptr(term->curs.y) + term->curs.x; \
57} while(0)
58
341eb978 59#ifdef OPTIMISE_SCROLL
60 struct scrollregion *scrollhead, *scrolltail;
61#endif /* OPTIMISE_SCROLL */
62
2df34b43 63 unsigned long curr_attr, save_attr;
64 unsigned long erase_char;
65
66 bufchain inbuf; /* terminal input buffer */
67 pos curs; /* cursor */
68 pos savecurs; /* saved cursor position */
69 int marg_t, marg_b; /* scroll margins */
70 int dec_om; /* DEC origin mode flag */
71 int wrap, wrapnext; /* wrap flags */
72 int insert; /* insert-mode flag */
73 int cset; /* 0 or 1: which char set */
74 int save_cset, save_csattr; /* saved with cursor position */
75 int save_utf, save_wnext; /* saved with cursor position */
76 int rvideo; /* global reverse video flag */
77 unsigned long rvbell_startpoint; /* for ESC[?5hESC[?5l vbell */
78 int cursor_on; /* cursor enabled flag */
79 int reset_132; /* Flag ESC c resets to 80 cols */
80 int use_bce; /* Use Background coloured erase */
81 int blinker; /* When blinking is the cursor on ? */
82 int tblinker; /* When the blinking text is on */
83 int blink_is_real; /* Actually blink blinking text */
84 int term_echoing; /* Does terminal want local echo? */
85 int term_editing; /* Does terminal want local edit? */
86 int sco_acs, save_sco_acs; /* CSI 10,11,12m -> OEM charset */
87 int vt52_bold; /* Force bold on non-bold colours */
88 int utf; /* Are we in toggleable UTF-8 mode? */
89 int utf_state; /* Is there a pending UTF-8 character */
90 int utf_char; /* and what is it so far. */
91 int utf_size; /* The size of the UTF character. */
92 int printing, only_printing; /* Are we doing ANSI printing? */
93 int print_state; /* state of print-end-sequence scan */
94 bufchain printer_buf; /* buffered data for printer */
95 printer_job *print_job;
96
97 int rows, cols, savelines;
98 int has_focus;
99 int in_vbell;
100 unsigned long vbell_startpoint;
101 int app_cursor_keys, app_keypad_keys, vt52_mode;
102 int repeat_off, cr_lf_return;
103 int seen_disp_event;
104 int big_cursor;
105
106 long last_blink; /* used for real blinking control */
107 long last_tblink;
108
109 int xterm_mouse; /* send mouse messages to app */
b9d7bcad 110 int mouse_is_down; /* used while tracking mouse buttons */
2df34b43 111
112 unsigned long cset_attr[2];
113
114/*
115 * Saved settings on the alternate screen.
116 */
117 int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;
118 int alt_cset, alt_sco_acs, alt_utf;
119 int alt_t, alt_b;
120 int alt_which;
121
122#define ARGS_MAX 32 /* max # of esc sequence arguments */
123#define ARG_DEFAULT 0 /* if an arg isn't specified */
124#define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )
125 int esc_args[ARGS_MAX];
126 int esc_nargs;
127 int esc_query;
128#define ANSI(x,y) ((x)+((y)<<8))
129#define ANSI_QUE(x) ANSI(x,TRUE)
130
131#define OSC_STR_MAX 2048
132 int osc_strlen;
133 char osc_string[OSC_STR_MAX + 1];
134 int osc_w;
135
136 char id_string[1024];
137
138 unsigned char *tabs;
139
140 enum {
141 TOPLEVEL,
142 SEEN_ESC,
143 SEEN_CSI,
144 SEEN_OSC,
145 SEEN_OSC_W,
146
147 DO_CTRLS,
148
149 SEEN_OSC_P,
150 OSC_STRING, OSC_MAYBE_ST,
151 VT52_ESC,
152 VT52_Y1,
153 VT52_Y2,
154 VT52_FG,
155 VT52_BG
156 } termstate;
157
158 enum {
159 NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
160 } selstate;
161 enum {
162 LEXICOGRAPHIC, RECTANGULAR
163 } seltype;
164 enum {
165 SM_CHAR, SM_WORD, SM_LINE
166 } selmode;
167 pos selstart, selend, selanchor;
168
169 short wordness[256];
170
2647b103 171 /* Mask of attributes to pay attention to when painting. */
172 unsigned long attr_mask;
173
2df34b43 174 wchar_t *paste_buffer;
175 int paste_len, paste_pos, paste_hold;
176 long last_paste;
51470298 177
178 void (*resize_fn)(void *, int, int);
179 void *resize_ctx;
b9d7bcad 180
181 void *ldisc;
a8327734 182
183 void *frontend;
184
185 void *logctx;
f6b14226 186
21d2b241 187 struct unicode_data *ucsdata;
188
64734920 189 /*
190 * We maintain a full _copy_ of a Config structure here, not
191 * merely a pointer to it. That way, when we're passed a new
192 * one for reconfiguration, we can check the differences and
193 * adjust the _current_ setting of (e.g.) auto wrap mode rather
194 * than only the default.
195 */
196 Config cfg;
2df34b43 197};
198
21d2b241 199#define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)
2df34b43 200
201#endif