JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Drawing a more visible rectangle as cursor on unfocus.
[st.git] / st.c
diff --git a/st.c b/st.c
index 49a9770..c4eafa0 100644 (file)
--- a/st.c
+++ b/st.c
@@ -758,7 +758,7 @@ bpress(XEvent *e) {
 void
 selcopy(void) {
        char *str, *ptr, *p;
-       int x, y, bufsize, is_selected = 0, size;
+       int x, y, bufsize, isselected = 0, size;
        Glyph *gp, *last;
 
        if(sel.bx == -1) {
@@ -769,7 +769,7 @@ selcopy(void) {
 
                /* append every set & selected glyph to the selection */
                for(y = sel.b.y; y < sel.e.y + 1; y++) {
-                       is_selected = 0;
+                       isselected = 0;
                        gp = &term.line[y][0];
                        last = gp + term.col;
 
@@ -780,7 +780,7 @@ selcopy(void) {
                                if(!selected(x, y)) {
                                        continue;
                                } else {
-                                       is_selected = 1;
+                                       isselected = 1;
                                }
 
                                p = (gp->state & GLYPH_SET) ? gp->c : " ";
@@ -798,7 +798,7 @@ selcopy(void) {
                         * st.
                         * FIXME: Fix the computer world.
                         */
-                       if(is_selected && y < sel.e.y)
+                       if(isselected && y < sel.e.y)
                                *ptr++ = '\n';
                }
                *ptr = 0;
@@ -835,10 +835,6 @@ selnotify(XEvent *e) {
                        *repl++ = '\r';
                }
 
-               last = data + nitems * format / 8;
-               repl = data;
-
-
                ttywrite((const char *)data, nitems * format / 8);
                XFree(data);
                /* number of 32-bit chunks returned */
@@ -2972,14 +2968,33 @@ xdrawcursor(void) {
 
        /* draw the new one */
        if(!(IS_SET(MODE_HIDE))) {
-               if(!(xw.state & WIN_FOCUSED))
-                       g.bg = defaultucs;
-
-               if(IS_SET(MODE_REVERSE))
-                       g.mode |= ATTR_REVERSE, g.fg = defaultcs, g.bg = defaultfg;
+               if(xw.state & WIN_FOCUSED) {
+                       if(IS_SET(MODE_REVERSE)) {
+                               g.mode |= ATTR_REVERSE;
+                               g.fg = defaultcs;
+                               g.bg = defaultfg;
+                       }
 
-               sl = utf8size(g.c);
-               xdraws(g.c, g, term.c.x, term.c.y, 1, sl);
+                       sl = utf8size(g.c);
+                       xdraws(g.c, g, term.c.x, term.c.y, 1, sl);
+               } else {
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + term.c.y * xw.ch,
+                                       xw.cw - 1, 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + term.c.y * xw.ch,
+                                       1, xw.ch - 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + (term.c.x + 1) * xw.cw - 1,
+                                       borderpx + term.c.y * xw.ch,
+                                       1, xw.ch - 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + (term.c.y + 1) * xw.ch - 1,
+                                       xw.cw, 1);
+               }
                oldx = term.c.x, oldy = term.c.y;
        }
 }