diff options
| -rw-r--r-- | st.c | 30 |
1 files changed, 12 insertions, 18 deletions
| @@ -1586,37 +1586,31 @@ tclearregion(int x1, int y1, int x2, int y2) { | |||
| 1586 | 1586 | ||
| 1587 | void | 1587 | void |
| 1588 | tdeletechar(int n) { | 1588 | tdeletechar(int n) { |
| 1589 | int src = term.c.x + n; | 1589 | int dst, src, size; |
| 1590 | int dst = term.c.x; | ||
| 1591 | int size = term.col - src; | ||
| 1592 | 1590 | ||
| 1593 | term.dirty[term.c.y] = 1; | 1591 | LIMIT(n, 0, term.col - term.c.x); |
| 1594 | 1592 | ||
| 1595 | if(src >= term.col) { | 1593 | dst = term.c.x; |
| 1596 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1594 | src = term.c.x + n; |
| 1597 | return; | 1595 | size = term.col - src; |
| 1598 | } | ||
| 1599 | 1596 | ||
| 1600 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], | 1597 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], |
| 1601 | size * sizeof(Glyph)); | 1598 | size * sizeof(Glyph)); |
| 1602 | tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); | 1599 | tclearregion(term.col-n, term.c.y, term.col-1, term.c.y); |
| 1603 | } | 1600 | } |
| 1604 | 1601 | ||
| 1605 | void | 1602 | void |
| 1606 | tinsertblank(int n) { | 1603 | tinsertblank(int n) { |
| 1607 | int src = term.c.x; | 1604 | int dst, src, size; |
| 1608 | int dst = src + n; | ||
| 1609 | int size = term.col - dst; | ||
| 1610 | 1605 | ||
| 1611 | term.dirty[term.c.y] = 1; | 1606 | LIMIT(n, 0, term.col - term.c.x); |
| 1612 | 1607 | ||
| 1613 | if(dst >= term.col) { | 1608 | dst = term.c.x + n; |
| 1614 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 1609 | src = term.c.x; |
| 1615 | return; | 1610 | size = term.col - dst; |
| 1616 | } | ||
| 1617 | 1611 | ||
| 1618 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], | 1612 | memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src], |
| 1619 | size * sizeof(Glyph)); | 1613 | size * sizeof(Glyph)); |
| 1620 | tclearregion(src, term.c.y, dst - 1, term.c.y); | 1614 | tclearregion(src, term.c.y, dst - 1, term.c.y); |
| 1621 | } | 1615 | } |
| 1622 | 1616 | ||
