st-osc_10_11_12-20200418-66520e1.diff (2032B)
1 From 66520e1c3b0a6f30ce1cde033a1aec04e5a0f1a2 Mon Sep 17 00:00:00 2001 2 From: Christian Tenllado <ctenllado@gmail.com> 3 Date: Sat, 18 Apr 2020 09:26:46 +0200 4 Subject: [PATCH] OSC 10/11/12 fg, bg and cursor colors 5 6 Support for OSC escape sequences 10, 11 and 12 to modify the bg, fg and 7 cursor colors. I selected entries in the colorname table after the 255 8 position for defaultfg, defaultbg and defaultcs 9 --- 10 config.def.h | 4 ++-- 11 st.c | 17 ++++++++++++++--- 12 st.h | 1 + 13 3 files changed, 17 insertions(+), 5 deletions(-) 14 15 diff --git a/config.def.h b/config.def.h 16 index 546edda..7d20fdf 100644 17 --- a/config.def.h 18 +++ b/config.def.h 19 @@ -118,8 +118,8 @@ static const char *colorname[] = { 20 */ 21 unsigned int defaultfg = 7; 22 unsigned int defaultbg = 0; 23 -static unsigned int defaultcs = 256; 24 -static unsigned int defaultrcs = 257; 25 +unsigned int defaultcs = 256; 26 +unsigned int defaultrcs = 257; 27 28 /* 29 * Default shape of cursor 30 diff --git a/st.c b/st.c 31 index 3e48410..ec7970c 100644 32 --- a/st.c 33 +++ b/st.c 34 @@ -1862,12 +1862,23 @@ strhandle(void) 35 } 36 return; 37 case 4: /* color set */ 38 - if (narg < 3) 39 + case 10: /* foreground set */ 40 + case 11: /* background set */ 41 + case 12: /* cursor color */ 42 + if ((par == 4 && narg < 3) || narg < 2) 43 break; 44 - p = strescseq.args[2]; 45 + p = strescseq.args[((par == 4) ? 2 : 1)]; 46 /* FALLTHROUGH */ 47 case 104: /* color reset, here p = NULL */ 48 - j = (narg > 1) ? atoi(strescseq.args[1]) : -1; 49 + if (par == 10) 50 + j = defaultfg; 51 + else if (par == 11) 52 + j = defaultbg; 53 + else if (par == 12) 54 + j = defaultcs; 55 + else 56 + j = (narg > 1) ? atoi(strescseq.args[1]) : -1; 57 + 58 if (xsetcolorname(j, p)) { 59 if (par == 104 && narg <= 1) 60 return; /* color reset without parameter */ 61 diff --git a/st.h b/st.h 62 index a1928ca..bd79875 100644 63 --- a/st.h 64 +++ b/st.h 65 @@ -121,3 +121,4 @@ extern char *termname; 66 extern unsigned int tabspaces; 67 extern unsigned int defaultfg; 68 extern unsigned int defaultbg; 69 +extern unsigned int defaultcs; 70 -- 71 2.20.1 72