annotate src/libvterm/src/pen.c @ 35167:6dddafdbe6f9 default tip

Added tag v9.1.0409 for changeset 0b259135fb3a4ce87fc1ff0673ae9b61cb7ed555
author Christian Brabandt <cb@256bit.org>
date Sun, 12 May 2024 00:15:05 +0200
parents b13f723a7ec6
children
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 #include "vterm_internal.h"
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 #include <stdio.h>
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
5 /**
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
6 * Structure used to store RGB triples without the additional metadata stored in
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
7 * VTermColor.
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
8 */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
9 typedef struct {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
10 uint8_t red, green, blue;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
11 } VTermRGB;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
12
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
13 static const VTermRGB ansi_colors[] = {
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
14 /* R G B */
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
15 { 0, 0, 0 }, // black
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
16 { 224, 0, 0 }, // red
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
17 { 0, 224, 0 }, // green
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
18 { 224, 224, 0 }, // yellow
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
19 { 0, 0, 224 }, // blue
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
20 { 224, 0, 224 }, // magenta
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
21 { 0, 224, 224 }, // cyan
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
22 { 224, 224, 224 }, // white == light grey
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
24 // high intensity
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
25 { 128, 128, 128 }, // black
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
26 { 255, 64, 64 }, // red
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
27 { 64, 255, 64 }, // green
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
28 { 255, 255, 64 }, // yellow
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
29 { 64, 64, 255 }, // blue
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
30 { 255, 64, 255 }, // magenta
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
31 { 64, 255, 255 }, // cyan
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
32 { 255, 255, 255 }, // white for real
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 static int ramp6[] = {
12541
fcb11cfca8b3 patch 8.0.1149: libvterm colors differ from xterm
Christian Brabandt <cb@256bit.org>
parents: 11856
diff changeset
36 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF,
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 };
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
17777
811a12a78164 patch 8.1.1885: comments in libvterm are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
39 // Use 0x81 instead of 0x80 to be able to distinguish from ansi black
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 static int ramp24[] = {
12541
fcb11cfca8b3 patch 8.0.1149: libvterm colors differ from xterm
Christian Brabandt <cb@256bit.org>
parents: 11856
diff changeset
41 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
fcb11cfca8b3 patch 8.0.1149: libvterm colors differ from xterm
Christian Brabandt <cb@256bit.org>
parents: 11856
diff changeset
42 0x81, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE,
11621
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
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
45 static void lookup_default_colour_ansi(long idx, VTermColor *col)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
46 {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
47 // VIM: store both RGB color and index
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
48 vterm_color_rgb(
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
49 col,
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
50 ansi_colors[idx].red, ansi_colors[idx].green, ansi_colors[idx].blue);
20555
eedaa9a30ab4 patch 8.2.0831: compiler warnings for integer sizes
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
51 col->index = (uint8_t)idx;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
52 col->type = VTERM_COLOR_INDEXED;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
53 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
54
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
55 static int lookup_colour_ansi(const VTermState *state, long index, VTermColor *col)
11621
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 if(index >= 0 && index < 16) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 *col = state->colors[index];
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
59 return TRUE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
62 return FALSE;
11621
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
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
65 static int lookup_colour_palette(const VTermState *state, long index, VTermColor *col)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 if(index >= 0 && index < 16) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
68 // Normal 8 colours or high intensity - parse as palette 0
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 return lookup_colour_ansi(state, index, col);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 else if(index >= 16 && index < 232) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
72 // 216-colour cube
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 index -= 16;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
75 vterm_color_rgb(col, ramp6[index/6/6 % 6],
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
76 ramp6[index/6 % 6],
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
77 ramp6[index % 6]);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
79 return TRUE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 else if(index >= 232 && index < 256) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
82 // 24 greyscales
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 index -= 232;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
85 vterm_color_rgb(col, ramp24[index], ramp24[index], ramp24[index]);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
87 return TRUE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
11780
c76b672df584 patch 8.0.0772: other stdbool.h dependencies in libvterm
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
90 return FALSE;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
93 static int lookup_colour(const VTermState *state, int palette, const long args[], int argcount, VTermColor *col)
11621
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 switch(palette) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
96 case 2: // RGB mode - 3 args contain colour values directly
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 if(argcount < 3)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 return argcount;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99
20555
eedaa9a30ab4 patch 8.2.0831: compiler warnings for integer sizes
Bram Moolenaar <Bram@vim.org>
parents: 20518
diff changeset
100 vterm_color_rgb(col, (uint8_t)CSI_ARG(args[0]), (uint8_t)CSI_ARG(args[1]), (uint8_t)CSI_ARG(args[2]));
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 return 3;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
104 case 5: // XTerm 256-colour mode
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
105 if (!argcount || CSI_ARG_IS_MISSING(args[0])) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
106 return argcount ? 1 : 0;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
107 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
109 lookup_colour_palette(state, args[0], col);
21085
bc81b275d4d6 patch 8.2.1094: dead code in libvterm
Bram Moolenaar <Bram@vim.org>
parents: 20555
diff changeset
110 return 1;
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 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 DEBUG_LOG1("Unrecognised colour palette %d\n", palette);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
118 // Some conveniences
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 static void setpenattr(VTermState *state, VTermAttr attr, VTermValueType type UNUSED, VTermValue *val)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 #ifdef DEBUG
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 if(type != vterm_get_attr_type(attr)) {
11856
1c0c6918926f patch 8.0.0808: cannot build with terminal feature and DEBUG defined
Christian Brabandt <cb@256bit.org>
parents: 11790
diff changeset
124 DEBUG_LOG3("Cannot set attr %d as it has type %d, not type %d\n",
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 attr, vterm_get_attr_type(attr), type);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 return;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 if(state->callbacks && state->callbacks->setpenattr)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 (*state->callbacks->setpenattr)(attr, val, state->cbdata);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 }
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 static void setpenattr_bool(VTermState *state, VTermAttr attr, int boolean)
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 VTermValue val;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 val.boolean = boolean;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 setpenattr(state, attr, VTERM_VALUETYPE_BOOL, &val);
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
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 static void setpenattr_int(VTermState *state, VTermAttr attr, int number)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 VTermValue val;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 val.number = number;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 setpenattr(state, attr, VTERM_VALUETYPE_INT, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 static void setpenattr_col(VTermState *state, VTermAttr attr, VTermColor color)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 VTermValue val;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 val.color = color;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 setpenattr(state, attr, VTERM_VALUETYPE_COLOR, &val);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 static void set_pen_col_ansi(VTermState *state, VTermAttr attr, long col)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 VTermColor *colp = (attr == VTERM_ATTR_BACKGROUND) ? &state->pen.bg : &state->pen.fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 lookup_colour_ansi(state, col, colp);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 setpenattr_col(state, attr, *colp);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 INTERNAL void vterm_state_newpen(VTermState *state)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
165 // 90% grey so that pure white is brighter
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
166 vterm_color_rgb(&state->default_fg, 240, 240, 240);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
167 vterm_color_rgb(&state->default_bg, 0, 0, 0);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
168 vterm_state_set_default_colors(state, &state->default_fg, &state->default_bg);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
170 for(int col = 0; col < 16; col++)
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
171 lookup_default_colour_ansi(col, &state->colors[col]);
11621
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
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 INTERNAL void vterm_state_resetpen(VTermState *state)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 state->pen.bold = 0; setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
177 state->pen.underline = 0; setpenattr_int (state, VTERM_ATTR_UNDERLINE, 0);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 state->pen.italic = 0; setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 state->pen.blink = 0; setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 state->pen.reverse = 0; setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
181 state->pen.conceal = 0; setpenattr_bool(state, VTERM_ATTR_CONCEAL, 0);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
183 state->pen.font = 0; setpenattr_int (state, VTERM_ATTR_FONT, 0);
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
184 state->pen.small = 0; setpenattr_bool(state, VTERM_ATTR_SMALL, 0);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
185 state->pen.baseline = 0; setpenattr_int (state, VTERM_ATTR_BASELINE, 0);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 state->pen.fg = state->default_fg; setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->default_fg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 state->pen.bg = state->default_bg; setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->default_bg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 INTERNAL 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
192 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 if(save) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 state->saved.pen = state->pen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 else {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 state->pen = state->saved.pen;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
199 setpenattr_bool(state, VTERM_ATTR_BOLD, state->pen.bold);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
200 setpenattr_int (state, VTERM_ATTR_UNDERLINE, state->pen.underline);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
201 setpenattr_bool(state, VTERM_ATTR_ITALIC, state->pen.italic);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
202 setpenattr_bool(state, VTERM_ATTR_BLINK, state->pen.blink);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
203 setpenattr_bool(state, VTERM_ATTR_REVERSE, state->pen.reverse);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
204 setpenattr_bool(state, VTERM_ATTR_CONCEAL, state->pen.conceal);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
205 setpenattr_bool(state, VTERM_ATTR_STRIKE, state->pen.strike);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
206 setpenattr_int (state, VTERM_ATTR_FONT, state->pen.font);
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
207 setpenattr_bool(state, VTERM_ATTR_SMALL, state->pen.small);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
208 setpenattr_int (state, VTERM_ATTR_BASELINE, state->pen.baseline);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
209
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 setpenattr_col( state, VTERM_ATTR_FOREGROUND, state->pen.fg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 setpenattr_col( state, VTERM_ATTR_BACKGROUND, state->pen.bg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 }
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
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
215 void vterm_color_rgb(VTermColor *col, uint8_t red, uint8_t green, uint8_t blue)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
216 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
217 col->type = VTERM_COLOR_RGB;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
218 col->red = red;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
219 col->green = green;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
220 col->blue = blue;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
221 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
222
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
223 void vterm_color_indexed(VTermColor *col, uint8_t idx)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
224 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
225 col->type = VTERM_COLOR_INDEXED;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
226 col->index = idx;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
227 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
228
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
229 int vterm_color_is_equal(const VTermColor *a, const VTermColor *b)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
230 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
231 /* First make sure that the two colours are of the same type (RGB/Indexed) */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
232 if (a->type != b->type) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
233 return FALSE;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
234 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
235
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
236 /* Depending on the type inspect the corresponding members */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
237 if (VTERM_COLOR_IS_INDEXED(a)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
238 return a->index == b->index;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
239 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
240 else if (VTERM_COLOR_IS_RGB(a)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
241 return (a->red == b->red)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
242 && (a->green == b->green)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
243 && (a->blue == b->blue);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
244 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
245
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
246 return 0;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
247 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
248
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 void vterm_state_get_default_colors(const VTermState *state, VTermColor *default_fg, VTermColor *default_bg)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 *default_fg = state->default_fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 *default_bg = state->default_bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 void vterm_state_get_palette_color(const VTermState *state, int index, VTermColor *col)
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 lookup_colour_palette(state, index, col);
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
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 {
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
262 if(default_fg) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
263 state->default_fg = *default_fg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
264 state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
265 | VTERM_COLOR_DEFAULT_FG;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
266 }
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
267
32728
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
268 if(default_bg) {
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
269 state->default_bg = *default_bg;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
270 state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
271 | VTERM_COLOR_DEFAULT_BG;
b13f723a7ec6 patch 9.0.1684: Update libvterm to rev 839
Christian Brabandt <cb@256bit.org>
parents: 30894
diff changeset
272 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 if(index >= 0 && index < 16)
12966
c5bccd50100e patch 8.0.1359: libvterm ANSI colors can not always be recognized
Christian Brabandt <cb@256bit.org>
parents: 12541
diff changeset
278 {
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 state->colors[index] = *col;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
280 state->colors[index].index = index + 1;
12966
c5bccd50100e patch 8.0.1359: libvterm ANSI colors can not always be recognized
Christian Brabandt <cb@256bit.org>
parents: 12541
diff changeset
281 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
284 void vterm_state_convert_color_to_rgb(const VTermState *state, VTermColor *col)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
285 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
286 if (VTERM_COLOR_IS_INDEXED(col)) { /* Convert indexed colors to RGB */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
287 lookup_colour_palette(state, col->index, col);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
288 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
289 col->type &= VTERM_COLOR_TYPE_MASK; /* Reset any metadata but the type */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
290 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
291
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 state->bold_is_highbright = bold_is_highbright;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 INTERNAL 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
298 {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
299 // SGR - ECMA-48 8.3.117
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 int argi = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 int value;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 while(argi < argcount) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
305 // This logic is easier to do 'done' backwards; set it true, and make it
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
306 // false again in the 'default' case
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 int done = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 long arg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 switch(arg = CSI_ARG(args[argi])) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 case CSI_ARG_MISSING:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
312 case 0: // Reset
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 vterm_state_resetpen(state);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
316 case 1: { // Bold on
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
317 const VTermColor *fg = &state->pen.fg;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 state->pen.bold = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 setpenattr_bool(state, VTERM_ATTR_BOLD, 1);
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
320 if(!VTERM_COLOR_IS_DEFAULT_FG(fg) && VTERM_COLOR_IS_INDEXED(fg) && fg->index < 8 && state->bold_is_highbright)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
321 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, fg->index + (state->pen.bold ? 8 : 0));
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 break;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
323 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
325 case 3: // Italic on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 state->pen.italic = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
330 case 4: // Underline
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
331 state->pen.underline = VTERM_UNDERLINE_SINGLE;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
332 if(CSI_ARG_HAS_MORE(args[argi])) {
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
333 argi++;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
334 switch(CSI_ARG(args[argi])) {
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
335 case 0:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
336 state->pen.underline = 0;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
337 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
338 case 1:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
339 state->pen.underline = VTERM_UNDERLINE_SINGLE;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
340 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
341 case 2:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
342 state->pen.underline = VTERM_UNDERLINE_DOUBLE;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
343 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
344 case 3:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
345 state->pen.underline = VTERM_UNDERLINE_CURLY;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
346 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
347 }
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
348 }
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
349 setpenattr_int(state, VTERM_ATTR_UNDERLINE, state->pen.underline);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
352 case 5: // Blink
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 state->pen.blink = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
357 case 7: // Reverse on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 state->pen.reverse = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
362 case 8: // Conceal on
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
363 state->pen.conceal = 1;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
364 setpenattr_bool(state, VTERM_ATTR_CONCEAL, 1);
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
365 break;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
366
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
367 case 9: // Strikethrough on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 state->pen.strike = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 case 10: case 11: case 12: case 13: case 14:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
373 case 15: case 16: case 17: case 18: case 19: // Select font
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 state->pen.font = CSI_ARG(args[argi]) - 10;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 setpenattr_int(state, VTERM_ATTR_FONT, state->pen.font);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
378 case 21: // Underline double
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
379 state->pen.underline = VTERM_UNDERLINE_DOUBLE;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
380 setpenattr_int(state, VTERM_ATTR_UNDERLINE, state->pen.underline);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
383 case 22: // Bold off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 state->pen.bold = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
388 case 23: // Italic and Gothic (currently unsupported) off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 state->pen.italic = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
393 case 24: // Underline off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 state->pen.underline = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
398 case 25: // Blink off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 state->pen.blink = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
403 case 27: // Reverse off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 state->pen.reverse = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
408 case 28: // Conceal off (Reveal)
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
409 state->pen.conceal = 0;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
410 setpenattr_bool(state, VTERM_ATTR_CONCEAL, 0);
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
411 break;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
412
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
413 case 29: // Strikethrough off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 state->pen.strike = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 case 30: case 31: case 32: case 33:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
419 case 34: case 35: case 36: case 37: // Foreground colour palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 value = CSI_ARG(args[argi]) - 30;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 if(state->pen.bold && state->bold_is_highbright)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 value += 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
426 case 38: // Foreground colour alternative palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 if(argcount - argi < 1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 return;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
429 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.fg);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
433 case 39: // Foreground colour default
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 state->pen.fg = state->default_fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 case 40: case 41: case 42: case 43:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
439 case 44: case 45: case 46: case 47: // Background colour palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 value = CSI_ARG(args[argi]) - 40;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
444 case 48: // Background colour alternative palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 if(argcount - argi < 1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 return;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
447 argi += 1 + lookup_colour(state, CSI_ARG(args[argi+1]), args+argi+2, argcount-argi-2, &state->pen.bg);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
451 case 49: // Default background
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 state->pen.bg = state->default_bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
456 case 73: // Superscript
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
457 case 74: // Subscript
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
458 case 75: // Superscript/subscript off
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
459 state->pen.small = (arg != 75);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
460 state->pen.baseline =
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
461 (arg == 73) ? VTERM_BASELINE_RAISE :
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
462 (arg == 74) ? VTERM_BASELINE_LOWER :
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
463 VTERM_BASELINE_NORMAL;
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
464 setpenattr_bool(state, VTERM_ATTR_SMALL, state->pen.small);
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
465 setpenattr_int (state, VTERM_ATTR_BASELINE, state->pen.baseline);
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
466 break;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
467
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 case 90: case 91: case 92: case 93:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
469 case 94: case 95: case 96: case 97: // Foreground colour high-intensity palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 value = CSI_ARG(args[argi]) - 90 + 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 case 100: case 101: case 102: case 103:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
475 case 104: case 105: case 106: case 107: // Background colour high-intensity palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 value = CSI_ARG(args[argi]) - 100 + 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 done = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
485 if(!done)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 {
19091
1c75e1974313 patch 8.2.0106: printf formats are not exactly right
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
487 DEBUG_LOG1("libvterm: Unhandled CSI SGR %ld\n", arg);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
490 while(CSI_ARG_HAS_MORE(args[argi++]))
16162
cd5c83115ec6 patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents: 13770
diff changeset
491 ;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
495 static int vterm_state_getpen_color(const VTermColor *col, int argi, long args[], int fg)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
496 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
497 /* Do nothing if the given color is the default color */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
498 if (( fg && VTERM_COLOR_IS_DEFAULT_FG(col)) ||
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
499 (!fg && VTERM_COLOR_IS_DEFAULT_BG(col))) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
500 return argi;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
501 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
502
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
503 /* Decide whether to send an indexed color or an RGB color */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
504 if (VTERM_COLOR_IS_INDEXED(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
505 const uint8_t idx = col->index;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
506 if (idx < 8) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
507 args[argi++] = (idx + (fg ? 30 : 40));
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
508 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
509 else if (idx < 16) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
510 args[argi++] = (idx - 8 + (fg ? 90 : 100));
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
511 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
512 else {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
513 args[argi++] = CSI_ARG_FLAG_MORE | (fg ? 38 : 48);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
514 args[argi++] = CSI_ARG_FLAG_MORE | 5;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
515 args[argi++] = idx;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
516 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
517 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
518 else if (VTERM_COLOR_IS_RGB(col)) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
519 args[argi++] = CSI_ARG_FLAG_MORE | (fg ? 38 : 48);
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
520 args[argi++] = CSI_ARG_FLAG_MORE | 2;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
521 args[argi++] = CSI_ARG_FLAG_MORE | col->red;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
522 args[argi++] = CSI_ARG_FLAG_MORE | col->green;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
523 args[argi++] = col->blue;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
524 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
525 return argi;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
526 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
527
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount UNUSED)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 int argi = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 if(state->pen.bold)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 args[argi++] = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 if(state->pen.italic)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 args[argi++] = 3;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
538 if(state->pen.underline == VTERM_UNDERLINE_SINGLE)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 args[argi++] = 4;
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
540 if(state->pen.underline == VTERM_UNDERLINE_CURLY)
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
541 args[argi++] = 4 | CSI_ARG_FLAG_MORE, args[argi++] = 3;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 if(state->pen.blink)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 args[argi++] = 5;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 if(state->pen.reverse)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 args[argi++] = 7;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
549 if(state->pen.conceal)
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
550 args[argi++] = 8;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
551
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 if(state->pen.strike)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 args[argi++] = 9;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 if(state->pen.font)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 args[argi++] = 10 + state->pen.font;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
558 if(state->pen.underline == VTERM_UNDERLINE_DOUBLE)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 args[argi++] = 21;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
561 argi = vterm_state_getpen_color(&state->pen.fg, argi, args, TRUE);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
563 argi = vterm_state_getpen_color(&state->pen.bg, argi, args, FALSE);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
565 if(state->pen.small) {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
566 if(state->pen.baseline == VTERM_BASELINE_RAISE)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
567 args[argi++] = 73;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
568 else if(state->pen.baseline == VTERM_BASELINE_LOWER)
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
569 args[argi++] = 74;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
570 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
571
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572 return argi;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue *val)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 switch(attr) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 case VTERM_ATTR_BOLD:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 val->boolean = state->pen.bold;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 case VTERM_ATTR_UNDERLINE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 val->number = state->pen.underline;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 case VTERM_ATTR_ITALIC:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587 val->boolean = state->pen.italic;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 case VTERM_ATTR_BLINK:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591 val->boolean = state->pen.blink;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 case VTERM_ATTR_REVERSE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 val->boolean = state->pen.reverse;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
598 case VTERM_ATTR_CONCEAL:
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
599 val->boolean = state->pen.conceal;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
600 return 1;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
601
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 case VTERM_ATTR_STRIKE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 val->boolean = state->pen.strike;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 case VTERM_ATTR_FONT:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 val->number = state->pen.font;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 case VTERM_ATTR_FOREGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 val->color = state->pen.fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 case VTERM_ATTR_BACKGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 val->color = state->pen.bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 return 1;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
617
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
618 case VTERM_ATTR_SMALL:
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
619 val->boolean = state->pen.small;
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
620 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
621
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
622 case VTERM_ATTR_BASELINE:
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
623 val->number = state->pen.baseline;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
624 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
625
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
626 case VTERM_N_ATTRS:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
627 return 0;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 }