mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-20 20:44:30 +02:00
sshd/terminal: Use clearline and clearscreen codes for enterClear
Fixes emoji offset bug
This commit is contained in:
parent
c9b58a80fa
commit
479a391d55
@ -529,11 +529,18 @@ func (t *Terminal) handleKey(key rune) (line string, ok bool) {
|
|||||||
case keyEnter:
|
case keyEnter:
|
||||||
line = string(t.line)
|
line = string(t.line)
|
||||||
if t.enterClear {
|
if t.enterClear {
|
||||||
// Clear line on enter instead of starting a new line. The old
|
// Clear line on enter instead of starting a new line.
|
||||||
// prompt is retained.
|
reset := []rune{
|
||||||
t.moveCursorToPos(0)
|
// Clear whole line
|
||||||
t.clearLineToRight()
|
keyEscape, '[', '2', 'K',
|
||||||
t.clearScreenBelow() // Necessary for wrapped lines
|
// Clear screen below (for any wrapped lines)
|
||||||
|
keyEscape, '[', 'J',
|
||||||
|
}
|
||||||
|
t.queue(reset)
|
||||||
|
// We're still technically on the same line. If we don't offset the
|
||||||
|
// cursorX, then the fresh prompt could be rendered in the wrong
|
||||||
|
// position.
|
||||||
|
t.cursorX += len(reset)
|
||||||
} else {
|
} else {
|
||||||
// Pushing the line up resets the cursor to 0,0 and we render a
|
// Pushing the line up resets the cursor to 0,0 and we render a
|
||||||
// fresh prompt.
|
// fresh prompt.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user