URI: 
       st-csi_22_23-0.8.5.diff - sites - public wiki contents of suckless.org
  HTML git clone git://git.suckless.org/sites
   DIR Log
   DIR Files
   DIR Refs
       ---
       st-csi_22_23-0.8.5.diff (4585B)
       ---
            1 From c90af45228c1100377d64ad021fa3f0cff9a1df4 Mon Sep 17 00:00:00 2001
            2 From: wael <40663@protonmail.com>
            3 Date: Mon, 11 Apr 2022 21:28:43 +0300
            4 Subject: [PATCH] [st][patch][csi 22 23] update to 0.8.5
            5 
            6 ---
            7  st.c    | 36 ++++++++++++++++++++++++++++++++----
            8  st.info |  4 ++--
            9  win.h   |  4 +++-
           10  x.c     | 41 ++++++++++++++++++++++++++++++++++++++---
           11  4 files changed, 75 insertions(+), 10 deletions(-)
           12 
           13 diff --git a/st.c b/st.c
           14 index f43cfd3..2802381 100644
           15 --- a/st.c
           16 +++ b/st.c
           17 @@ -1801,6 +1801,33 @@ csihandle(void)
           18                          goto unknown;
           19                  }
           20                  break;
           21 +        case 't': /* title stack operations */
           22 +                switch (csiescseq.arg[0]) {
           23 +                case 22: /* pust current title on stack */
           24 +                        switch (csiescseq.arg[1]) {
           25 +                        case 0:
           26 +                        case 1:
           27 +                        case 2:
           28 +                                xpushtitle();
           29 +                                break;
           30 +                        default:
           31 +                                goto unknown;
           32 +                        }
           33 +                        break;
           34 +                case 23: /* pop last title from stack */
           35 +                        switch (csiescseq.arg[1]) {
           36 +                        case 0:
           37 +                        case 1:
           38 +                        case 2:
           39 +                                xsettitle(NULL, 1);
           40 +                                break;
           41 +                        default:
           42 +                                goto unknown;
           43 +                        }
           44 +                        break;
           45 +                default:
           46 +                        goto unknown;
           47 +                }
           48          }
           49  }
           50  
           51 @@ -1885,7 +1912,7 @@ strhandle(void)
           52                  switch (par) {
           53                  case 0:
           54                          if (narg > 1) {
           55 -                                xsettitle(strescseq.args[1]);
           56 +                                xsettitle(strescseq.args[1], 0);
           57                                  xseticontitle(strescseq.args[1]);
           58                          }
           59                          return;
           60 @@ -1895,7 +1922,7 @@ strhandle(void)
           61                          return;
           62                  case 2:
           63                          if (narg > 1)
           64 -                                xsettitle(strescseq.args[1]);
           65 +                                xsettitle(strescseq.args[1], 0);
           66                          return;
           67                  case 52:
           68                          if (narg > 2 && allowwindowops) {
           69 @@ -1973,7 +2000,7 @@ strhandle(void)
           70                  }
           71                  break;
           72          case 'k': /* old title set compatibility */
           73 -                xsettitle(strescseq.args[0]);
           74 +                xsettitle(strescseq.args[0], 0);
           75                  return;
           76          case 'P': /* DCS -- Device Control String */
           77          case '_': /* APC -- Application Program Command */
           78 @@ -2345,6 +2372,7 @@ eschandle(uchar ascii)
           79                  break;
           80          case 'c': /* RIS -- Reset to initial state */
           81                  treset();
           82 +                xfreetitlestack();
           83                  resettitle();
           84                  xloadcols();
           85                  break;
           86 @@ -2631,7 +2659,7 @@ tresize(int col, int row)
           87  void
           88  resettitle(void)
           89  {
           90 -        xsettitle(NULL);
           91 +        xsettitle(NULL, 0);
           92  }
           93  
           94  void
           95 diff --git a/st.info b/st.info
           96 index 8201ad6..aeef606 100644
           97 --- a/st.info
           98 +++ b/st.info
           99 @@ -161,7 +161,7 @@ st-mono| simpleterm monocolor,
          100          rin=\E[%p1%dT,
          101          ritm=\E[23m,
          102          rmacs=\E(B,
          103 -        rmcup=\E[?1049l,
          104 +        rmcup=\E[?1049l\E[23;0;0t,
          105          rmir=\E[4l,
          106          rmkx=\E[?1l\E>,
          107          rmso=\E[27m,
          108 @@ -172,7 +172,7 @@ st-mono| simpleterm monocolor,
          109          sitm=\E[3m,
          110          sgr0=\E[0m,
          111          smacs=\E(0,
          112 -        smcup=\E[?1049h,
          113 +        smcup=\E[?1049h\E[22;0;0t,
          114          smir=\E[4h,
          115          smkx=\E[?1h\E=,
          116          smso=\E[7m,
          117 diff --git a/win.h b/win.h
          118 index e6e4369..ef67fd6 100644
          119 --- a/win.h
          120 +++ b/win.h
          121 @@ -31,7 +31,9 @@ void xfinishdraw(void);
          122  void xloadcols(void);
          123  int xsetcolorname(int, const char *);
          124  void xseticontitle(char *);
          125 -void xsettitle(char *);
          126 +void xfreetitlestack(void);
          127 +void xsettitle(char *, int);
          128 +void xpushtitle(void);
          129  int xsetcursor(int);
          130  void xsetmode(int, unsigned int);
          131  void xsetpointermotion(int);
          132 diff --git a/x.c b/x.c
          133 index 2a3bd38..babb04c 100644
          134 --- a/x.c
          135 +++ b/x.c
          136 @@ -63,6 +63,9 @@ static void ttysend(const Arg *);
          137  /* config.h for applying patches and the configuration. */
          138  #include "config.h"
          139  
          140 +/* size of title stack */
          141 +#define TITLESTACKSIZE 8
          142 +
          143  /* XEMBED messages */
          144  #define XEMBED_FOCUS_IN  4
          145  #define XEMBED_FOCUS_OUT 5
          146 @@ -220,6 +223,8 @@ static DC dc;
          147  static XWindow xw;
          148  static XSelection xsel;
          149  static TermWindow win;
          150 +static int tstki; /* title stack index */
          151 +static char *titlestack[TITLESTACKSIZE]; /* title stack */
          152  
          153  /* Font Ring Cache */
          154  enum {
          155 @@ -1626,10 +1631,30 @@ xseticontitle(char *p)
          156  }
          157  
          158  void
          159 -xsettitle(char *p)
          160 +xfreetitlestack(void)
          161  {
          162 -        XTextProperty prop;
          163 -        DEFAULT(p, opt_title);
          164 +        for (int i = 0; i < LEN(titlestack); i++) {
          165 +                free(titlestack[i]);
          166 +                titlestack[i] = NULL;
          167 +        }
          168 +}
          169 +
          170 +void
          171 +xsettitle(char *p, int pop)
          172 +{
          173 +         XTextProperty prop;
          174 + 
          175 +        free(titlestack[tstki]);
          176 +        if (pop) {
          177 +                titlestack[tstki] = NULL;
          178 +                tstki = (tstki - 1 + TITLESTACKSIZE) % TITLESTACKSIZE;
          179 +                p = titlestack[tstki] ? titlestack[tstki] : opt_title;
          180 +        } else if (p) {
          181 +                titlestack[tstki] = xstrdup(p);
          182 +        } else {
          183 +                titlestack[tstki] = NULL;
          184 +                p = opt_title;
          185 +        }
          186  
          187          if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
          188                                          &prop) != Success)
          189 @@ -1639,6 +1664,16 @@ xsettitle(char *p)
          190          XFree(prop.value);
          191  }
          192  
          193 +void
          194 +xpushtitle(void)
          195 +{
          196 +        int tstkin = (tstki + 1) % TITLESTACKSIZE;
          197 +
          198 +        free(titlestack[tstkin]);
          199 +        titlestack[tstkin] = titlestack[tstki] ? xstrdup(titlestack[tstki]) : NULL;
          200 +        tstki = tstkin;
          201 +}
          202 +
          203  int
          204  xstartdraw(void)
          205  {
          206 -- 
          207 2.35.1
          208