mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-17 17:32:22 +03: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:
|
||||
line = string(t.line)
|
||||
if t.enterClear {
|
||||
// Clear line on enter instead of starting a new line. The old
|
||||
// prompt is retained.
|
||||
t.moveCursorToPos(0)
|
||||
t.clearLineToRight()
|
||||
t.clearScreenBelow() // Necessary for wrapped lines
|
||||
// Clear line on enter instead of starting a new line.
|
||||
reset := []rune{
|
||||
// Clear whole line
|
||||
keyEscape, '[', '2', 'K',
|
||||
// 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 {
|
||||
// Pushing the line up resets the cursor to 0,0 and we render a
|
||||
// fresh prompt.
|
||||
|
Loading…
x
Reference in New Issue
Block a user