Commit 51c9dbf
committed
Backspace when cursor is off right edge of screen should move back two cells
This is extremely counter-intuitive for a terminal like kitty that
allows the cursor to be off screen when drawing a char in the last cell.
However, most other terminals dont allow the cursor to be off the right
edge so it makes sense for them. There is no terminfo property
controlling this behavior as far as I know.
The execrable ncurses actually relies on this behavior of backspace to
position the cursor in some cases, the good lord alone knows why.
So in the interests of compatibility lets special case backsapce when
cursor is off the right edge.
A simple test script to see the behavior:
```py
import subprocess
cols = int(subprocess.check_output('tput cols'.split()).decode().strip())
print(end='\x1b[?7l') # turn off line wrap
print('a' * cols, end='\x08bc') # print a upto last cell then backspace and bc
input()
print(end='\x1b[?7h') # turn on line wrap
print()
```
This should result in a line starting with aaaa and ending with bc.
It does so in most terminals, exceptions being foot and kitty before
this patch.
Note that this also means that backspacing when cursor is off the right
edge of the terminal is broken in all terminals with this weird
behavior. See the docs in screen_backspace() for details. Sigh.
Fixes #88411 parent 55a2f2c commit 51c9dbf
3 files changed
+23
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1962 | 1962 | | |
1963 | 1963 | | |
1964 | 1964 | | |
1965 | | - | |
1966 | | - | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
1967 | 1980 | | |
1968 | 1981 | | |
1969 | 1982 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
565 | 567 | | |
566 | 568 | | |
567 | 569 | | |
568 | | - | |
| 570 | + | |
569 | 571 | | |
570 | 572 | | |
571 | 573 | | |
| |||
0 commit comments