JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Adding scrollwheel support. Thanks Brandon Invergo!
[st.git] / st.c
diff --git a/st.c b/st.c
index bfbe799..2ad13ef 100644 (file)
--- a/st.c
+++ b/st.c
@@ -673,6 +673,10 @@ bpress(XEvent *e) {
                sel.mode = 1;
                sel.ex = sel.bx = x2col(e->xbutton.x);
                sel.ey = sel.by = y2row(e->xbutton.y);
+       } else if(e->xbutton.button == Button4) {
+               ttywrite("\031", 1);
+       } else if(e->xbutton.button == Button5) {
+               ttywrite("\005", 1);
        }
 }
 
@@ -1834,8 +1838,8 @@ tputc(char *c, int len) {
                }
        }
        /*
-        * STR sequences must be checked before of anything
-        * because it can use some control codes as part of the sequence
+        * STR sequences must be checked before anything else
+        * because it can use some control codes as part of the sequence.
         */
        if(term.esc & ESC_STR) {
                switch(ascii) {
@@ -1855,6 +1859,7 @@ tputc(char *c, int len) {
                }
                return;
        }
+
        /*
         * Actions of control codes must be performed as soon they arrive
         * because they can be embedded inside a control sequence, and
@@ -1895,11 +1900,11 @@ tputc(char *c, int len) {
                case '\030':    /* CAN */
                        csireset();
                        return;
-                case '\005':   /* ENQ (IGNORED) */
-                case '\000':   /* NUL (IGNORED) */
-                case '\021':   /* XON (IGNORED) */
-                case '\023':   /* XOFF (IGNORED) */
-                case 0177:     /* DEL (IGNORED) */
+               case '\005':    /* ENQ (IGNORED) */
+               case '\000':    /* NUL (IGNORED) */
+               case '\021':    /* XON (IGNORED) */
+               case '\023':    /* XOFF (IGNORED) */
+               case 0177:      /* DEL (IGNORED) */
                        return;
                }
        } else if(term.esc & ESC_START) {
@@ -2398,9 +2403,6 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
                 *temp, revfg, revbg;
        XRenderColor colfg, colbg;
 
-       if(base.mode & ATTR_REVERSE)
-               temp = fg, fg = bg, bg = temp;
-
        if(base.mode & ATTR_BOLD) {
                if(BETWEEN(base.fg, 0, 7)) {
                        /* basic system colors */
@@ -2450,6 +2452,9 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
                }
        }
 
+       if(base.mode & ATTR_REVERSE)
+               temp = fg, fg = bg, bg = temp;
+
        XftTextExtentsUtf8(xw.dpy, font->xft_set, (FcChar8 *)s, bytelen,
                        &extents);
        width = extents.xOff;
@@ -2694,6 +2699,9 @@ kpress(XEvent *ev) {
                                selpaste();
                        break;
                case XK_Return:
+                       if(meta)
+                               ttywrite("\033", 1);
+
                        if(IS_SET(MODE_CRLF)) {
                                ttywrite("\r\n", 2);
                        } else {
@@ -2742,8 +2750,6 @@ cresize(int width, int height)
 
        col = (xw.w - 2*borderpx) / xw.cw;
        row = (xw.h - 2*borderpx) / xw.ch;
-       if(col == term.col && row == term.row)
-               return;
 
        tresize(col, row);
        xresize(col, row);