diff options
| -rw-r--r-- | TODO | 1 | ||||
| -rw-r--r-- | st.c | 78 |
2 files changed, 31 insertions, 48 deletions
| @@ -19,7 +19,6 @@ bugs | |||
| 19 | ---- | 19 | ---- |
| 20 | 20 | ||
| 21 | * fix shift up/down (shift selection in emacs) | 21 | * fix shift up/down (shift selection in emacs) |
| 22 | * fix -e handling | ||
| 23 | * remove DEC test sequence when appropriate | 22 | * remove DEC test sequence when appropriate |
| 24 | 23 | ||
| 25 | misc | 24 | misc |
| @@ -1,4 +1,4 @@ | |||
| 1 | /* See LICENSE for licence details. */ | 1 | /* See LICENSE for license details. */ |
| 2 | #include <ctype.h> | 2 | #include <ctype.h> |
| 3 | #include <errno.h> | 3 | #include <errno.h> |
| 4 | #include <fcntl.h> | 4 | #include <fcntl.h> |
| @@ -944,7 +944,7 @@ getsel(void) { | |||
| 944 | ptr = str = xmalloc(bufsize); | 944 | ptr = str = xmalloc(bufsize); |
| 945 | 945 | ||
| 946 | /* append every set & selected glyph to the selection */ | 946 | /* append every set & selected glyph to the selection */ |
| 947 | for(y = sel.nb.y; y < sel.ne.y + 1; y++) { | 947 | for(y = sel.nb.y; y <= sel.ne.y; y++) { |
| 948 | linelen = tlinelen(y); | 948 | linelen = tlinelen(y); |
| 949 | 949 | ||
| 950 | if(sel.type == SEL_RECTANGULAR) { | 950 | if(sel.type == SEL_RECTANGULAR) { |
| @@ -1576,11 +1576,9 @@ tmoveto(int x, int y) { | |||
| 1576 | miny = 0; | 1576 | miny = 0; |
| 1577 | maxy = term.row - 1; | 1577 | maxy = term.row - 1; |
| 1578 | } | 1578 | } |
| 1579 | LIMIT(x, 0, term.col-1); | ||
| 1580 | LIMIT(y, miny, maxy); | ||
| 1581 | term.c.state &= ~CURSOR_WRAPNEXT; | 1579 | term.c.state &= ~CURSOR_WRAPNEXT; |
| 1582 | term.c.x = x; | 1580 | term.c.x = LIMIT(x, 0, term.col-1); |
| 1583 | term.c.y = y; | 1581 | term.c.y = LIMIT(y, miny, maxy); |
| 1584 | } | 1582 | } |
| 1585 | 1583 | ||
| 1586 | void | 1584 | void |
| @@ -2451,21 +2449,19 @@ tdectest(char c) { | |||
| 2451 | 2449 | ||
| 2452 | void | 2450 | void |
| 2453 | tstrsequence(uchar c) { | 2451 | tstrsequence(uchar c) { |
| 2454 | if (c & 0x80) { | 2452 | switch (c) { |
| 2455 | switch (c) { | 2453 | case 0x90: /* DCS -- Device Control String */ |
| 2456 | case 0x90: /* DCS -- Device Control String */ | 2454 | c = 'P'; |
| 2457 | c = 'P'; | 2455 | break; |
| 2458 | break; | 2456 | case 0x9f: /* APC -- Application Program Command */ |
| 2459 | case 0x9f: /* APC -- Application Program Command */ | 2457 | c = '_'; |
| 2460 | c = '_'; | 2458 | break; |
| 2461 | break; | 2459 | case 0x9e: /* PM -- Privacy Message */ |
| 2462 | case 0x9e: /* PM -- Privacy Message */ | 2460 | c = '^'; |
| 2463 | c = '^'; | 2461 | break; |
| 2464 | break; | 2462 | case 0x9d: /* OSC -- Operating System Command */ |
| 2465 | case 0x9d: /* OSC -- Operating System Command */ | 2463 | c = ']'; |
| 2466 | c = ']'; | 2464 | break; |
| 2467 | break; | ||
| 2468 | } | ||
| 2469 | } | 2465 | } |
| 2470 | strreset(); | 2466 | strreset(); |
| 2471 | strescseq.type = c; | 2467 | strescseq.type = c; |
| @@ -2774,7 +2770,6 @@ tresize(int col, int row) { | |||
| 2774 | int i; | 2770 | int i; |
| 2775 | int minrow = MIN(row, term.row); | 2771 | int minrow = MIN(row, term.row); |
| 2776 | int mincol = MIN(col, term.col); | 2772 | int mincol = MIN(col, term.col); |
| 2777 | int slide = term.c.y - row + 1; | ||
| 2778 | bool *bp; | 2773 | bool *bp; |
| 2779 | TCursor c; | 2774 | TCursor c; |
| 2780 | 2775 | ||
| @@ -2784,21 +2779,17 @@ tresize(int col, int row) { | |||
| 2784 | return; | 2779 | return; |
| 2785 | } | 2780 | } |
| 2786 | 2781 | ||
| 2787 | /* free unneeded rows */ | 2782 | /* |
| 2788 | i = 0; | 2783 | * slide screen to keep cursor where we expect it - |
| 2789 | if(slide > 0) { | 2784 | * tscrollup would work here, but we can optimize to |
| 2790 | /* | 2785 | * memmove because we're freeing the earlier lines |
| 2791 | * slide screen to keep cursor where we expect it - | 2786 | */ |
| 2792 | * tscrollup would work here, but we can optimize to | 2787 | for(i = 0; i <= term.c.y - row; i++) { |
| 2793 | * memmove because we're freeing the earlier lines | 2788 | free(term.line[i]); |
| 2794 | */ | 2789 | free(term.alt[i]); |
| 2795 | for(/* i = 0 */; i < slide; i++) { | ||
| 2796 | free(term.line[i]); | ||
| 2797 | free(term.alt[i]); | ||
| 2798 | } | ||
| 2799 | memmove(term.line, term.line + slide, row * sizeof(Line)); | ||
| 2800 | memmove(term.alt, term.alt + slide, row * sizeof(Line)); | ||
| 2801 | } | 2790 | } |
| 2791 | memmove(term.line, term.line + i, row * sizeof(Line)); | ||
| 2792 | memmove(term.alt, term.alt + i, row * sizeof(Line)); | ||
| 2802 | for(i += row; i < term.row; i++) { | 2793 | for(i += row; i < term.row; i++) { |
| 2803 | free(term.line[i]); | 2794 | free(term.line[i]); |
| 2804 | free(term.alt[i]); | 2795 | free(term.alt[i]); |
| @@ -3922,17 +3913,13 @@ run(void) { | |||
| 3922 | long deltatime; | 3913 | long deltatime; |
| 3923 | 3914 | ||
| 3924 | /* Waiting for window mapping */ | 3915 | /* Waiting for window mapping */ |
| 3925 | while(1) { | 3916 | do { |
| 3926 | XNextEvent(xw.dpy, &ev); | 3917 | XNextEvent(xw.dpy, &ev); |
| 3927 | if(XFilterEvent(&ev, None)) | ||
| 3928 | continue; | ||
| 3929 | if(ev.type == ConfigureNotify) { | 3918 | if(ev.type == ConfigureNotify) { |
| 3930 | w = ev.xconfigure.width; | 3919 | w = ev.xconfigure.width; |
| 3931 | h = ev.xconfigure.height; | 3920 | h = ev.xconfigure.height; |
| 3932 | } else if(ev.type == MapNotify) { | ||
| 3933 | break; | ||
| 3934 | } | 3921 | } |
| 3935 | } | 3922 | } while(ev.type != MapNotify); |
| 3936 | 3923 | ||
| 3937 | ttynew(); | 3924 | ttynew(); |
| 3938 | cresize(w, h); | 3925 | cresize(w, h); |
| @@ -4026,7 +4013,6 @@ usage(void) { | |||
| 4026 | 4013 | ||
| 4027 | int | 4014 | int |
| 4028 | main(int argc, char *argv[]) { | 4015 | main(int argc, char *argv[]) { |
| 4029 | char *titles; | ||
| 4030 | uint cols = 80, rows = 24; | 4016 | uint cols = 80, rows = 24; |
| 4031 | 4017 | ||
| 4032 | xw.l = xw.t = 0; | 4018 | xw.l = xw.t = 0; |
| @@ -4044,10 +4030,8 @@ main(int argc, char *argv[]) { | |||
| 4044 | /* eat all remaining arguments */ | 4030 | /* eat all remaining arguments */ |
| 4045 | if(argc > 1) { | 4031 | if(argc > 1) { |
| 4046 | opt_cmd = &argv[1]; | 4032 | opt_cmd = &argv[1]; |
| 4047 | if(argv[1] != NULL && opt_title == NULL) { | 4033 | if(argv[1] != NULL && opt_title == NULL) |
| 4048 | titles = xstrdup(argv[1]); | 4034 | opt_title = basename(xstrdup(argv[1])); |
| 4049 | opt_title = basename(titles); | ||
| 4050 | } | ||
| 4051 | } | 4035 | } |
| 4052 | goto run; | 4036 | goto run; |
| 4053 | case 'f': | 4037 | case 'f': |
