apply patch st-meta-vim-full-20210425-43a395a-8.4.patch

This commit is contained in:
2026-01-22 06:23:33 +01:00
parent 6e97047474
commit 6d00916036
9 changed files with 559 additions and 179 deletions

51
x.c
View File

@@ -19,6 +19,7 @@ char *argv0;
#include "arg.h"
#include "st.h"
#include "win.h"
#include "normalMode.h"
/* types used in config.h */
typedef struct {
@@ -261,6 +262,7 @@ clipcopy(const Arg *dummy)
free(xsel.clipboard);
xsel.clipboard = NULL;
xsetsel(getsel());
if (xsel.primary != NULL) {
xsel.clipboard = xstrdup(xsel.primary);
@@ -470,7 +472,6 @@ bpress(XEvent *e)
{
int btn = e->xbutton.button;
struct timespec now;
int snap;
if (1 <= btn && btn <= 11)
buttons |= 1 << (btn-1);
@@ -489,17 +490,34 @@ bpress(XEvent *e)
* snapping behaviour is exposed.
*/
clock_gettime(CLOCK_MONOTONIC, &now);
if (TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout) {
snap = SNAP_LINE;
} else if (TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout) {
snap = SNAP_WORD;
int const tripleClick = TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout,
doubleClick = TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout;
if ((mouseYank || mouseSelect) && (tripleClick || doubleClick)) {
if (!IS_SET(MODE_NORMAL)) normalMode();
historyOpToggle(1, 1);
tmoveto(evcol(e), evrow(e));
if (tripleClick) {
if (mouseYank) pressKeys("dVy", 3);
if (mouseSelect) pressKeys("dV", 2);
} else if (doubleClick) {
if (mouseYank) pressKeys("dyiW", 4);
if (mouseSelect) {
tmoveto(evcol(e), evrow(e));
pressKeys("viW", 3);
}
}
historyOpToggle(-1, 1);
} else {
snap = 0;
if (!IS_SET(MODE_NORMAL)) selstart(evcol(e), evrow(e), 0);
else {
historyOpToggle(1, 1);
tmoveto(evcol(e), evrow(e));
pressKeys("v", 1);
historyOpToggle(-1, 1);
}
}
xsel.tclick2 = xsel.tclick1;
xsel.tclick1 = now;
selstart(evcol(e), evrow(e), snap);
}
}
@@ -709,8 +727,7 @@ brelease(XEvent *e)
if (mouseaction(e, 1))
return;
if (btn == Button1)
mousesel(e, 1);
if (btn == Button1 && !IS_SET(MODE_NORMAL)) mousesel(e, 1);
}
void
@@ -790,6 +807,8 @@ xloadcolor(int i, const char *name, Color *ncolor)
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
}
void normalMode() { historyModeToggle((win.mode ^=MODE_NORMAL) & MODE_NORMAL); }
void
xloadcols(void)
{
@@ -1260,8 +1279,10 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
/* Fetch rune and mode for current glyph. */
rune = glyphs[i].u;
mode = glyphs[i].mode;
Glyph g = glyphs[i];
historyOverlay(x+i, y, &g);
rune = g.u;
mode = g.mode;
/* Skip dummy wide-character spacing. */
if (mode == ATTR_WDUMMY)
@@ -1665,6 +1686,7 @@ xdrawline(Line line, int x1, int y1, int x2)
i = ox = 0;
for (x = x1; x < x2 && i < numspecs; x++) {
new = line[x];
historyOverlay(x, y1, &new);
if (new.mode == ATTR_WDUMMY)
continue;
if (selected(x, y1))
@@ -1859,6 +1881,11 @@ kpress(XEvent *ev)
} else {
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
}
if (IS_SET(MODE_NORMAL)) {
if (kPressHist(buf, len, match(ControlMask, e->state), &ksym)
== finish) normalMode();
return;
}
/* 1. shortcuts */
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
if (ksym == bp->keysym && match(bp->mod, e->state)) {