-#define has_compat(x) ( ((CL_##x)&compatibility_level) != 0 )
-
-static int compatibility_level = TM_PUTTY;
-
-static tree234 *scrollback; /* lines scrolled off top of screen */
-static tree234 *screen; /* lines on primary screen */
-static tree234 *alt_screen; /* lines on alternate screen */
-static int disptop; /* distance scrolled back (0 or -ve) */
-
-static unsigned long *cpos; /* cursor position (convenience) */
-
-static unsigned long *disptext; /* buffer of text on real screen */
-static unsigned long *dispcurs; /* location of cursor on real screen */
-static unsigned long curstype; /* type of cursor on real screen */
-
-#define VBELL_TIMEOUT 100 /* millisecond len of visual bell */
-
-struct beeptime {
- struct beeptime *next;
- long ticks;
-};
-static struct beeptime *beephead, *beeptail;
-int nbeeps;
-int beep_overloaded;
-long lastbeep;
-
-#define TSIZE (sizeof(unsigned long))
-#define fix_cpos do { cpos = lineptr(curs.y) + curs.x; } while(0)
-
-static unsigned long curr_attr, save_attr;
-static unsigned long erase_char = ERASE_CHAR;
-
-typedef struct {
- int y, x;
-} pos;
-#define poslt(p1,p2) ( (p1).y < (p2).y || ( (p1).y == (p2).y && (p1).x < (p2).x ) )
-#define posle(p1,p2) ( (p1).y < (p2).y || ( (p1).y == (p2).y && (p1).x <= (p2).x ) )
-#define poseq(p1,p2) ( (p1).y == (p2).y && (p1).x == (p2).x )
-#define posdiff(p1,p2) ( ((p1).y - (p2).y) * (cols+1) + (p1).x - (p2).x )
-#define incpos(p) ( (p).x == cols ? ((p).x = 0, (p).y++, 1) : ((p).x++, 0) )
-#define decpos(p) ( (p).x == 0 ? ((p).x = cols, (p).y--, 1) : ((p).x--, 0) )
-
-static pos curs; /* cursor */
-static pos savecurs; /* saved cursor position */
-static int marg_t, marg_b; /* scroll margins */
-static int dec_om; /* DEC origin mode flag */
-static int wrap, wrapnext; /* wrap flags */
-static int insert; /* insert-mode flag */
-static int cset; /* 0 or 1: which char set */
-static int save_cset, save_csattr; /* saved with cursor position */
-static int rvideo; /* global reverse video flag */
-static int rvbell_timeout; /* for ESC[?5hESC[?5l vbell */
-static int cursor_on; /* cursor enabled flag */
-static int reset_132; /* Flag ESC c resets to 80 cols */
-static int use_bce; /* Use Background coloured erase */
-static int blinker; /* When blinking is the cursor on ? */
-static int tblinker; /* When the blinking text is on */
-static int blink_is_real; /* Actually blink blinking text */
-static int term_echoing; /* Does terminal want local echo? */
-static int term_editing; /* Does terminal want local edit? */
-static int vt52_bold; /* Force bold on non-bold colours */
-static int utf_state; /* Is there a pending UTF-8 character */
-static int utf_char; /* and what is it so far. */
-static int utf_size; /* The size of the UTF character. */
-
-static int xterm_mouse; /* send mouse messages to app */
-
-static unsigned long cset_attr[2];
-
-/*
- * Saved settings on the alternate screen.
- */
-static int alt_x, alt_y, alt_om, alt_wrap, alt_wnext, alt_ins, alt_cset;
-static int alt_t, alt_b;
-static int alt_which;
-
-#define ARGS_MAX 32 /* max # of esc sequence arguments */
-#define ARG_DEFAULT 0 /* if an arg isn't specified */
-#define def(a,d) ( (a) == ARG_DEFAULT ? (d) : (a) )
-static int esc_args[ARGS_MAX];
-static int esc_nargs;
-static int esc_query;
-#define ANSI(x,y) ((x)+((y)<<8))
-#define ANSI_QUE(x) ANSI(x,TRUE)
-
-#define OSC_STR_MAX 2048
-static int osc_strlen;
-static char osc_string[OSC_STR_MAX + 1];
-static int osc_w;
-
-static char id_string[1024] = "\033[?6c";
-
-static unsigned char *tabs;
-
-static enum {
- TOPLEVEL,
- SEEN_ESC,
- SEEN_CSI,
- SEEN_OSC,
- SEEN_OSC_W,
-
- DO_CTRLS,
-
- SEEN_OSC_P,
- OSC_STRING, OSC_MAYBE_ST,
- VT52_ESC,
- VT52_Y1,
- VT52_Y2,
- VT52_FG,
- VT52_BG
-} termstate;
-
-static enum {
- NO_SELECTION, ABOUT_TO, DRAGGING, SELECTED
-} selstate;
-static enum {
- SM_CHAR, SM_WORD, SM_LINE
-} selmode;
-static pos selstart, selend, selanchor;
-
-static short wordness[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 01 */
- 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 1, 1, 1, 1, 1, 1, /* 23 */
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 1, 1, 1, 1, 2, /* 45 */
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 1, 1, 1, 1, 1, /* 67 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, /* 89 */
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, /* AB */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, /* CD */
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, /* EF */
-};