Fixed issue #2495: "Show Reflog" dialog shows empty action for "push" entries
[TortoiseGit.git] / src / TortoisePlink / TERMINAL.H
blob80bad86d7dbb2de59aa9b40ccfc16bf9d9e068b4
1 /*\r
2  * Internals of the Terminal structure, for those other modules\r
3  * which need to look inside it. It would be nice if this could be\r
4  * folded back into terminal.c in future, with an abstraction layer\r
5  * to handle everything that other modules need to know about it;\r
6  * but for the moment, this will do.\r
7  */\r
8 \r
9 #ifndef PUTTY_TERMINAL_H\r
10 #define PUTTY_TERMINAL_H\r
12 #include "tree234.h"\r
14 struct beeptime {\r
15     struct beeptime *next;\r
16     unsigned long ticks;\r
17 };\r
19 typedef struct {\r
20     int y, x;\r
21 } pos;\r
23 #ifdef OPTIMISE_SCROLL\r
24 struct scrollregion {\r
25     struct scrollregion *next;\r
26     int topline; /* Top line of scroll region. */\r
27     int botline; /* Bottom line of scroll region. */\r
28     int lines; /* Number of lines to scroll by - +ve is forwards. */\r
29 };\r
30 #endif /* OPTIMISE_SCROLL */\r
32 typedef struct termchar termchar;\r
33 typedef struct termline termline;\r
35 struct termchar {\r
36     /*\r
37      * Any code in terminal.c which definitely needs to be changed\r
38      * when extra fields are added here is labelled with a comment\r
39      * saying FULL-TERMCHAR.\r
40      */\r
41     unsigned long chr;\r
42     unsigned long attr;\r
44     /*\r
45      * The cc_next field is used to link multiple termchars\r
46      * together into a list, so as to fit more than one character\r
47      * into a character cell (Unicode combining characters).\r
48      * \r
49      * cc_next is a relative offset into the current array of\r
50      * termchars. I.e. to advance to the next character in a list,\r
51      * one does `tc += tc->next'.\r
52      * \r
53      * Zero means end of list.\r
54      */\r
55     int cc_next;\r
56 };\r
58 struct termline {\r
59     unsigned short lattr;\r
60     int cols;                          /* number of real columns on the line */\r
61     int size;                          /* number of allocated termchars\r
62                                         * (cc-lists may make this > cols) */\r
63     int temporary;                     /* TRUE if decompressed from scrollback */\r
64     int cc_free;                       /* offset to first cc in free list */\r
65     struct termchar *chars;\r
66 };\r
68 struct bidi_cache_entry {\r
69     int width;\r
70     struct termchar *chars;\r
71     int *forward, *backward;           /* the permutations of line positions */\r
72 };\r
74 struct terminal_tag {\r
76     int compatibility_level;\r
78     tree234 *scrollback;               /* lines scrolled off top of screen */\r
79     tree234 *screen;                   /* lines on primary screen */\r
80     tree234 *alt_screen;               /* lines on alternate screen */\r
81     int disptop;                       /* distance scrolled back (0 or -ve) */\r
82     int tempsblines;                   /* number of lines of .scrollback that\r
83                                           can be retrieved onto the terminal\r
84                                           ("temporary scrollback") */\r
86     termline **disptext;               /* buffer of text on real screen */\r
87     int dispcursx, dispcursy;          /* location of cursor on real screen */\r
88     int curstype;                      /* type of cursor on real screen */\r
90 #define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */\r
92     struct beeptime *beephead, *beeptail;\r
93     int nbeeps;\r
94     int beep_overloaded;\r
95     long lastbeep;\r
97 #define TTYPE termchar\r
98 #define TSIZE (sizeof(TTYPE))\r
100 #ifdef OPTIMISE_SCROLL\r
101     struct scrollregion *scrollhead, *scrolltail;\r
102 #endif /* OPTIMISE_SCROLL */\r
104     int default_attr, curr_attr, save_attr;\r
105     termchar basic_erase_char, erase_char;\r
107     bufchain inbuf;                    /* terminal input buffer */\r
108     pos curs;                          /* cursor */\r
109     pos savecurs;                      /* saved cursor position */\r
110     int marg_t, marg_b;                /* scroll margins */\r
111     int dec_om;                        /* DEC origin mode flag */\r
112     int wrap, wrapnext;                /* wrap flags */\r
113     int insert;                        /* insert-mode flag */\r
114     int cset;                          /* 0 or 1: which char set */\r
115     int save_cset, save_csattr;        /* saved with cursor position */\r
116     int save_utf, save_wnext;          /* saved with cursor position */\r
117     int rvideo;                        /* global reverse video flag */\r
118     unsigned long rvbell_startpoint;   /* for ESC[?5hESC[?5l vbell */\r
119     int cursor_on;                     /* cursor enabled flag */\r
120     int reset_132;                     /* Flag ESC c resets to 80 cols */\r
121     int use_bce;                       /* Use Background coloured erase */\r
122     int cblinker;                      /* When blinking is the cursor on ? */\r
123     int tblinker;                      /* When the blinking text is on */\r
124     int blink_is_real;                 /* Actually blink blinking text */\r
125     int term_echoing;                  /* Does terminal want local echo? */\r
126     int term_editing;                  /* Does terminal want local edit? */\r
127     int sco_acs, save_sco_acs;         /* CSI 10,11,12m -> OEM charset */\r
128     int vt52_bold;                     /* Force bold on non-bold colours */\r
129     int utf;                           /* Are we in toggleable UTF-8 mode? */\r
130     int utf_state;                     /* Is there a pending UTF-8 character */\r
131     int utf_char;                      /* and what is it so far. */\r
132     int utf_size;                      /* The size of the UTF character. */\r
133     int printing, only_printing;       /* Are we doing ANSI printing? */\r
134     int print_state;                   /* state of print-end-sequence scan */\r
135     bufchain printer_buf;              /* buffered data for printer */\r
136     printer_job *print_job;\r
138     /* ESC 7 saved state for the alternate screen */\r
139     pos alt_savecurs;\r
140     int alt_save_attr;\r
141     int alt_save_cset, alt_save_csattr;\r
142     int alt_save_utf, alt_save_wnext;\r
143     int alt_save_sco_acs;\r
145     int rows, cols, savelines;\r
146     int has_focus;\r
147     int in_vbell;\r
148     long vbell_end;\r
149     int app_cursor_keys, app_keypad_keys, vt52_mode;\r
150     int repeat_off, cr_lf_return;\r
151     int seen_disp_event;\r
152     int big_cursor;\r
154     int xterm_mouse;                   /* send mouse messages to host */\r
155     int xterm_extended_mouse;\r
156     int urxvt_extended_mouse;\r
157     int mouse_is_down;                 /* used while tracking mouse buttons */\r
159     int bracketed_paste;\r
161     int cset_attr[2];\r
163 /*\r
164  * Saved settings on the alternate screen.\r
165  */\r
166     int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins;\r
167     int alt_cset, alt_sco_acs, alt_utf;\r
168     int alt_t, alt_b;\r
169     int alt_which;\r
170     int alt_sblines; /* # of lines on alternate screen that should be used for scrollback. */\r
172 #define ARGS_MAX 32                    /* max # of esc sequence arguments */\r
173 #define ARG_DEFAULT 0                  /* if an arg isn't specified */\r
174 #define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )\r
175     int esc_args[ARGS_MAX];\r
176     int esc_nargs;\r
177     int esc_query;\r
178 #define ANSI(x,y)       ((x)+((y)<<8))\r
179 #define ANSI_QUE(x)     ANSI(x,TRUE)\r
181 #define OSC_STR_MAX 2048\r
182     int osc_strlen;\r
183     char osc_string[OSC_STR_MAX + 1];\r
184     int osc_w;\r
186     char id_string[1024];\r
188     unsigned char *tabs;\r
190     enum {\r
191         TOPLEVEL,\r
192         SEEN_ESC,\r
193         SEEN_CSI,\r
194         SEEN_OSC,\r
195         SEEN_OSC_W,\r
197         DO_CTRLS,\r
199         SEEN_OSC_P,\r
200         OSC_STRING, OSC_MAYBE_ST,\r
201         VT52_ESC,\r
202         VT52_Y1,\r
203         VT52_Y2,\r
204         VT52_FG,\r
205         VT52_BG\r
206     } termstate;\r
208     enum {\r
209         NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED\r
210     } selstate;\r
211     enum {\r
212         LEXICOGRAPHIC, RECTANGULAR\r
213     } seltype;\r
214     enum {\r
215         SM_CHAR, SM_WORD, SM_LINE\r
216     } selmode;\r
217     pos selstart, selend, selanchor;\r
219     short wordness[256];\r
221     /* Mask of attributes to pay attention to when painting. */\r
222     int attr_mask;\r
224     wchar_t *paste_buffer;\r
225     int paste_len, paste_pos;\r
227     void (*resize_fn)(void *, int, int);\r
228     void *resize_ctx;\r
230     void *ldisc;\r
232     void *frontend;\r
234     void *logctx;\r
236     struct unicode_data *ucsdata;\r
238     /*\r
239      * We maintain a full copy of a Conf here, not merely a pointer\r
240      * to it. That way, when we're passed a new one for\r
241      * reconfiguration, we can check the differences and adjust the\r
242      * _current_ setting of (e.g.) auto wrap mode rather than only\r
243      * the default.\r
244      */\r
245     Conf *conf;\r
247     /*\r
248      * from_backend calls term_out, but it can also be called from\r
249      * the ldisc if the ldisc is called _within_ term_out. So we\r
250      * have to guard against re-entrancy - if from_backend is\r
251      * called recursively like this, it will simply add data to the\r
252      * end of the buffer term_out is in the process of working\r
253      * through.\r
254      */\r
255     int in_term_out;\r
257     /*\r
258      * We schedule a window update shortly after receiving terminal\r
259      * data. This tracks whether one is currently pending.\r
260      */\r
261     int window_update_pending;\r
262     long next_update;\r
264     /*\r
265      * Track pending blinks and tblinks.\r
266      */\r
267     int tblink_pending, cblink_pending;\r
268     long next_tblink, next_cblink;\r
270     /*\r
271      * These are buffers used by the bidi and Arabic shaping code.\r
272      */\r
273     termchar *ltemp;\r
274     int ltemp_size;\r
275     bidi_char *wcFrom, *wcTo;\r
276     int wcFromTo_size;\r
277     struct bidi_cache_entry *pre_bidi_cache, *post_bidi_cache;\r
278     int bidi_cache_size;\r
280     /*\r
281      * We copy a bunch of stuff out of the Conf structure into local\r
282      * fields in the Terminal structure, to avoid the repeated\r
283      * tree234 lookups which would be involved in fetching them from\r
284      * the former every time.\r
285      */\r
286     int ansi_colour;\r
287     char *answerback;\r
288     int answerbacklen;\r
289     int arabicshaping;\r
290     int beep;\r
291     int bellovl;\r
292     int bellovl_n;\r
293     int bellovl_s;\r
294     int bellovl_t;\r
295     int bidi;\r
296     int bksp_is_delete;\r
297     int blink_cur;\r
298     int blinktext;\r
299     int cjk_ambig_wide;\r
300     int conf_height;\r
301     int conf_width;\r
302     int crhaslf;\r
303     int erase_to_scrollback;\r
304     int funky_type;\r
305     int lfhascr;\r
306     int logflush;\r
307     int logtype;\r
308     int mouse_override;\r
309     int nethack_keypad;\r
310     int no_alt_screen;\r
311     int no_applic_c;\r
312     int no_applic_k;\r
313     int no_dbackspace;\r
314     int no_mouse_rep;\r
315     int no_remote_charset;\r
316     int no_remote_resize;\r
317     int no_remote_wintitle;\r
318     int rawcnp;\r
319     int rect_select;\r
320     int remote_qtitle_action;\r
321     int rxvt_homeend;\r
322     int scroll_on_disp;\r
323     int scroll_on_key;\r
324     int xterm_256_colour;\r
325 };\r
327 #define in_utf(term) ((term)->utf || (term)->ucsdata->line_codepage==CP_UTF8)\r
329 #endif\r