… | |
… | |
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 |
142 | rxvt_term::scr_reset () |
161 | rxvt_term::scr_reset () |
143 | { |
162 | { |
144 | #if ENABLE_OVERLAY |
|
|
145 | scr_overlay_off (); |
|
|
146 | #endif |
|
|
147 | |
|
|
148 | rvideo_mode = false; |
|
|
149 | view_start = 0; |
163 | view_start = 0; |
150 | num_scr = 0; |
164 | num_scr = 0; |
151 | |
165 | |
152 | if (ncol == 0) |
166 | if (ncol == 0) |
153 | ncol = 80; |
167 | ncol = 80; |
… | |
… | |
155 | if (nrow == 0) |
169 | if (nrow == 0) |
156 | nrow = 24; |
170 | nrow = 24; |
157 | |
171 | |
158 | if (ncol == prev_ncol && nrow == prev_nrow) |
172 | if (ncol == prev_ncol && nrow == prev_nrow) |
159 | return; |
173 | return; |
160 | |
|
|
161 | if (current_screen != PRIMARY) |
|
|
162 | scr_swap_screen (); |
|
|
163 | |
174 | |
164 | // we need at least two lines for wrapping to work correctly |
175 | // we need at least two lines for wrapping to work correctly |
165 | while (nrow + saveLines < 2) |
176 | while (nrow + saveLines < 2) |
166 | { |
177 | { |
167 | //TODO//FIXME |
178 | //TODO//FIXME |
… | |
… | |
380 | delete old_ta; |
391 | delete old_ta; |
381 | delete old_ra; |
392 | delete old_ra; |
382 | |
393 | |
383 | clamp_it (screen.cur.row, 0, nrow - 1); |
394 | clamp_it (screen.cur.row, 0, nrow - 1); |
384 | clamp_it (screen.cur.col, 0, ncol - 1); |
395 | clamp_it (screen.cur.col, 0, ncol - 1); |
385 | |
|
|
386 | free (tabs); |
|
|
387 | } |
396 | } |
388 | |
397 | |
389 | CLEAR_ALL_SELECTION (); |
398 | CLEAR_ALL_SELECTION (); |
390 | |
399 | |
391 | prev_nrow = nrow; |
400 | prev_nrow = nrow; |
392 | prev_ncol = ncol; |
401 | prev_ncol = ncol; |
393 | |
|
|
394 | tabs = (char *)rxvt_malloc (ncol); |
|
|
395 | |
|
|
396 | for (int col = ncol; --col; ) |
|
|
397 | tabs [col] = col % TABSIZE == 0; |
|
|
398 | |
|
|
399 | if (current_screen != PRIMARY) |
|
|
400 | scr_swap_screen (); |
|
|
401 | |
402 | |
402 | tt_winch (); |
403 | tt_winch (); |
403 | |
404 | |
404 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
405 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
405 | } |
406 | } |
… | |
… | |
417 | delete ralloc; ralloc = 0; |
418 | delete ralloc; ralloc = 0; |
418 | |
419 | |
419 | free (row_buf); |
420 | free (row_buf); |
420 | free (swap_buf); |
421 | free (swap_buf); |
421 | free (drawn_buf); |
422 | free (drawn_buf); |
|
|
423 | row_buf = 0; // signal that we freed all the arrays above |
|
|
424 | |
422 | free (tabs); |
425 | free (tabs); |
423 | |
426 | tabs = 0; |
424 | row_buf = 0; // signal that we freed all the arrays |
|
|
425 | } |
427 | } |
426 | } |
428 | } |
427 | |
429 | |
428 | /* ------------------------------------------------------------------------- */ |
430 | /* ------------------------------------------------------------------------- */ |
429 | /* |
431 | /* |
430 | * Hard reset |
432 | * Hard/Soft reset |
431 | */ |
433 | */ |
432 | void |
434 | void |
433 | rxvt_term::scr_poweron () |
435 | rxvt_term::scr_poweron () |
434 | { |
436 | { |
435 | scr_release (); |
437 | scr_release (); |
436 | prev_nrow = prev_ncol = 0; |
438 | prev_nrow = prev_ncol = 0; |
|
|
439 | scr_soft_reset (); |
437 | scr_reset (); |
440 | scr_reset (); |
438 | |
441 | |
439 | scr_clear (true); |
442 | scr_clear (true); |
440 | scr_refresh (); |
443 | scr_refresh (); |
|
|
444 | } |
|
|
445 | |
|
|
446 | void |
|
|
447 | rxvt_term::scr_soft_reset () |
|
|
448 | { |
|
|
449 | /* only affects modes, nothing drastic such as clearing the screen */ |
|
|
450 | #if ENABLE_OVERLAY |
|
|
451 | scr_overlay_off (); |
|
|
452 | #endif |
|
|
453 | |
|
|
454 | rvideo_mode = false; |
|
|
455 | |
|
|
456 | if (current_screen != PRIMARY) |
|
|
457 | scr_swap_screen (); |
|
|
458 | |
|
|
459 | free (tabs); |
|
|
460 | tabs = (char *)rxvt_malloc (ncol); |
|
|
461 | |
|
|
462 | for (int col = ncol; --col; ) |
|
|
463 | tabs [col] = col % TABSIZE == 0; |
|
|
464 | |
|
|
465 | if (current_screen != PRIMARY) |
|
|
466 | scr_swap_screen (); |
|
|
467 | |
|
|
468 | scr_scroll_region (0, MAX_ROWS - 1); |
|
|
469 | scr_rendition (0, ~RS_None); |
|
|
470 | scr_insert_mode (0); |
441 | } |
471 | } |
442 | |
472 | |
443 | /* ------------------------------------------------------------------------- * |
473 | /* ------------------------------------------------------------------------- * |
444 | * PROCESS SCREEN COMMANDS * |
474 | * PROCESS SCREEN COMMANDS * |
445 | * ------------------------------------------------------------------------- */ |
475 | * ------------------------------------------------------------------------- */ |
… | |
… | |
880 | if (expect_false ( |
910 | if (expect_false ( |
881 | line->t[screen.cur.col] == NOCHAR |
911 | line->t[screen.cur.col] == NOCHAR |
882 | || (screen.cur.col < ncol - 1 |
912 | || (screen.cur.col < ncol - 1 |
883 | && line->t[screen.cur.col + 1] == NOCHAR) |
913 | && line->t[screen.cur.col + 1] == NOCHAR) |
884 | )) |
914 | )) |
885 | { |
915 | 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 | |
916 | |
902 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
917 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
903 | |
918 | |
904 | // if the character doesn't fit into the remaining columns... |
919 | // if the character doesn't fit into the remaining columns... |
905 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
920 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
906 | { |
921 | { |
907 | // ...output spaces |
922 | // ... artificially enlargen the previous one |
908 | c = ' '; |
923 | c = NOCHAR; |
909 | // and try the same character next loop iteration |
924 | // and try the same character next loop iteration |
910 | --str; |
925 | --str; |
911 | } |
926 | } |
912 | |
927 | |
913 | line->touch (); |
928 | line->touch (); |
… | |
… | |
1442 | * Insert/Delete <count> characters from the current position |
1457 | * Insert/Delete <count> characters from the current position |
1443 | */ |
1458 | */ |
1444 | void |
1459 | void |
1445 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1460 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1446 | { |
1461 | { |
1447 | int col, row; |
|
|
1448 | rend_t tr; |
|
|
1449 | |
|
|
1450 | want_refresh = 1; |
1462 | want_refresh = 1; |
1451 | ZERO_SCROLLBACK (); |
1463 | ZERO_SCROLLBACK (); |
1452 | |
1464 | |
1453 | if (count <= 0) |
1465 | if (count <= 0) |
1454 | return; |
1466 | return; |
… | |
… | |
1456 | scr_do_wrap (); |
1468 | scr_do_wrap (); |
1457 | |
1469 | |
1458 | selection_check (1); |
1470 | selection_check (1); |
1459 | min_it (count, ncol - screen.cur.col); |
1471 | min_it (count, ncol - screen.cur.col); |
1460 | |
1472 | |
1461 | row = screen.cur.row; |
1473 | int row = screen.cur.row; |
1462 | |
1474 | |
1463 | line_t *line = &ROW(row); |
1475 | line_t *line = &ROW(row); |
1464 | |
1476 | |
1465 | line->touch (); |
1477 | line->touch (); |
1466 | line->is_longer (0); |
1478 | line->is_longer (0); |
1467 | |
1479 | |
|
|
1480 | // nuke wide spanning the start |
|
|
1481 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1482 | scr_kill_char (*line, screen.cur.col); |
|
|
1483 | |
1468 | switch (insdel) |
1484 | switch (insdel) |
1469 | { |
1485 | { |
1470 | case INSERT: |
1486 | case INSERT: |
1471 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1487 | line->l = min (line->l + count, ncol); |
|
|
1488 | |
|
|
1489 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1490 | scr_kill_char (*line, screen.cur.col); |
|
|
1491 | |
|
|
1492 | for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1472 | { |
1493 | { |
1473 | line->t[col] = line->t[col - count]; |
1494 | line->t[col] = line->t[col - count]; |
1474 | line->r[col] = line->r[col - count]; |
1495 | line->r[col] = line->r[col - count]; |
1475 | } |
1496 | } |
1476 | |
|
|
1477 | line->l = min (line->l + count, ncol); |
|
|
1478 | |
1497 | |
1479 | if (selection.op && current_screen == selection.screen |
1498 | if (selection.op && current_screen == selection.screen |
1480 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1499 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1481 | { |
1500 | { |
1482 | if (selection.end.row != screen.cur.row |
1501 | if (selection.end.row != screen.cur.row |
… | |
… | |
1497 | case ERASE: |
1516 | case ERASE: |
1498 | screen.cur.col += count; /* don't worry if > ncol */ |
1517 | screen.cur.col += count; /* don't worry if > ncol */ |
1499 | selection_check (1); |
1518 | selection_check (1); |
1500 | screen.cur.col -= count; |
1519 | screen.cur.col -= count; |
1501 | |
1520 | |
1502 | line->l = max (line->l - count, 0); |
1521 | // nuke wide char after the end |
|
|
1522 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1523 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1524 | |
1503 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1525 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1504 | break; |
1526 | break; |
1505 | |
1527 | |
1506 | case DELETE: |
1528 | case DELETE: |
1507 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1529 | line->l = max (line->l - count, 0); |
1508 | |
1530 | |
|
|
1531 | // nuke wide char spanning the end |
|
|
1532 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1533 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1534 | |
1509 | for (col = screen.cur.col; (col + count) < ncol; col++) |
1535 | for (int col = screen.cur.col; (col + count) < ncol; col++) |
1510 | { |
1536 | { |
1511 | line->t[col] = line->t[col + count]; |
1537 | line->t[col] = line->t[col + count]; |
1512 | line->r[col] = line->r[col + count]; |
1538 | line->r[col] = line->r[col + count]; |
1513 | } |
1539 | } |
1514 | |
1540 | |
1515 | line->l = max (line->l - count, 0); |
|
|
1516 | scr_blank_line (*line, ncol - count, count, tr); |
1541 | scr_blank_line (*line, ncol - count, count, |
|
|
1542 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
1517 | |
1543 | |
1518 | if (selection.op && current_screen == selection.screen |
1544 | if (selection.op && current_screen == selection.screen |
1519 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1545 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1520 | { |
1546 | { |
1521 | if (selection.end.row != screen.cur.row |
1547 | if (selection.end.row != screen.cur.row |
… | |
… | |
1899 | XMapWindow (dpy, parent[0]); |
1925 | XMapWindow (dpy, parent[0]); |
1900 | # endif |
1926 | # endif |
1901 | |
1927 | |
1902 | # if ENABLE_FRILLS |
1928 | # if ENABLE_FRILLS |
1903 | if (option (Opt_urgentOnBell)) |
1929 | if (option (Opt_urgentOnBell)) |
1904 | { |
1930 | 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 |
1931 | # endif |
1912 | |
1932 | |
1913 | if (option (Opt_visualBell)) |
1933 | if (option (Opt_visualBell)) |
1914 | { |
1934 | { |
1915 | rvideo_bell = true; |
1935 | rvideo_bell = true; |