From 18e7dc554530dcbe6dcb9b3d1fb98a31bd8933d8 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Fri, 7 Apr 2023 14:28:19 +0200 Subject: [PATCH] Bump to f17abd2. Add support for DSR response "OK" escape sequence "VT100 defines an escape sequence [1] called Device Status Report (DSR). When the DSR sequence received is `csi 5n`, an "OK" response `csi 0n` is returned. This patch adds that "OK" response. I encountered this missing sequence when I noticed that fzf [2] would clobber my prompt whenever completing a find. To test that ST doesn't currently respond to `csi 5n`, use fzf's shell extension in ST's repo to complete the path for a file. my-fancy-prompt $ vim ** my-fancy prompt $ vim st.c Thank you for considering my first patch submission. [1] https://www.xfree86.org/current/ctlseqs.html#VT100%20Mode [2] https://github.com/junegunn/fzf " Patch slightly adapted with input from the mailinglist, Ref. https://git.suckless.org/st/commit/f17abd25b376c292f783062ecf821453eaa9cc4c.html --- st.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/st.c b/st.c index b45dae4..09ce926 100644 --- a/st.c +++ b/st.c @@ -2363,11 +2363,18 @@ csihandle(void) case 'm': /* SGR -- Terminal attribute (color) */ tsetattr(csiescseq.arg, csiescseq.narg); break; - case 'n': /* DSR – Device Status Report (cursor position) */ - if (csiescseq.arg[0] == 6) { + case 'n': /* DSR -- Device Status Report */ + switch (csiescseq.arg[0]) { + case 5: /* Status Report "OK" `0n` */ + ttywrite("\033[0n", sizeof("\033[0n") - 1, 0); + break; + case 6: /* Report Cursor Position (CPR) ";R" */ len = snprintf(buffer, sizeof(buffer), "\033[%i;%iR", - term.c.y+1, term.c.x+1); + term.c.y+1, term.c.x+1); ttywrite(buffer, len, 0); + break; + default: + goto unknown; } break; case 'r': /* DECSTBM -- Set Scrolling Region */