diff --git a/README.md b/README.md index b5e7f8d..2b0b17c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: -2021-05-08 - Added blinking cursor, undercurl, desktopentry and netwmicon patches +2021-05-08 - Added blinking cursor, undercurl, desktopentry, netwmicon and osc_10_11_12_2 patches 2021-05-07 - Added xresources reload patch @@ -154,6 +154,14 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [open-copied-url](https://st.suckless.org/patches/open_copied_url/) - open contents of the clipboard in a user-defined browser + - [osc_10_11_12_2](https://st.suckless.org/patches/osc_10_11_12_2/) + - this patch adds support for OSC escape sequences 10, 11, and 12 in the way they are + implemented in most other terminals (e.g libvte, kitty) + - specifically it differs from [osc_10_11_12](https://st.suckless.org/patches/osc_10_11_12/) + in that it treats the background and foreground colors as distinct from palette colours 01 + and 07 in order to facilitate the use of theme setting scripts like + [theme.sh](https://github.com/lemnos/theme.sh) which expect these colours to be distinct + - [relativeborder](https://st.suckless.org/patches/relativeborder/) - allows you to specify a border that is relative in size to the width of a cell in the terminal diff --git a/patches.def.h b/patches.def.h index 4e6e12d..c63d36a 100644 --- a/patches.def.h +++ b/patches.def.h @@ -186,6 +186,16 @@ */ #define OPENCOPIED_PATCH 0 +/* This patch adds support for OSC escape sequences 10, 11 and 12 that modify the background, + * foreground and cursor colors in the way they are implemented in most other terminals + * (e.g libvte, kitty). Specifically it differs from https://st.suckless.org/patches/osc_10_11_12/ + * in that it treats the background and foreground colors as distinct from palette colours + * 01 and 07 in order to facilitate the use of theme setting scripts like theme.sh + * (https://github.com/lemnos/theme.sh) which expect these colours to be distinct. + * https://st.suckless.org/patches/osc_10_11_12_2/ + */ +#define OSC_10_11_12_2_PATCH 0 + /* This patch allows you to specify a border that is relative in size to the width of a cell * in the terminal. * https://st.suckless.org/patches/relativeborder/ diff --git a/st.c b/st.c index 6c0f774..1caa949 100644 --- a/st.c +++ b/st.c @@ -2140,10 +2140,43 @@ strhandle(void) } } return; - case 4: /* color set */ case 10: /* foreground set */ + #if OSC_10_11_12_2_PATCH + if (narg < 2) + break; + + p = strescseq.args[1]; + if (xsetcolorname(defaultfg, p)) + fprintf(stderr, "erresc: invalid foreground color %d\n", p); + else + redraw(); + break; + #endif // OSC_10_11_12_2_PATCH case 11: /* background set */ + #if OSC_10_11_12_2_PATCH + if (narg < 2) + break; + + p = strescseq.args[1]; + if (xsetcolorname(defaultbg, p)) + fprintf(stderr, "erresc: invalid background color %d\n", p); + else + redraw(); + break; + #endif // OSC_10_11_12_2_PATCH case 12: /* cursor color */ + #if OSC_10_11_12_2_PATCH + if (narg < 2) + break; + + p = strescseq.args[1]; + if (xsetcolorname(defaultcs, p)) + fprintf(stderr, "erresc: invalid cursor color %d\n", p); + else + redraw(); + break; + #endif // OSC_10_11_12_2_PATCH + case 4: /* color set */ if ((par == 4 && narg < 3) || narg < 2) break; p = strescseq.args[((par == 4) ? 2 : 1)];