annotate src/libvterm/src/vterm_internal.h @ 20399:d1a54d2bd145 v8.2.0754

patch 8.2.0754: Vim9: No test for forward declaration Commit: https://github.com/vim/vim/commit/a5d0077efbced85fcc63f203937b13efd55d036f Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 14 23:20:55 2020 +0200 patch 8.2.0754: Vim9: No test for forward declaration Problem: Vim9: No test for forward declaration. Solution: Add a test.
author Bram Moolenaar <Bram@vim.org>
date Thu, 14 May 2020 23:30:03 +0200
parents e8d1f3209dcd
children ffadba5f898c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 #ifndef __VTERM_INTERNAL_H__
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 #define __VTERM_INTERNAL_H__
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 #include "vterm.h"
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 #include <stdarg.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
13507
8bdcc8faeb32 patch 8.0.1627: compiler warning for visibility attribute not supported
Christian Brabandt <cb@256bit.org>
parents: 13448
diff changeset
8 #if defined(__GNUC__) && !defined(__MINGW32__)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 # define INTERNAL __attribute__((visibility("internal")))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 # define UNUSED __attribute__((unused))
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 #else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 # define INTERNAL
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 # define UNUSED
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 #ifdef DEBUG
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 # define DEBUG_LOG(s) fprintf(stderr, s)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 # define DEBUG_LOG1(s, a) fprintf(stderr, s, a)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 # define DEBUG_LOG2(s, a, b) fprintf(stderr, s, a, b)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 # define DEBUG_LOG3(s, a, b, c) fprintf(stderr, s, a, b, c)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 #else
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 # define DEBUG_LOG(s)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 # define DEBUG_LOG1(s, a)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 # define DEBUG_LOG2(s, a, b)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 # define DEBUG_LOG3(s, a, b, c)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 #define ESC_S "\x1b"
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
30 #define INTERMED_MAX 16
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
31
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
32 #define CSI_ARGS_MAX 16
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
33 #define CSI_LEADER_MAX 16
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
34
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 typedef struct VTermEncoding VTermEncoding;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 typedef struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 VTermEncoding *enc;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
40 // This size should be increased if required by other stateful encodings
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 char data[4*sizeof(uint32_t)];
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 } VTermEncodingInstance;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 struct VTermPen
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 VTermColor fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 VTermColor bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 unsigned int bold:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 unsigned int underline:2;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 unsigned int italic:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 unsigned int blink:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 unsigned int reverse:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 unsigned int strike:1;
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
54 unsigned int font:4; // To store 0-9
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 int vterm_color_equal(VTermColor a, VTermColor b);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 #if defined(DEFINE_INLINES) || USE_INLINE
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 INLINE int vterm_color_equal(VTermColor a, VTermColor b)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 return a.red == b.red && a.green == b.green && a.blue == b.blue;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 struct VTermState
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 VTerm *vt;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 const VTermStateCallbacks *callbacks;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 void *cbdata;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 const VTermParserCallbacks *fallbacks;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 void *fbdata;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 int rows;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 int cols;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
79 // Current cursor position
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
82 int at_phantom; // True if we're on the "81st" phantom column to defer a wraparound
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 int scrollregion_top;
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
85 int scrollregion_bottom; // -1 means unbounded
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 #define SCROLLREGION_BOTTOM(state) ((state)->scrollregion_bottom > -1 ? (state)->scrollregion_bottom : (state)->rows)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 int scrollregion_left;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 #define SCROLLREGION_LEFT(state) ((state)->mode.leftrightmargin ? (state)->scrollregion_left : 0)
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
89 int scrollregion_right; // -1 means unbounded
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 #define SCROLLREGION_RIGHT(state) ((state)->mode.leftrightmargin && (state)->scrollregion_right > -1 ? (state)->scrollregion_right : (state)->cols)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
92 // Bitvector of tab stops
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 unsigned char *tabstops;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 VTermLineInfo *lineinfo;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 #define ROWWIDTH(state,row) ((state)->lineinfo[(row)].doublewidth ? ((state)->cols / 2) : (state)->cols)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 #define THISROWWIDTH(state) ROWWIDTH(state, (state)->pos.row)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
99 // Mouse state
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 int mouse_col, mouse_row;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 int mouse_buttons;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 int mouse_flags;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 enum { MOUSE_X10, MOUSE_UTF8, MOUSE_SGR, MOUSE_RXVT } mouse_protocol;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
106 // Last glyph output, for Unicode recombining purposes
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 uint32_t *combine_chars;
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
108 size_t combine_chars_size; // Number of ELEMENTS in the above
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
109 int combine_width; // The width of the glyph above
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
110 VTermPos combine_pos; // Position before movement
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 unsigned int keypad:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 unsigned int cursor:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 unsigned int autowrap:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 unsigned int insert:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 unsigned int newline:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 unsigned int cursor_visible:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 unsigned int cursor_blink:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 unsigned int cursor_shape:2;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 unsigned int alt_screen:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 unsigned int origin:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 unsigned int screen:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 unsigned int leftrightmargin:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 unsigned int bracketpaste:1;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
126 unsigned int report_focus:1;
18279
e8d1f3209dcd patch 8.1.2134: modifier keys are not always recognized
Bram Moolenaar <Bram@vim.org>
parents: 18064
diff changeset
127 unsigned int modify_other_keys:1;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 } mode;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 VTermEncodingInstance encoding[4], encoding_utf8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 int gl_set, gr_set, gsingle_set;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 struct VTermPen pen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 VTermColor default_fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 VTermColor default_bg;
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
137 VTermColor colors[16]; // Store the 8 ANSI and the 8 ANSI high-brights only
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 int fg_index;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 int bg_index;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 int bold_is_highbright;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 unsigned int protected_cell : 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
145 // Saved state under DEC mode 1048/1049
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 VTermPos pos;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 struct VTermPen pen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 struct {
12080
93024e778745 patch 8.0.0920: cursor wrong after switching altscreen in terminal
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
151 unsigned int cursor_visible:1;
93024e778745 patch 8.0.0920: cursor wrong after switching altscreen in terminal
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
152 unsigned int cursor_blink:1;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 unsigned int cursor_shape:2;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 } mode;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 } saved;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
158 typedef enum {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
159 VTERM_PARSER_OSC,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
160 VTERM_PARSER_DCS,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
161
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
162 VTERM_N_PARSER_TYPES
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
163 } VTermParserStringType;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
164
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 struct VTerm
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 VTermAllocatorFunctions *allocator;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 void *allocdata;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 int rows;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 int cols;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 struct {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 unsigned int utf8:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 unsigned int ctrl8bit:1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 } mode;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
178 struct {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
179 enum VTermParserState {
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
180 NORMAL,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
181 CSI_LEADER,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
182 CSI_ARGS,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
183 CSI_INTERMED,
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
184 ESC,
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
185 // below here are the "string states"
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
186 STRING,
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
187 ESC_IN_STRING,
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
188 } state;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
189
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
190 int intermedlen;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
191 char intermed[INTERMED_MAX];
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
192
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
193 int csi_leaderlen;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
194 char csi_leader[CSI_LEADER_MAX];
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
195
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
196 int csi_argi;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
197 long csi_args[CSI_ARGS_MAX];
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
198
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
199 const VTermParserCallbacks *callbacks;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
200 void *cbdata;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
201
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
202 VTermParserStringType stringtype;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
203 char *strbuffer;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
204 size_t strbuffer_len;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
205 size_t strbuffer_cur;
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 13507
diff changeset
206 } parser;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
208 // len == malloc()ed size; cur == number of valid bytes
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 char *outbuffer;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 size_t outbuffer_len;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 size_t outbuffer_cur;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 VTermState *state;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 VTermScreen *screen;
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
216
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
217 int in_backspace;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 struct VTermEncoding {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 void (*init) (VTermEncoding *enc, void *data);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 void (*decode)(VTermEncoding *enc, void *data,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 uint32_t cp[], int *cpi, int cplen,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 const char bytes[], size_t *pos, size_t len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 typedef enum {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 ENC_UTF8,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 ENC_SINGLE_94
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 } VTermEncodingType;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 void *vterm_allocator_malloc(VTerm *vt, size_t size);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 void vterm_allocator_free(VTerm *vt, void *ptr);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 void vterm_push_output_bytes(VTerm *vt, const char *bytes, size_t len);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 void vterm_push_output_vsprintf(VTerm *vt, const char *format, va_list args);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 void vterm_push_output_sprintf(VTerm *vt, const char *format, ...);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 void vterm_push_output_sprintf_ctrl(VTerm *vt, unsigned char ctrl, const char *fmt, ...);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 void vterm_push_output_sprintf_dcs(VTerm *vt, const char *fmt, ...);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 void vterm_state_free(VTermState *state);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 void vterm_state_newpen(VTermState *state);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 void vterm_state_resetpen(VTermState *state);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245 void vterm_state_setpen(VTermState *state, const long args[], int argcount);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 int vterm_state_getpen(VTermState *state, long args[], int argcount);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 void vterm_state_savepen(VTermState *state, int save);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 enum {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 C1_SS3 = 0x8f,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 C1_DCS = 0x90,
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 C1_CSI = 0x9b,
13318
5e47c4bdf3a6 patch 8.0.1533: libterm doesn't support requesting fg and bg color
Christian Brabandt <cb@256bit.org>
parents: 12080
diff changeset
253 C1_ST = 0x9c,
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
254 C1_OSC = 0x9d,
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 void vterm_state_push_output_sprintf_CSI(VTermState *vts, const char *format, ...);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 void vterm_screen_free(VTermScreen *screen);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 VTermEncoding *vterm_lookup_encoding(VTermEncodingType type, char designation);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 int vterm_unicode_width(uint32_t codepoint);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 int vterm_unicode_is_combining(uint32_t codepoint);
18064
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
265 int vterm_unicode_is_ambiguous(uint32_t codepoint);
8b4f9be5db73 patch 8.1.2027: MS-Windows: problem with ambiwidth characters
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
266 int vterm_get_special_pty_type(void);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 #endif