X-Git-Url: https://git.danieliu.xyz/?p=st.git;a=blobdiff_plain;f=x.c;fp=x.c;h=09ee61248d62a54d8170ae952d58346913aedc03;hp=a3583869e3cc052819082ec6c3c4b41ae70c18c5;hb=30967a2a66c125cd68ad2c44df11218ccad1105d;hpb=7d59dd715c0b5b219dbb8ac050f2fc07b604e30b diff --git a/x.c b/x.c index a358386..09ee612 100644 --- a/x.c +++ b/x.c @@ -20,6 +20,7 @@ char *argv0; #include "arg.h" #include "st.h" #include "win.h" +#include "normalMode.h" /* types used in config.h */ typedef struct { @@ -276,6 +277,7 @@ clipcopy(const Arg *dummy) free(xsel.clipboard); xsel.clipboard = NULL; + xsetsel(getsel()); if (xsel.primary != NULL) { xsel.clipboard = xstrdup(xsel.primary); @@ -787,6 +789,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) { @@ -1238,8 +1242,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) @@ -1636,6 +1642,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)) @@ -1830,6 +1837,11 @@ kpress(XEvent *ev) len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); else len = XLookupString(e, buf, sizeof buf, &ksym, NULL); + if (IS_SET(MODE_NORMAL)) { + if (kpressHist(buf, len, match(ControlMask, e->state), &ksym) + == finished) normalMode(); + return; + } /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) {