misc st patches and other things

This commit is contained in:
randomuser 2022-06-13 14:06:36 -05:00
parent 72d0d47817
commit 3b0804dde2
5 changed files with 77 additions and 14 deletions

View File

@ -1,8 +1,6 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
/* /*
* appearance
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/ */
static char *font = "Fantasque Sans Mono:pixelsize=14:antialias=true:autohint=true"; static char *font = "Fantasque Sans Mono:pixelsize=14:antialias=true:autohint=true";
@ -190,8 +188,8 @@ static Shortcut shortcuts[] = {
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
{ MODKEY, XK_h, zoom, {.f = +1} }, { MODKEY, XK_h, zoom, {.f = +1} },
{ MODKEY, XK_l, zoom, {.f = -1} }, { MODKEY, XK_l, zoom, {.f = -1} },
{ MODKEY, XK_C, clipcopy, {.i = 0} }, { MODKEY, XK_c, clipcopy, {.i = 0} },
{ MODKEY, XK_V, clippaste, {.i = 0} }, { MODKEY, XK_v, clippaste, {.i = 0} },
{ MODKEY, XK_k, kscrollup, {.i = -1} }, { MODKEY, XK_k, kscrollup, {.i = -1} },
{ MODKEY, XK_j, kscrolldown, {.i = -1} }, { MODKEY, XK_j, kscrolldown, {.i = -1} },
}; };

36
st.c
View File

@ -1870,6 +1870,33 @@ csihandle(void)
goto unknown; goto unknown;
} }
break; break;
case 't': /* title stack operations */
switch (csiescseq.arg[0]) {
case 22: /* pust current title on stack */
switch (csiescseq.arg[1]) {
case 0:
case 1:
case 2:
xpushtitle();
break;
default:
goto unknown;
}
break;
case 23: /* pop last title from stack */
switch (csiescseq.arg[1]) {
case 0:
case 1:
case 2:
xsettitle(NULL, 1);
break;
default:
goto unknown;
}
break;
default:
goto unknown;
}
} }
} }
@ -1948,7 +1975,7 @@ strhandle(void)
switch (par) { switch (par) {
case 0: case 0:
if (narg > 1) { if (narg > 1) {
xsettitle(strescseq.args[1]); xsettitle(strescseq.args[1], 0);
xseticontitle(strescseq.args[1]); xseticontitle(strescseq.args[1]);
} }
return; return;
@ -1958,7 +1985,7 @@ strhandle(void)
return; return;
case 2: case 2:
if (narg > 1) if (narg > 1)
xsettitle(strescseq.args[1]); xsettitle(strescseq.args[1], 0);
return; return;
case 52: case 52:
if (narg > 2 && allowwindowops) { if (narg > 2 && allowwindowops) {
@ -2015,7 +2042,7 @@ strhandle(void)
} }
break; break;
case 'k': /* old title set compatibility */ case 'k': /* old title set compatibility */
xsettitle(strescseq.args[0]); xsettitle(strescseq.args[0], 0);
return; return;
case 'P': /* DCS -- Device Control String */ case 'P': /* DCS -- Device Control String */
case '_': /* APC -- Application Program Command */ case '_': /* APC -- Application Program Command */
@ -2440,6 +2467,7 @@ eschandle(uchar ascii)
break; break;
case 'c': /* RIS -- Reset to initial state */ case 'c': /* RIS -- Reset to initial state */
treset(); treset();
xfreetitlestack();
resettitle(); resettitle();
xloadcols(); xloadcols();
break; break;
@ -2734,7 +2762,7 @@ tresize(int col, int row)
void void
resettitle(void) resettitle(void)
{ {
xsettitle(NULL); xsettitle(NULL, 0);
} }
void void

View File

@ -161,7 +161,7 @@ st-mono| simpleterm monocolor,
rin=\E[%p1%dT, rin=\E[%p1%dT,
ritm=\E[23m, ritm=\E[23m,
rmacs=\E(B, rmacs=\E(B,
rmcup=\E[?1049l, rmcup=\E[?1049l\E[23;0;0t,
rmir=\E[4l, rmir=\E[4l,
rmkx=\E[?1l\E>, rmkx=\E[?1l\E>,
rmso=\E[27m, rmso=\E[27m,
@ -172,7 +172,7 @@ st-mono| simpleterm monocolor,
sitm=\E[3m, sitm=\E[3m,
sgr0=\E[0m, sgr0=\E[0m,
smacs=\E(0, smacs=\E(0,
smcup=\E[?1049h, smcup=\E[?1049h\E[22;0;0t,
smir=\E[4h, smir=\E[4h,
smkx=\E[?1h\E=, smkx=\E[?1h\E=,
smso=\E[7m, smso=\E[7m,

4
win.h
View File

@ -32,7 +32,9 @@ void xloadcols(void);
int xsetcolorname(int, const char *); int xsetcolorname(int, const char *);
int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *); int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *);
void xseticontitle(char *); void xseticontitle(char *);
void xsettitle(char *); void xfreetitlestack(void);
void xsettitle(char *, int);
void xpushtitle(void);
int xsetcursor(int); int xsetcursor(int);
void xsetmode(int, unsigned int); void xsetmode(int, unsigned int);
void xsetpointermotion(int); void xsetpointermotion(int);

41
x.c
View File

@ -63,6 +63,9 @@ static void ttysend(const Arg *);
/* config.h for applying patches and the configuration. */ /* config.h for applying patches and the configuration. */
#include "config.h" #include "config.h"
/* size of title stack */
#define TITLESTACKSIZE 8
/* XEMBED messages */ /* XEMBED messages */
#define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_IN 4
#define XEMBED_FOCUS_OUT 5 #define XEMBED_FOCUS_OUT 5
@ -220,6 +223,8 @@ static DC dc;
static XWindow xw; static XWindow xw;
static XSelection xsel; static XSelection xsel;
static TermWindow win; static TermWindow win;
static int tstki; /* title stack index */
static char *titlestack[TITLESTACKSIZE]; /* title stack */
/* Font Ring Cache */ /* Font Ring Cache */
enum { enum {
@ -1626,10 +1631,30 @@ xseticontitle(char *p)
} }
void void
xsettitle(char *p) xfreetitlestack(void)
{ {
XTextProperty prop; for (int i = 0; i < LEN(titlestack); i++) {
DEFAULT(p, opt_title); free(titlestack[i]);
titlestack[i] = NULL;
}
}
void
xsettitle(char *p, int pop)
{
XTextProperty prop;
free(titlestack[tstki]);
if (pop) {
titlestack[tstki] = NULL;
tstki = (tstki - 1 + TITLESTACKSIZE) % TITLESTACKSIZE;
p = titlestack[tstki] ? titlestack[tstki] : opt_title;
} else if (p) {
titlestack[tstki] = xstrdup(p);
} else {
titlestack[tstki] = NULL;
p = opt_title;
}
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop) != Success) &prop) != Success)
@ -1639,6 +1664,16 @@ xsettitle(char *p)
XFree(prop.value); XFree(prop.value);
} }
void
xpushtitle(void)
{
int tstkin = (tstki + 1) % TITLESTACKSIZE;
free(titlestack[tstkin]);
titlestack[tstkin] = titlestack[tstki] ? xstrdup(titlestack[tstki]) : NULL;
tstki = tstkin;
}
int int
xstartdraw(void) xstartdraw(void)
{ {