commit a7672e2fbd353fbe1423e503a736d65cbc853c81
Author: Ashish Kumar Yadav <[email protected]>
Date:   Wed Aug 4 18:31:38 2021 +0530

    [st][patch][title_parsing_fix] Added patch to fix title parsing

diff --git a/st.suckless.org/patches/title_parsing_fix/index.md 
b/st.suckless.org/patches/title_parsing_fix/index.md
new file mode 100644
index 00000000..b86aaf7a
--- /dev/null
+++ b/st.suckless.org/patches/title_parsing_fix/index.md
@@ -0,0 +1,18 @@
+title parsing fix
+=================
+
+Description
+-----------
+
+Window titles in st get truncated after the first ';' character. I don't know
+whether this is the expected behaviour but all terminals I have come across
+do not truncate (for instance xterm, termite and alacritty). This patch "fixes"
+that behaviour.
+
+Download
+--------
+* [st-title\_parsing\_fix-0.8.4.diff](st-title_parsing_fix-0.8.4.diff)
+
+Authors
+-------
+* Ashish Kumar Yadav - <[email protected]>
diff --git 
a/st.suckless.org/patches/title_parsing_fix/st-title_parsing_fix-0.8.4.diff 
b/st.suckless.org/patches/title_parsing_fix/st-title_parsing_fix-0.8.4.diff
new file mode 100644
index 00000000..e10ad56b
--- /dev/null
+++ b/st.suckless.org/patches/title_parsing_fix/st-title_parsing_fix-0.8.4.diff
@@ -0,0 +1,107 @@
+From 6585da1be120d86316e4a9d620e9dfdfb3755822 Mon Sep 17 00:00:00 2001
+From: Ashish Kumar Yadav <[email protected]>
+Date: Wed, 4 Aug 2021 18:21:01 +0530
+Subject: [PATCH] Fixes title parsing
+
+In st, titles get truncated after the first ';' character, this patch
+fixes that.
+---
+ st.c | 26 ++++++++++++++------------
+ 1 file changed, 14 insertions(+), 12 deletions(-)
+
+diff --git a/st.c b/st.c
+index 76b7e0d..8c68218 100644
+--- a/st.c
++++ b/st.c
+@@ -42,6 +42,8 @@
+ #define ISCONTROLC1(c)                (BETWEEN(c, 0x80, 0x9f))
+ #define ISCONTROL(c)          (ISCONTROLC0(c) || ISCONTROLC1(c))
+ #define ISDELIM(u)            (u && wcschr(worddelimiters, u))
++#define STRESCARGREST(n)      ((n) == 0 ? strescseq.buf : 
strescseq.argp[(n)-1] + 1)
++#define STRESCARGJUST(n)      (*(strescseq.argp[n]) = '+ 
+ enum term_mode {
+       MODE_WRAP        = 1 << 0,
+@@ -148,7 +150,7 @@ typedef struct {
+       char *buf;             /* allocated raw string */
+       size_t siz;            /* allocation size */
+       size_t len;            /* raw string length */
+-      char *args[STR_ARG_SIZ];
++      char *argp[STR_ARG_SIZ]; /* pointers to the end of nth argument */
+       int narg;              /* nb of args */
+ } STREscape;
+ 
+@@ -1846,21 +1848,22 @@ strhandle(void)
+       int j, narg, par;
+ 
+       term.esc &= ~(ESC_STR_END|ESC_STR);
+-      strparse();
+-      par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0;
++      strescseq.buf[strescseq.len] = '+ 
+       switch (strescseq.type) {
+       case ']': /* OSC -- Operating System Command */
++              strparse();
++              par = (narg = strescseq.narg) ? atoi(STRESCARGJUST(0)) : 0;
+               switch (par) {
+               case 0:
+               case 1:
+               case 2:
+                       if (narg > 1)
+-                              xsettitle(strescseq.args[1]);
++                              xsettitle(STRESCARGREST(1));
+                       return;
+               case 52:
+                       if (narg > 2 && allowwindowops) {
+-                              dec = base64dec(strescseq.args[2]);
++                              dec = base64dec(STRESCARGJUST(2));
+                               if (dec) {
+                                       xsetsel(dec);
+                                       xclipcopy();
+@@ -1872,10 +1875,10 @@ strhandle(void)
+               case 4: /* color set */
+                       if (narg < 3)
+                               break;
+-                      p = strescseq.args[2];
++                      p = STRESCARGJUST(2);
+                       /* FALLTHROUGH */
+               case 104: /* color reset, here p = NULL */
+-                      j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
++                      j = (narg > 1) ? atoi(STRESCARGJUST(1)) : -1;
+                       if (xsetcolorname(j, p)) {
+                               if (par == 104 && narg <= 1)
+                                       return; /* color reset without 
parameter */
+@@ -1892,7 +1895,7 @@ strhandle(void)
+               }
+               break;
+       case 'k': /* old title set compatibility */
+-              xsettitle(strescseq.args[0]);
++              xsettitle(strescseq.buf);
+               return;
+       case 'P': /* DCS -- Device Control String */
+       case '_': /* APC -- Application Program Command */
+@@ -1911,18 +1914,17 @@ strparse(void)
+       char *p = strescseq.buf;
+ 
+       strescseq.narg = 0;
+-      strescseq.buf[strescseq.len] = '+ 
+       if (*p == '+            return;
+ 
+       while (strescseq.narg < STR_ARG_SIZ) {
+-              strescseq.args[strescseq.narg++] = p;
+               while ((c = *p) != ';' && c != '+-                      ++p;
++                      p++;
++              strescseq.argp[strescseq.narg++] = p;
+               if (c == '+                     return;
+-              *p++ = '++              p++;
+       }
+ }
+ 
+-- 
+2.32.0
+


Reply via email to