aboutsummaryrefslogtreecommitdiff
path: root/terminal.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-07-01 15:40:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-07-03 07:47:30 +0000
commitdd6fc99ae1badb7963271ed171beea8ef0e39601 (patch)
tree5d7454a19bb9d077b77d325e91733954a61f44ab /terminal.h
parentosc: merge OSC 10/11/12/17/19 handling (diff)
csi: implement XTPUSHCOLORS+XTPOPCOLORS+XTREPORTCOLORS
The documentation of these sequences are vague and lacking, as is often the case with XTerm invented control sequences. I've tried to replicate what XTerm does (as of xterm-392). The stack represents *stashed/stored* palettes. The currently active palette is *not* stored on the stack. The stack is dynamically allocated, and starts out with zero elements. Now, XTerm has a somewhat weird definition of "pushing" and "popping" in this context, and the documentation is somewhat misleading. What a push does is this: it stores the current palette to the stack at the specified slot. If the specified slot number (Pm) is 0, the slot used is the current slot index incremented by 1. The "current" slot index is then set to the specified slot (which is current slot + 1 if Pm == 0). Thus, "push" (i.e. when Pm == 0 is used) means store to the "next" slot. This is true even if the current slot index points into the middle of stack. Pop works in a similar way. The palette is restored from the specified slot index. If the specified slot number is 0, we use the current slot index. The "current" slot index is then set to the specified slot - 1 (current slot - 1 if Pm == 0). XTREPORTCOLORS return the current slot index, and the number of palettes stored on the stack, on the format CSI ? <slot index> ; <palette count> # Q When XTPUSHCOLORS grows the stack with more than one element (i.e. via a 'CSI N # P' sequence), make sure *all* new slots are initialized (to the current color palette). This avoids uninitialized slots, that could then be popped with XTPOPCOLORS. Closes #856
Diffstat (limited to 'terminal.h')
-rw-r--r--terminal.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/terminal.h b/terminal.h
index 9fce2396..4d628661 100644
--- a/terminal.h
+++ b/terminal.h
@@ -393,6 +393,19 @@ struct url {
};
typedef tll(struct url) url_list_t;
+
+struct colors {
+ uint32_t fg;
+ uint32_t bg;
+ uint32_t table[256];
+ uint16_t alpha;
+ uint32_t cursor_fg; /* Text color */
+ uint32_t cursor_bg; /* cursor color */
+ uint32_t selection_fg;
+ uint32_t selection_bg;
+ bool use_custom_selection;
+};
+
struct terminal {
struct fdm *fdm;
struct reaper *reaper;
@@ -563,17 +576,13 @@ struct terminal {
int cell_width; /* pixels per cell, x-wise */
int cell_height; /* pixels per cell, y-wise */
+ struct colors colors;
+
struct {
- uint32_t fg;
- uint32_t bg;
- uint32_t table[256];
- uint16_t alpha;
- uint32_t cursor_fg; /* Text color */
- uint32_t cursor_bg; /* cursor color */
- uint32_t selection_fg;
- uint32_t selection_bg;
- bool use_custom_selection;
- } colors;
+ struct colors *stack;
+ size_t idx;
+ size_t size;
+ } color_stack;
enum cursor_style cursor_style;
struct {