X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=x.c;h=b278a3454fd216c37ab0adf943f28cbd710c6218;hb=079f9a8bb75664a40bba9af2c84d876a4290090c;hp=a3583869e3cc052819082ec6c3c4b41ae70c18c5;hpb=7d59dd715c0b5b219dbb8ac050f2fc07b604e30b;p=st.git diff --git a/x.c b/x.c index a358386..b278a34 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) @@ -1622,6 +1628,8 @@ xsettitle(char *p) int xstartdraw(void) { + if (IS_SET(MODE_VISIBLE)) + XCopyArea(xw.dpy, xw.win, xw.buf, dc.gc, 0, 0, win.w, win.h, 0, 0); return IS_SET(MODE_VISIBLE); } @@ -1636,6 +1644,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 +1839,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)) {