annotate src/libvterm/src/pen.c @ 30894:bf4f25d50fdd v9.0.0781

patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy Commit: https://github.com/vim/vim/commit/e6a16e9950111adfcfdb85261b3d5a8c13f1d533 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 17 14:51:36 2022 +0100 patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy Problem: Workaround to rename "small" to "smallfont" is clumsy. Solution: Undefine "small" after including windows.h. (Ken Takata)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 Oct 2022 16:00:04 +0200
parents ac9464a32606
children b13f723a7ec6
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 {
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
262 /* Copy the given colors */
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 state->default_fg = *default_fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 state->default_bg = *default_bg;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
265
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
266 /* Make sure the correct type flags are set */
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
267 state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
268 | VTERM_COLOR_DEFAULT_FG;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
269 state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
270 | VTERM_COLOR_DEFAULT_BG;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 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
274 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 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
276 {
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 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
278 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
279 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
282 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
283 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
284 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
285 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
286 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
287 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
288 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
289
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 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
291 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 state->bold_is_highbright = 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
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 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
296 {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
297 // SGR - ECMA-48 8.3.117
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 int argi = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 int value;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 while(argi < argcount) {
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
303 // 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
304 // false again in the 'default' case
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 int done = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 long arg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 switch(arg = CSI_ARG(args[argi])) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 case CSI_ARG_MISSING:
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
310 case 0: // Reset
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 vterm_state_resetpen(state);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
314 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
315 const VTermColor *fg = &state->pen.fg;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 state->pen.bold = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 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
318 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
319 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
320 break;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
321 }
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
323 case 3: // Italic on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 state->pen.italic = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
328 case 4: // Underline
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
329 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
330 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
331 argi++;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
332 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
333 case 0:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
334 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
335 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
336 case 1:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
337 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
338 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
339 case 2:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
340 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
341 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
342 case 3:
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
343 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
344 break;
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
345 }
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
346 }
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
347 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
348 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
350 case 5: // Blink
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 state->pen.blink = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
355 case 7: // Reverse on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 state->pen.reverse = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
360 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
361 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
362 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
363 break;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
364
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
365 case 9: // Strikethrough on
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 state->pen.strike = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 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
371 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
372 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
373 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
374 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
376 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
377 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
378 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
379 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
381 case 22: // Bold off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 state->pen.bold = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
386 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
387 state->pen.italic = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
391 case 24: // Underline off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 state->pen.underline = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
396 case 25: // Blink off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 state->pen.blink = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
401 case 27: // Reverse off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 state->pen.reverse = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
406 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
407 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
408 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
409 break;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
410
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
411 case 29: // Strikethrough off
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 state->pen.strike = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 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
417 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
418 value = CSI_ARG(args[argi]) - 30;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 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
420 value += 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 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
422 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
424 case 38: // Foreground colour alternative palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 if(argcount - argi < 1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 return;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
427 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
428 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
429 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
431 case 39: // Foreground colour default
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 state->pen.fg = state->default_fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 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
434 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 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
437 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
438 value = CSI_ARG(args[argi]) - 40;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 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
440 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
442 case 48: // Background colour alternative palette
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 if(argcount - argi < 1)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 return;
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
445 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
446 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
447 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448
13770
2449b6ce1456 patch 8.0.1757: unnecessary changes in libvterm
Christian Brabandt <cb@256bit.org>
parents: 13531
diff changeset
449 case 49: // Default background
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 state->pen.bg = state->default_bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 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
452 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
454 case 73: // Superscript
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
455 case 74: // Subscript
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
456 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
457 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
458 state->pen.baseline =
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
459 (arg == 73) ? VTERM_BASELINE_RAISE :
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
460 (arg == 74) ? VTERM_BASELINE_LOWER :
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
461 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
462 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
463 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
464 break;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
465
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 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
467 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
468 value = CSI_ARG(args[argi]) - 90 + 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 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
470 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472 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
473 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
474 value = CSI_ARG(args[argi]) - 100 + 8;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 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
476 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 default:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 done = 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 break;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
483 if(!done)
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 {
19091
1c75e1974313 patch 8.2.0106: printf formats are not exactly right
Bram Moolenaar <Bram@vim.org>
parents: 17777
diff changeset
485 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
486 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487
20518
a4652d7ec99f patch 8.2.0813: libvterm code is slightly different from upstream
Bram Moolenaar <Bram@vim.org>
parents: 20500
diff changeset
488 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
489 ;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
493 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
494 {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
495 /* 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
496 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
497 (!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
498 return argi;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
499 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
501 /* 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
502 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
503 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
504 if (idx < 8) {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
505 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
506 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
507 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
508 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
509 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
510 else {
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
511 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
512 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
513 args[argi++] = idx;
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
514 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
515 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
516 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
517 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
518 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
519 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
520 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
521 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
522 }
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
523 return argi;
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
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 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
527 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 int argi = 0;
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 if(state->pen.bold)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 args[argi++] = 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 if(state->pen.italic)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 args[argi++] = 3;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
536 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
537 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
538 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
539 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
540
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
541 if(state->pen.blink)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 args[argi++] = 5;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 if(state->pen.reverse)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 args[argi++] = 7;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
547 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
548 args[argi++] = 8;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
549
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 if(state->pen.strike)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 args[argi++] = 9;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 if(state->pen.font)
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 args[argi++] = 10 + state->pen.font;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555
20462
9ad473b50471 patch 8.2.0785: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 19091
diff changeset
556 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
557 args[argi++] = 21;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558
20500
03826c672315 patch 8.2.0804: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20496
diff changeset
559 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
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.bg, argi, args, FALSE);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562
30894
bf4f25d50fdd patch 9.0.0781: workaround to rename "small" to "smallfont" is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 30884
diff changeset
563 if(state->pen.small) {
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
564 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
565 args[argi++] = 73;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
566 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
567 args[argi++] = 74;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
568 }
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
569
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 return argi;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 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
574 {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 switch(attr) {
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 case VTERM_ATTR_BOLD:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 val->boolean = state->pen.bold;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 case VTERM_ATTR_UNDERLINE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 val->number = state->pen.underline;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 case VTERM_ATTR_ITALIC:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 val->boolean = state->pen.italic;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 case VTERM_ATTR_BLINK:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589 val->boolean = state->pen.blink;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 case VTERM_ATTR_REVERSE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 val->boolean = state->pen.reverse;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595
20496
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
596 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
597 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
598 return 1;
747a270eb1db patch 8.2.0802: libvterm code lags behind the upstream version
Bram Moolenaar <Bram@vim.org>
parents: 20462
diff changeset
599
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 case VTERM_ATTR_STRIKE:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 val->boolean = state->pen.strike;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 case VTERM_ATTR_FONT:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605 val->number = state->pen.font;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 case VTERM_ATTR_FOREGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 val->color = state->pen.fg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 return 1;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 case VTERM_ATTR_BACKGROUND:
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613 val->color = state->pen.bg;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 return 1;
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
615
30880
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
616 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
617 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
618 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
619
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
620 case VTERM_ATTR_BASELINE:
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
621 val->number = state->pen.baseline;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
622 return 1;
82336c3b679d patch 9.0.0774: the libvterm code is outdated
Bram Moolenaar <Bram@vim.org>
parents: 21085
diff changeset
623
13531
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
624 case VTERM_N_ATTRS:
9f857e6310b6 patch 8.0.1639: libvterm code lags behind master
Christian Brabandt <cb@256bit.org>
parents: 12973
diff changeset
625 return 0;
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 }
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 return 0;
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 }