diff options
| author | Christoph Lohmann <20h@r-36.net> | 2012-12-10 20:45:46 +0100 |
|---|---|---|
| committer | Christoph Lohmann <20h@r-36.net> | 2012-12-10 20:45:46 +0100 |
| commit | 78215c8ee0f4cb62655730260520f185ce97c620 (patch) | |
| tree | a38b22d846f4aab16ad10ef2d75005cb5844e238 | |
| parent | fe3fb82d29bd4c3b2194aa7b66733de4c8cd2161 (diff) | |
| download | st-78215c8ee0f4cb62655730260520f185ce97c620.tar.gz st-78215c8ee0f4cb62655730260520f185ce97c620.zip | |
Fixing the nasty selection bug. Thanks p37sitdu@lavabit.com!
| -rw-r--r-- | st.c | 31 |
1 files changed, 17 insertions, 14 deletions
| @@ -73,7 +73,7 @@ | |||
| 73 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) | 73 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) |
| 74 | #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) | 74 | #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) |
| 75 | #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg) | 75 | #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || (a).bg != (b).bg) |
| 76 | #define IS_SET(flag) (term.mode & (flag)) | 76 | #define IS_SET(flag) ((term.mode & (flag)) != 0) |
| 77 | #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000) | 77 | #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + (t1.tv_usec-t2.tv_usec)/1000) |
| 78 | 78 | ||
| 79 | #define VT102ID "\033[?6c" | 79 | #define VT102ID "\033[?6c" |
| @@ -624,6 +624,8 @@ selected(int x, int y) { | |||
| 624 | 624 | ||
| 625 | void | 625 | void |
| 626 | getbuttoninfo(XEvent *e) { | 626 | getbuttoninfo(XEvent *e) { |
| 627 | sel.alt = IS_SET(MODE_ALTSCREEN); | ||
| 628 | |||
| 627 | sel.ex = x2col(e->xbutton.x); | 629 | sel.ex = x2col(e->xbutton.x); |
| 628 | sel.ey = y2row(e->xbutton.y); | 630 | sel.ey = y2row(e->xbutton.y); |
| 629 | 631 | ||
| @@ -722,7 +724,6 @@ selcopy(void) { | |||
| 722 | } | 724 | } |
| 723 | *ptr = 0; | 725 | *ptr = 0; |
| 724 | } | 726 | } |
| 725 | sel.alt = IS_SET(MODE_ALTSCREEN); | ||
| 726 | xsetsel(str); | 727 | xsetsel(str); |
| 727 | } | 728 | } |
| 728 | 729 | ||
| @@ -869,16 +870,17 @@ bmotion(XEvent *e) { | |||
| 869 | return; | 870 | return; |
| 870 | } | 871 | } |
| 871 | 872 | ||
| 872 | if(sel.mode) { | 873 | if(!sel.mode) |
| 873 | oldey = sel.ey; | 874 | return; |
| 874 | oldex = sel.ex; | ||
| 875 | getbuttoninfo(e); | ||
| 876 | 875 | ||
| 877 | if(oldey != sel.ey || oldex != sel.ex) { | 876 | oldey = sel.ey; |
| 878 | starty = MIN(oldey, sel.ey); | 877 | oldex = sel.ex; |
| 879 | endy = MAX(oldey, sel.ey); | 878 | getbuttoninfo(e); |
| 880 | tsetdirt(starty, endy); | 879 | |
| 881 | } | 880 | if(oldey != sel.ey || oldex != sel.ex) { |
| 881 | starty = MIN(oldey, sel.ey); | ||
| 882 | endy = MAX(oldey, sel.ey); | ||
| 883 | tsetdirt(starty, endy); | ||
| 882 | } | 884 | } |
| 883 | } | 885 | } |
| 884 | 886 | ||
| @@ -1510,7 +1512,7 @@ tsetmode(bool priv, bool set, int *args, int narg) { | |||
| 1510 | case 1049: /* = 1047 and 1048 */ | 1512 | case 1049: /* = 1047 and 1048 */ |
| 1511 | case 47: | 1513 | case 47: |
| 1512 | case 1047: { | 1514 | case 1047: { |
| 1513 | alt = IS_SET(MODE_ALTSCREEN) != 0; | 1515 | alt = IS_SET(MODE_ALTSCREEN); |
| 1514 | if(alt) | 1516 | if(alt) |
| 1515 | tclearregion(0, 0, term.col-1, term.row-1); | 1517 | tclearregion(0, 0, term.col-1, term.row-1); |
| 1516 | if(set ^ alt) /* set is always 1 or 0 */ | 1518 | if(set ^ alt) /* set is always 1 or 0 */ |
| @@ -2603,10 +2605,11 @@ drawregion(int x1, int y1, int x2, int y2) { | |||
| 2603 | int ic, ib, x, y, ox, sl; | 2605 | int ic, ib, x, y, ox, sl; |
| 2604 | Glyph base, new; | 2606 | Glyph base, new; |
| 2605 | char buf[DRAW_BUF_SIZ]; | 2607 | char buf[DRAW_BUF_SIZ]; |
| 2606 | bool ena_sel = sel.bx != -1, alt = IS_SET(MODE_ALTSCREEN) != 0; | 2608 | bool ena_sel = sel.bx != -1; |
| 2607 | 2609 | ||
| 2608 | if((sel.alt != 0) ^ alt) | 2610 | if(sel.alt ^ IS_SET(MODE_ALTSCREEN)) |
| 2609 | ena_sel = 0; | 2611 | ena_sel = 0; |
| 2612 | |||
| 2610 | if(!(xw.state & WIN_VISIBLE)) | 2613 | if(!(xw.state & WIN_VISIBLE)) |
| 2611 | return; | 2614 | return; |
| 2612 | 2615 | ||
