JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Making rectangular selection work again.
[st.git] / st.c
diff --git a/st.c b/st.c
index 83fdc6d..131cba8 100644 (file)
--- a/st.c
+++ b/st.c
@@ -1,5 +1,4 @@
 /* See LICENSE for licence details. */
-#define _XOPEN_SOURCE 600
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -650,13 +649,10 @@ selected(int x, int y) {
        if(sel.ey == y && sel.by == y) {
                bx = MIN(sel.bx, sel.ex);
                ex = MAX(sel.bx, sel.ex);
+
                return BETWEEN(x, bx, ex);
        }
 
-       return ((sel.b.y < y && y < sel.e.y)
-                       || (y == sel.e.y && x <= sel.e.x))
-                       || (y == sel.b.y && x >= sel.b.x
-                               && (x <= sel.e.x || sel.b.y != sel.e.y));
        switch(sel.type) {
        case SEL_REGULAR:
                return ((sel.b.y < y && y < sel.e.y)
@@ -796,7 +792,7 @@ selcopy(void) {
                        }
                        /* \n at the end of every selected line except for the last one */
                        if(is_selected && y < sel.e.y)
-                               *ptr++ = '\n';
+                               *ptr++ = '\r';
                }
                *ptr = 0;
        }
@@ -1304,6 +1300,7 @@ csiparse(void) {
                p++;
        }
 
+       csiescseq.buf[csiescseq.len] = '\0';
        while(p < csiescseq.buf+csiescseq.len) {
                np = NULL;
                v = strtol(p, &np, 10);
@@ -1925,14 +1922,12 @@ strhandle(void) {
 
 void
 strparse(void) {
-       char *p = strescseq.buf, *sp;
+       char *p = strescseq.buf;
 
+       strescseq.narg = 0;
        strescseq.buf[strescseq.len] = '\0';
-       for(p = strtok_r(p, ";", &sp); p; p = strtok_r(NULL, ";", &sp)) {
-               if(strescseq.narg == STR_ARG_SIZ)
-                       return;
-               strescseq.args[strescseq.narg++] = p;
-       }
+       while(p && strescseq.narg < STR_ARG_SIZ)
+               strescseq.args[strescseq.narg++] = strsep(&p, ";");
 }
 
 void
@@ -2109,7 +2104,8 @@ tputc(char *c, int len) {
                if(term.esc & ESC_CSI) {
                        csiescseq.buf[csiescseq.len++] = ascii;
                        if(BETWEEN(ascii, 0x40, 0x7E)
-                                       || csiescseq.len >= ESC_BUF_SIZ) {
+                                       || csiescseq.len >= \
+                                       sizeof(csiescseq.buf)-1) {
                                term.esc = 0;
                                csiparse();
                                csihandle();
@@ -2494,7 +2490,7 @@ xloadfont(Font *f, FcPattern *pattern) {
        f->lbearing = 0;
        f->rbearing = f->match->max_advance_width;
 
-       f->height = f->match->height;
+       f->height = f->ascent + f->descent;
        f->width = f->lbearing + f->rbearing;
 
        return 0;