… | |
… | |
1446 | * Insert/Delete <count> characters from the current position |
1446 | * Insert/Delete <count> characters from the current position |
1447 | */ |
1447 | */ |
1448 | void |
1448 | void |
1449 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1449 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1450 | { |
1450 | { |
1451 | int col, row; |
|
|
1452 | rend_t tr; |
|
|
1453 | |
|
|
1454 | want_refresh = 1; |
1451 | want_refresh = 1; |
1455 | ZERO_SCROLLBACK (); |
1452 | ZERO_SCROLLBACK (); |
1456 | |
1453 | |
1457 | if (count <= 0) |
1454 | if (count <= 0) |
1458 | return; |
1455 | return; |
… | |
… | |
1460 | scr_do_wrap (); |
1457 | scr_do_wrap (); |
1461 | |
1458 | |
1462 | selection_check (1); |
1459 | selection_check (1); |
1463 | min_it (count, ncol - screen.cur.col); |
1460 | min_it (count, ncol - screen.cur.col); |
1464 | |
1461 | |
1465 | row = screen.cur.row; |
1462 | int row = screen.cur.row; |
1466 | |
1463 | |
1467 | line_t *line = &ROW(row); |
1464 | line_t *line = &ROW(row); |
1468 | |
1465 | |
1469 | line->touch (); |
1466 | line->touch (); |
1470 | line->is_longer (0); |
1467 | line->is_longer (0); |
1471 | |
1468 | |
1472 | switch (insdel) |
1469 | switch (insdel) |
1473 | { |
1470 | { |
1474 | case INSERT: |
1471 | case INSERT: |
1475 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1472 | line->l = min (line->l + count, ncol); |
|
|
1473 | |
|
|
1474 | for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1476 | { |
1475 | { |
1477 | line->t[col] = line->t[col - count]; |
1476 | line->t[col] = line->t[col - count]; |
1478 | line->r[col] = line->r[col - count]; |
1477 | line->r[col] = line->r[col - count]; |
1479 | } |
1478 | } |
1480 | |
|
|
1481 | line->l = min (line->l + count, ncol); |
|
|
1482 | |
1479 | |
1483 | if (selection.op && current_screen == selection.screen |
1480 | if (selection.op && current_screen == selection.screen |
1484 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1481 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1485 | { |
1482 | { |
1486 | if (selection.end.row != screen.cur.row |
1483 | if (selection.end.row != screen.cur.row |
… | |
… | |
1505 | |
1502 | |
1506 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1503 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1507 | break; |
1504 | break; |
1508 | |
1505 | |
1509 | case DELETE: |
1506 | case DELETE: |
|
|
1507 | { |
|
|
1508 | line->l = max (line->l - count, 0); |
|
|
1509 | |
1510 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1510 | rend_t tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1511 | |
1511 | |
1512 | for (col = screen.cur.col; (col + count) < ncol; col++) |
1512 | for (int col = screen.cur.col; (col + count) < ncol; col++) |
1513 | { |
1513 | { |
1514 | line->t[col] = line->t[col + count]; |
1514 | line->t[col] = line->t[col + count]; |
1515 | line->r[col] = line->r[col + count]; |
1515 | line->r[col] = line->r[col + count]; |
1516 | } |
1516 | } |
1517 | |
1517 | |
1518 | line->l = max (line->l - count, 0); |
1518 | // nuke wide char at the end |
|
|
1519 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1520 | scr_kill_char (*line, screen.cur.col); |
|
|
1521 | |
1519 | scr_blank_line (*line, ncol - count, count, tr); |
1522 | scr_blank_line (*line, ncol - count, count, tr); |
1520 | |
1523 | |
1521 | if (selection.op && current_screen == selection.screen |
1524 | if (selection.op && current_screen == selection.screen |
1522 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1525 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1523 | { |
1526 | { |
1524 | if (selection.end.row != screen.cur.row |
1527 | if (selection.end.row != screen.cur.row |
1525 | || (screen.cur.col >= selection.beg.col - count) |
1528 | || (screen.cur.col >= selection.beg.col - count) |
1526 | || selection.end.col >= ncol) |
1529 | || selection.end.col >= ncol) |
1527 | CLEAR_SELECTION (); |
1530 | CLEAR_SELECTION (); |
1528 | else |
1531 | else |
1529 | { |
1532 | { |
1530 | /* shift selection */ |
1533 | /* shift selection */ |
1531 | selection.beg.col -= count; |
1534 | selection.beg.col -= count; |
1532 | selection.mark.col -= count; /* XXX: yes? */ |
1535 | selection.mark.col -= count; /* XXX: yes? */ |
1533 | selection.end.col -= count; |
1536 | selection.end.col -= count; |
1534 | } |
1537 | } |
|
|
1538 | } |
1535 | } |
1539 | } |
1536 | |
1540 | |
1537 | break; |
1541 | break; |
1538 | } |
1542 | } |
1539 | } |
1543 | } |