aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Price <komidore64@gmail.com>2023-02-07 19:54:29 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2023-02-07 19:57:34 +0100
commitf17abd25b376c292f783062ecf821453eaa9cc4c (patch)
tree8a501a78f8091bd26d956596fb37557139857a02
parent7e8050cc621f27002eaf1be8114dee2497beff91 (diff)
downloadst-patched-f17abd25b376c292f783062ecf821453eaa9cc4c.tar.bz2
st-patched-f17abd25b376c292f783062ecf821453eaa9cc4c.tar.xz
st-patched-f17abd25b376c292f783062ecf821453eaa9cc4c.zip
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 **<tab> <select a file> st.c Select a file with <enter>, and notice that fzf clobbers some or all of your prompt. After applying this patch, do the same test as above and notice that fzf has no longer clobbered your prompt by placing the file name in the correct position in your command. my-fancy-prompt $ vim **<tab> <select a file> 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,
-rw-r--r--st.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/st.c b/st.c
index 34c27ad..49357cc 100644
--- a/st.c
+++ b/st.c
@@ -1769,11 +1769,18 @@ csihandle(void)
1769 case 'm': /* SGR -- Terminal attribute (color) */ 1769 case 'm': /* SGR -- Terminal attribute (color) */
1770 tsetattr(csiescseq.arg, csiescseq.narg); 1770 tsetattr(csiescseq.arg, csiescseq.narg);
1771 break; 1771 break;
1772 case 'n': /* DSR – Device Status Report (cursor position) */ 1772 case 'n': /* DSR -- Device Status Report */
1773 if (csiescseq.arg[0] == 6) { 1773 switch (csiescseq.arg[0]) {
1774 case 5: /* Status Report "OK" `0n` */
1775 ttywrite("\033[0n", sizeof("\033[0n") - 1, 0);
1776 break;
1777 case 6: /* Report Cursor Position (CPR) "<row>;<column>R" */
1774 len = snprintf(buf, sizeof(buf), "\033[%i;%iR", 1778 len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
1775 term.c.y+1, term.c.x+1); 1779 term.c.y+1, term.c.x+1);
1776 ttywrite(buf, len, 0); 1780 ttywrite(buf, len, 0);
1781 break;
1782 default:
1783 goto unknown;
1777 } 1784 }
1778 break; 1785 break;
1779 case 'r': /* DECSTBM -- Set Scrolling Region */ 1786 case 'r': /* DECSTBM -- Set Scrolling Region */