… | |
… | |
132 | |
132 | |
133 | l.l = 0; |
133 | l.l = 0; |
134 | l.f = 0; |
134 | l.f = 0; |
135 | } |
135 | } |
136 | |
136 | |
|
|
137 | // nuke a single wide character at the given column |
|
|
138 | void |
|
|
139 | rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW |
|
|
140 | { |
|
|
141 | // find begin |
|
|
142 | while (col > 0 && l.t[col] == NOCHAR) |
|
|
143 | col--; |
|
|
144 | |
|
|
145 | rend_t rend = l.r[col] & ~RS_baseattrMask; |
|
|
146 | rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); |
|
|
147 | |
|
|
148 | // found start, nuke |
|
|
149 | do { |
|
|
150 | l.t[col] = ' '; |
|
|
151 | l.r[col] = rend; |
|
|
152 | col++; |
|
|
153 | } while (col < ncol && l.t[col] == NOCHAR); |
|
|
154 | } |
|
|
155 | |
137 | /* ------------------------------------------------------------------------- * |
156 | /* ------------------------------------------------------------------------- * |
138 | * SCREEN INITIALISATION * |
157 | * SCREEN INITIALISATION * |
139 | * ------------------------------------------------------------------------- */ |
158 | * ------------------------------------------------------------------------- */ |
140 | |
159 | |
141 | void |
160 | void |
… | |
… | |
880 | if (expect_false ( |
899 | if (expect_false ( |
881 | line->t[screen.cur.col] == NOCHAR |
900 | line->t[screen.cur.col] == NOCHAR |
882 | || (screen.cur.col < ncol - 1 |
901 | || (screen.cur.col < ncol - 1 |
883 | && line->t[screen.cur.col + 1] == NOCHAR) |
902 | && line->t[screen.cur.col + 1] == NOCHAR) |
884 | )) |
903 | )) |
885 | { |
904 | scr_kill_char (*line, screen.cur.col); |
886 | int col = screen.cur.col; |
|
|
887 | |
|
|
888 | // find begin |
|
|
889 | while (col > 0 && line->t[col] == NOCHAR) |
|
|
890 | col--; |
|
|
891 | |
|
|
892 | rend_t rend = SET_FONT (line->r[col], FONTSET (line->r[col])->find_font (' ')); |
|
|
893 | |
|
|
894 | // found begin, nuke |
|
|
895 | do { |
|
|
896 | line->t[col] = ' '; |
|
|
897 | line->r[col] = rend; |
|
|
898 | col++; |
|
|
899 | } while (col < ncol && line->t[col] == NOCHAR); |
|
|
900 | } |
|
|
901 | |
905 | |
902 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
906 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
903 | |
907 | |
904 | // if the character doesn't fit into the remaining columns... |
908 | // if the character doesn't fit into the remaining columns... |
905 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
909 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
906 | { |
910 | { |
907 | // ...output spaces |
911 | // ... artificially enlargen the previous one |
908 | c = ' '; |
912 | c = NOCHAR; |
909 | // and try the same character next loop iteration |
913 | // and try the same character next loop iteration |
910 | --str; |
914 | --str; |
911 | } |
915 | } |
912 | |
916 | |
913 | line->touch (); |
917 | line->touch (); |
… | |
… | |
1442 | * Insert/Delete <count> characters from the current position |
1446 | * Insert/Delete <count> characters from the current position |
1443 | */ |
1447 | */ |
1444 | void |
1448 | void |
1445 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1449 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1446 | { |
1450 | { |
1447 | int col, row; |
|
|
1448 | rend_t tr; |
|
|
1449 | |
|
|
1450 | want_refresh = 1; |
1451 | want_refresh = 1; |
1451 | ZERO_SCROLLBACK (); |
1452 | ZERO_SCROLLBACK (); |
1452 | |
1453 | |
1453 | if (count <= 0) |
1454 | if (count <= 0) |
1454 | return; |
1455 | return; |
… | |
… | |
1456 | scr_do_wrap (); |
1457 | scr_do_wrap (); |
1457 | |
1458 | |
1458 | selection_check (1); |
1459 | selection_check (1); |
1459 | min_it (count, ncol - screen.cur.col); |
1460 | min_it (count, ncol - screen.cur.col); |
1460 | |
1461 | |
1461 | row = screen.cur.row; |
1462 | int row = screen.cur.row; |
1462 | |
1463 | |
1463 | line_t *line = &ROW(row); |
1464 | line_t *line = &ROW(row); |
1464 | |
1465 | |
1465 | line->touch (); |
1466 | line->touch (); |
1466 | line->is_longer (0); |
1467 | line->is_longer (0); |
1467 | |
1468 | |
|
|
1469 | // nuke wide spanning the start |
|
|
1470 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1471 | scr_kill_char (*line, screen.cur.col); |
|
|
1472 | |
1468 | switch (insdel) |
1473 | switch (insdel) |
1469 | { |
1474 | { |
1470 | case INSERT: |
1475 | case INSERT: |
1471 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1476 | line->l = min (line->l + count, ncol); |
|
|
1477 | |
|
|
1478 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1479 | scr_kill_char (*line, screen.cur.col); |
|
|
1480 | |
|
|
1481 | for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1472 | { |
1482 | { |
1473 | line->t[col] = line->t[col - count]; |
1483 | line->t[col] = line->t[col - count]; |
1474 | line->r[col] = line->r[col - count]; |
1484 | line->r[col] = line->r[col - count]; |
1475 | } |
1485 | } |
1476 | |
|
|
1477 | line->l = min (line->l + count, ncol); |
|
|
1478 | |
1486 | |
1479 | if (selection.op && current_screen == selection.screen |
1487 | if (selection.op && current_screen == selection.screen |
1480 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1488 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1481 | { |
1489 | { |
1482 | if (selection.end.row != screen.cur.row |
1490 | if (selection.end.row != screen.cur.row |
… | |
… | |
1497 | case ERASE: |
1505 | case ERASE: |
1498 | screen.cur.col += count; /* don't worry if > ncol */ |
1506 | screen.cur.col += count; /* don't worry if > ncol */ |
1499 | selection_check (1); |
1507 | selection_check (1); |
1500 | screen.cur.col -= count; |
1508 | screen.cur.col -= count; |
1501 | |
1509 | |
1502 | line->l = max (line->l - count, 0); |
1510 | // nuke wide char after the end |
|
|
1511 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1512 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1513 | |
1503 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1514 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1504 | break; |
1515 | break; |
1505 | |
1516 | |
1506 | case DELETE: |
1517 | case DELETE: |
1507 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1518 | line->l = max (line->l - count, 0); |
1508 | |
1519 | |
|
|
1520 | // nuke wide char spanning the end |
|
|
1521 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1522 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1523 | |
1509 | for (col = screen.cur.col; (col + count) < ncol; col++) |
1524 | for (int col = screen.cur.col; (col + count) < ncol; col++) |
1510 | { |
1525 | { |
1511 | line->t[col] = line->t[col + count]; |
1526 | line->t[col] = line->t[col + count]; |
1512 | line->r[col] = line->r[col + count]; |
1527 | line->r[col] = line->r[col + count]; |
1513 | } |
1528 | } |
1514 | |
1529 | |
1515 | line->l = max (line->l - count, 0); |
|
|
1516 | scr_blank_line (*line, ncol - count, count, tr); |
1530 | scr_blank_line (*line, ncol - count, count, |
|
|
1531 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
1517 | |
1532 | |
1518 | if (selection.op && current_screen == selection.screen |
1533 | if (selection.op && current_screen == selection.screen |
1519 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1534 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1520 | { |
1535 | { |
1521 | if (selection.end.row != screen.cur.row |
1536 | if (selection.end.row != screen.cur.row |
… | |
… | |
1899 | XMapWindow (dpy, parent[0]); |
1914 | XMapWindow (dpy, parent[0]); |
1900 | # endif |
1915 | # endif |
1901 | |
1916 | |
1902 | # if ENABLE_FRILLS |
1917 | # if ENABLE_FRILLS |
1903 | if (option (Opt_urgentOnBell)) |
1918 | if (option (Opt_urgentOnBell)) |
1904 | { |
1919 | set_urgency (1); |
1905 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1906 | { |
|
|
1907 | h->flags |= XUrgencyHint; |
|
|
1908 | XSetWMHints (dpy, parent[0], h); |
|
|
1909 | } |
|
|
1910 | } |
|
|
1911 | # endif |
1920 | # endif |
1912 | |
1921 | |
1913 | if (option (Opt_visualBell)) |
1922 | if (option (Opt_visualBell)) |
1914 | { |
1923 | { |
1915 | rvideo_bell = true; |
1924 | rvideo_bell = true; |
… | |
… | |
2210 | continue; |
2219 | continue; |
2211 | |
2220 | |
2212 | // redraw one or more characters |
2221 | // redraw one or more characters |
2213 | |
2222 | |
2214 | // seek to the beginning of wide characters |
2223 | // seek to the beginning of wide characters |
2215 | while (stp[col] == NOCHAR && col > 0) |
2224 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2216 | --col; |
2225 | --col; |
2217 | |
2226 | |
2218 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2227 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2219 | text_t *text = stp + col; |
2228 | text_t *text = stp + col; |
2220 | int count = 1; |
2229 | int count = 1; |
… | |
… | |
2257 | |
2266 | |
2258 | col--; /* went one too far. move back */ |
2267 | col--; /* went one too far. move back */ |
2259 | count -= i; /* dump any matching trailing chars */ |
2268 | count -= i; /* dump any matching trailing chars */ |
2260 | |
2269 | |
2261 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2270 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2262 | while (i && text[count] == NOCHAR) |
2271 | while (expect_false (i && text[count] == NOCHAR)) |
2263 | count++, i--; |
2272 | count++, i--; |
2264 | |
2273 | |
2265 | /* |
2274 | /* |
2266 | * Determine the attributes for the string |
2275 | * Determine the attributes for the string |
2267 | */ |
2276 | */ |
2268 | int fore = fgcolor_of (rend); // desired foreground |
2277 | int fore = fgcolor_of (rend); // desired foreground |
2269 | int back = bgcolor_of (rend); // desired background |
2278 | int back = bgcolor_of (rend); // desired background |
2270 | |
2279 | |
2271 | // only do special processing if any attributes are set, which is unlikely |
2280 | // only do special processing if any attributes are set, which is unlikely |
2272 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2281 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2273 | { |
2282 | { |
2274 | bool invert = rend & RS_RVid; |
2283 | bool invert = rend & RS_RVid; |
2275 | |
2284 | |
2276 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2285 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2277 | if (rend & RS_Bold && fore == Color_fg) |
2286 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2360 | /* |
2369 | /* |
2361 | * Actually do the drawing of the string here |
2370 | * Actually do the drawing of the string here |
2362 | */ |
2371 | */ |
2363 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2372 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2364 | |
2373 | |
2365 | if (have_bg && back == Color_bg) |
2374 | if (expect_true (have_bg && back == Color_bg)) |
2366 | { |
2375 | { |
2367 | // this is very ugly, maybe push it into ->draw? |
2376 | // this is very ugly, maybe push it into ->draw? |
2368 | |
2377 | |
2369 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2378 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2370 | if (text[i] != ' ') |
2379 | if (text[i] != ' ') |
… | |
… | |
2377 | did_clear: ; |
2386 | did_clear: ; |
2378 | } |
2387 | } |
2379 | else |
2388 | else |
2380 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2389 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2381 | |
2390 | |
2382 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2391 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2383 | { |
2392 | { |
2384 | #if ENABLE_FRILLS |
2393 | #if ENABLE_FRILLS |
2385 | if (ISSET_PIXCOLOR (Color_underline)) |
2394 | if (ISSET_PIXCOLOR (Color_underline)) |
2386 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2395 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2387 | else |
2396 | else |