applied vimbrowse patch
[st.git] / x.c
diff --git a/x.c b/x.c
index a358386..09ee612 100644 (file)
--- 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)) {