From fa99672ff2863abac06d8729335366a3b865e5ab Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 6 May 2020 16:44:09 +0100 Subject: [PATCH] Fix cursor direction escapes --- escape.go | 4 ++-- escape_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/escape.go b/escape.go index 33e2faf5..8fe61744 100644 --- a/escape.go +++ b/escape.go @@ -37,10 +37,10 @@ func (t *Terminal) handleEscape(code string) { t.moveCursor(t.cursorRow+rows, t.cursorCol) case "C": cols, _ := strconv.Atoi(message) - t.moveCursor(t.cursorRow, t.cursorCol-cols) + t.moveCursor(t.cursorRow, t.cursorCol+cols) case "D": cols, _ := strconv.Atoi(message) - t.moveCursor(t.cursorRow, t.cursorCol+cols) + t.moveCursor(t.cursorRow, t.cursorCol-cols) case "H", "f": parts := strings.Split(message, ";") row, _ := strconv.Atoi(parts[0]) diff --git a/escape_test.go b/escape_test.go index 6168fb66..24edbf35 100644 --- a/escape_test.go +++ b/escape_test.go @@ -41,11 +41,11 @@ func TestCursorMove(t *testing.T) { assert.Equal(t, 0, term.cursorRow) assert.Equal(t, 3, term.cursorCol) - term.handleEscape("2C") + term.handleEscape("2D") assert.Equal(t, 0, term.cursorRow) assert.Equal(t, 1, term.cursorCol) - term.handleEscape("2D") + term.handleEscape("2C") assert.Equal(t, 0, term.cursorRow) assert.Equal(t, 3, term.cursorCol) @@ -66,11 +66,11 @@ func TestCursorMove_Overflow(t *testing.T) { assert.Equal(t, 1, term.cursorRow) assert.Equal(t, 1, term.cursorCol) - term.handleEscape("2C") + term.handleEscape("2D") assert.Equal(t, 1, term.cursorRow) assert.Equal(t, 0, term.cursorCol) - term.handleEscape("5D") + term.handleEscape("5C") assert.Equal(t, 1, term.cursorRow) assert.Equal(t, 1, term.cursorCol)