diff options
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 59 |
1 files changed, 31 insertions, 28 deletions
| @@ -224,7 +224,9 @@ typedef struct { | |||
| 224 | int mode; | 224 | int mode; |
| 225 | int bx, by; | 225 | int bx, by; |
| 226 | int ex, ey; | 226 | int ex, ey; |
| 227 | struct {int x, y;} b, e; | 227 | struct { |
| 228 | int x, y; | ||
| 229 | } b, e; | ||
| 228 | char *clip; | 230 | char *clip; |
| 229 | Atom xtarget; | 231 | Atom xtarget; |
| 230 | bool alt; | 232 | bool alt; |
| @@ -587,10 +589,10 @@ selected(int x, int y) { | |||
| 587 | return BETWEEN(x, bx, ex); | 589 | return BETWEEN(x, bx, ex); |
| 588 | } | 590 | } |
| 589 | 591 | ||
| 590 | return ((sel.b.y < y&&y < sel.e.y) | 592 | return ((sel.b.y < y && y < sel.e.y) |
| 591 | || (y==sel.e.y && x<=sel.e.x)) | 593 | || (y == sel.e.y && x <= sel.e.x)) |
| 592 | || (y==sel.b.y && x>=sel.b.x | 594 | || (y == sel.b.y && x >= sel.b.x |
| 593 | && (x<=sel.e.x || sel.b.y!=sel.e.y)); | 595 | && (x <= sel.e.x || sel.b.y != sel.e.y)); |
| 594 | } | 596 | } |
| 595 | 597 | ||
| 596 | void | 598 | void |
| @@ -803,12 +805,12 @@ brelease(XEvent *e) { | |||
| 803 | /* double click to select word */ | 805 | /* double click to select word */ |
| 804 | sel.bx = sel.ex; | 806 | sel.bx = sel.ex; |
| 805 | while(sel.bx > 0 && term.line[sel.ey][sel.bx-1].state & GLYPH_SET && | 807 | while(sel.bx > 0 && term.line[sel.ey][sel.bx-1].state & GLYPH_SET && |
| 806 | term.line[sel.ey][sel.bx-1].c[0] != ' ') { | 808 | term.line[sel.ey][sel.bx-1].c[0] != ' ') { |
| 807 | sel.bx--; | 809 | sel.bx--; |
| 808 | } | 810 | } |
| 809 | sel.b.x = sel.bx; | 811 | sel.b.x = sel.bx; |
| 810 | while(sel.ex < term.col-1 && term.line[sel.ey][sel.ex+1].state & GLYPH_SET && | 812 | while(sel.ex < term.col-1 && term.line[sel.ey][sel.ex+1].state & GLYPH_SET && |
| 811 | term.line[sel.ey][sel.ex+1].c[0] != ' ') { | 813 | term.line[sel.ey][sel.ex+1].c[0] != ' ') { |
| 812 | sel.ex++; | 814 | sel.ex++; |
| 813 | } | 815 | } |
| 814 | sel.e.x = sel.ex; | 816 | sel.e.x = sel.ex; |
| @@ -1031,7 +1033,8 @@ treset(void) { | |||
| 1031 | memset(term.tabs, 0, term.col * sizeof(*term.tabs)); | 1033 | memset(term.tabs, 0, term.col * sizeof(*term.tabs)); |
| 1032 | for(i = TAB; i < term.col; i += TAB) | 1034 | for(i = TAB; i < term.col; i += TAB) |
| 1033 | term.tabs[i] = 1; | 1035 | term.tabs[i] = 1; |
| 1034 | term.top = 0, term.bot = term.row - 1; | 1036 | term.top = 0; |
| 1037 | term.bot = term.row - 1; | ||
| 1035 | term.mode = MODE_WRAP; | 1038 | term.mode = MODE_WRAP; |
| 1036 | 1039 | ||
| 1037 | tclearregion(0, 0, term.col-1, term.row-1); | 1040 | tclearregion(0, 0, term.col-1, term.row-1); |
| @@ -1040,7 +1043,8 @@ treset(void) { | |||
| 1040 | void | 1043 | void |
| 1041 | tnew(int col, int row) { | 1044 | tnew(int col, int row) { |
| 1042 | /* set screen size */ | 1045 | /* set screen size */ |
| 1043 | term.row = row, term.col = col; | 1046 | term.row = row; |
| 1047 | term.col = col; | ||
| 1044 | term.line = xmalloc(term.row * sizeof(Line)); | 1048 | term.line = xmalloc(term.row * sizeof(Line)); |
| 1045 | term.alt = xmalloc(term.row * sizeof(Line)); | 1049 | term.alt = xmalloc(term.row * sizeof(Line)); |
| 1046 | term.dirty = xmalloc(term.row * sizeof(*term.dirty)); | 1050 | term.dirty = xmalloc(term.row * sizeof(*term.dirty)); |
| @@ -1437,8 +1441,8 @@ tsetmode(bool priv, bool set, int *args, int narg) { | |||
| 1437 | if(IS_SET(MODE_ALTSCREEN)) | 1441 | if(IS_SET(MODE_ALTSCREEN)) |
| 1438 | tclearregion(0, 0, term.col-1, term.row-1); | 1442 | tclearregion(0, 0, term.col-1, term.row-1); |
| 1439 | if((set && !IS_SET(MODE_ALTSCREEN)) || | 1443 | if((set && !IS_SET(MODE_ALTSCREEN)) || |
| 1440 | (!set && IS_SET(MODE_ALTSCREEN))) { | 1444 | (!set && IS_SET(MODE_ALTSCREEN))) { |
| 1441 | tswapscreen(); | 1445 | tswapscreen(); |
| 1442 | } | 1446 | } |
| 1443 | if(*args != 1049) | 1447 | if(*args != 1049) |
| 1444 | break; | 1448 | break; |
| @@ -1909,7 +1913,6 @@ tputc(char *c, int len) { | |||
| 1909 | case 'c': /* RIS -- Reset to inital state */ | 1913 | case 'c': /* RIS -- Reset to inital state */ |
| 1910 | treset(); | 1914 | treset(); |
| 1911 | term.esc = 0; | 1915 | term.esc = 0; |
| 1912 | xclearborders(); | ||
| 1913 | xresettitle(); | 1916 | xresettitle(); |
| 1914 | break; | 1917 | break; |
| 1915 | case '=': /* DECPAM -- Application keypad */ | 1918 | case '=': /* DECPAM -- Application keypad */ |
| @@ -2091,18 +2094,6 @@ xclear(int x1, int y1, int x2, int y2) { | |||
| 2091 | } | 2094 | } |
| 2092 | 2095 | ||
| 2093 | void | 2096 | void |
| 2094 | xclearborders(void) { | ||
| 2095 | /* top and left border */ | ||
| 2096 | xclear(0, 0, BORDER, xw.h); | ||
| 2097 | xclear(0, 0, xw.w, BORDER); | ||
| 2098 | |||
| 2099 | /* lower and right border */ | ||
| 2100 | xclear(BORDER, xw.th - 1, xw.w, xw.h); | ||
| 2101 | /* Will just draw what hasn't been drawn by the previous call. */ | ||
| 2102 | xclear(xw.tw - 1, BORDER, xw.w, xw.h - xw.th - 2); | ||
| 2103 | } | ||
| 2104 | |||
| 2105 | void | ||
| 2106 | xhints(void) { | 2097 | xhints(void) { |
| 2107 | XClassHint class = {opt_class ? opt_class : TNAME, TNAME}; | 2098 | XClassHint class = {opt_class ? opt_class : TNAME, TNAME}; |
| 2108 | XWMHints wm = {.flags = InputHint, .input = 1}; | 2099 | XWMHints wm = {.flags = InputHint, .input = 1}; |
| @@ -2264,8 +2255,8 @@ xinit(void) { | |||
| 2264 | 2255 | ||
| 2265 | void | 2256 | void |
| 2266 | xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { | 2257 | xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { |
| 2267 | int winx = BORDER+x*xw.cw, winy = BORDER+y*xw.ch, | 2258 | int winx = BORDER + x * xw.cw, winy = BORDER + y * xw.ch, |
| 2268 | width = charlen*xw.cw; | 2259 | width = charlen * xw.cw; |
| 2269 | Font *font = &dc.font; | 2260 | Font *font = &dc.font; |
| 2270 | XGlyphInfo extents; | 2261 | XGlyphInfo extents; |
| 2271 | XftColor *fg = &dc.xft_col[base.fg], *bg = &dc.xft_col[base.bg], | 2262 | XftColor *fg = &dc.xft_col[base.fg], *bg = &dc.xft_col[base.bg], |
| @@ -2328,6 +2319,20 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { | |||
| 2328 | &extents); | 2319 | &extents); |
| 2329 | width = extents.xOff; | 2320 | width = extents.xOff; |
| 2330 | 2321 | ||
| 2322 | /* Intelligent cleaning up of the borders. */ | ||
| 2323 | if(x == 0) { | ||
| 2324 | xclear(0, (y == 0)? 0 : winy, BORDER, | ||
| 2325 | winy + xw.ch + (y == term.row-1)? xw.h : 0); | ||
| 2326 | } | ||
| 2327 | if(x + charlen >= term.col-1) { | ||
| 2328 | xclear(winx + width, (y == 0)? 0 : winy, xw.w, | ||
| 2329 | winy + xw.ch + (y == term.row-1)? xw.h : 0); | ||
| 2330 | } | ||
| 2331 | if(y == 0) | ||
| 2332 | xclear(winx, 0, winx + width, BORDER); | ||
| 2333 | if(y == term.row-1) | ||
| 2334 | xclear(winx, winy + xw.ch, winx + width, xw.h); | ||
| 2335 | |||
| 2331 | XftDrawRect(xw.xft_draw, bg, winx, winy, width, xw.ch); | 2336 | XftDrawRect(xw.xft_draw, bg, winx, winy, width, xw.ch); |
| 2332 | XftDrawStringUtf8(xw.xft_draw, fg, font->xft_set, winx, | 2337 | XftDrawStringUtf8(xw.xft_draw, fg, font->xft_set, winx, |
| 2333 | winy + font->ascent, (FcChar8 *)s, bytelen); | 2338 | winy + font->ascent, (FcChar8 *)s, bytelen); |
| @@ -2382,7 +2387,6 @@ void | |||
| 2382 | redraw(void) { | 2387 | redraw(void) { |
| 2383 | struct timespec tv = {0, REDRAW_TIMEOUT * 1000}; | 2388 | struct timespec tv = {0, REDRAW_TIMEOUT * 1000}; |
| 2384 | 2389 | ||
| 2385 | xclearborders(); | ||
| 2386 | tfulldirt(); | 2390 | tfulldirt(); |
| 2387 | draw(); | 2391 | draw(); |
| 2388 | XSync(xw.dpy, False); /* necessary for a good tput flash */ | 2392 | XSync(xw.dpy, False); /* necessary for a good tput flash */ |
| @@ -2598,7 +2602,6 @@ resize(XEvent *e) { | |||
| 2598 | 2602 | ||
| 2599 | tresize(col, row); | 2603 | tresize(col, row); |
| 2600 | xresize(col, row); | 2604 | xresize(col, row); |
| 2601 | xclearborders(); | ||
| 2602 | ttyresize(); | 2605 | ttyresize(); |
| 2603 | } | 2606 | } |
| 2604 | 2607 | ||
