]> asedeno.scripts.mit.edu Git - pssh.git/blob - arm/vt100/terminal.h
My 2007-03-13 release:
[pssh.git] / arm / vt100 / terminal.h
1 /*
2 PuTTY is copyright 1997-2004 Simon Tatham.
3
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.
7
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:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
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.
26 */
27
28 /*
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.
34  */
35
36 #ifndef PUTTY_TERMINAL_H
37 #define PUTTY_TERMINAL_H
38
39 #include "tree234.h"
40
41 struct beeptime {
42     struct beeptime *next;
43     unsigned long ticks;
44 };
45
46 typedef struct {
47     int y, x;
48 } pos;
49
50 #ifdef OPTIMISE_SCROLL
51 struct scrollregion {
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. */
56 };
57 #endif /* OPTIMISE_SCROLL */
58
59 struct terminal_tag {
60
61     int compatibility_level;
62
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
68                                           scrollback */
69
70     struct attr_tag *cpos;             /* cursor position (convenience) */
71
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 */
75
76 #define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
77
78     struct beeptime *beephead, *beeptail;
79     int nbeeps;
80     int beep_overloaded;
81     long lastbeep;
82
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; \
87 } while(0)
88
89 #ifdef OPTIMISE_SCROLL
90     struct scrollregion *scrollhead, *scrolltail;
91 #endif /* OPTIMISE_SCROLL */
92
93     struct attr_tag default_attr, curr_attr, save_attr;
94     struct attr_tag erase_char;
95
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;
127
128     int rows, cols, savelines;
129     int has_focus;
130     int in_vbell;
131     unsigned long vbell_startpoint;
132     int app_cursor_keys, app_keypad_keys, vt52_mode;
133     int repeat_off, cr_lf_return;
134     int seen_disp_event;
135     int big_cursor;
136
137     long last_blink;                   /* used for real blinking control */
138     long last_tblink;
139
140     int xterm_mouse;                   /* send mouse messages to app */
141     int mouse_is_down;                 /* used while tracking mouse buttons */
142
143     struct attr_tag cset_attr[2];
144
145 /*
146  * Saved settings on the alternate screen.
147  */
148     int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;
149     int alt_cset, alt_sco_acs, alt_utf;
150     int alt_t, alt_b;
151     int alt_which;
152     int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */
153
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];
158     int esc_nargs;
159     int esc_query;
160 #define ANSI(x,y)       ((x)+((y)<<8))
161 #define ANSI_QUE(x)     ANSI(x,TRUE)
162
163 #define OSC_STR_MAX 2048
164     int osc_strlen;
165     char osc_string[OSC_STR_MAX + 1];
166     int osc_w;
167
168     char id_string[1024];
169
170     unsigned char *tabs;
171
172     enum {
173         TOPLEVEL,
174         SEEN_ESC,
175         SEEN_CSI,
176         SEEN_OSC,
177         SEEN_OSC_W,
178
179         DO_CTRLS,
180
181         SEEN_OSC_P,
182         OSC_STRING, OSC_MAYBE_ST,
183         VT52_ESC,
184         VT52_Y1,
185         VT52_Y2,
186         VT52_FG,
187         VT52_BG
188     } termstate;
189
190     enum {
191         NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
192     } selstate;
193     enum {
194         LEXICOGRAPHIC, RECTANGULAR
195     } seltype;
196     enum {
197         SM_CHAR, SM_WORD, SM_LINE
198     } selmode;
199     pos selstart, selend, selanchor;
200
201     short wordness[256];
202
203     /* Mask of attributes to pay attention to when painting. */
204     struct attr_tag attr_mask;
205
206     wchar_t *paste_buffer;
207     int paste_len, paste_pos, paste_hold;
208     long last_paste;
209
210     void (*resize_fn)(void *, int, int);
211     void *resize_ctx;
212
213     void *ldisc;
214
215     void *frontend;
216
217     void *logctx;
218
219     struct unicode_data *ucsdata;
220
221     /*
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.
227      */
228     Config cfg;
229
230     /*
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
236      * through.
237      */
238     int in_term_out;
239 };
240
241 #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)
242
243 #endif