Skip to content

Commit

Permalink
Add test and default value for P escape
Browse files Browse the repository at this point in the history
  • Loading branch information
figuerom16 committed Feb 2, 2024
1 parent 249f220 commit cb7a9e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions escape.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package terminal

import (
"fmt"
"log"
"strconv"
"strings"
Expand Down Expand Up @@ -130,6 +131,9 @@ func escapeColorMode(t *Terminal, msg string) {

func escapeDeleteChars(t *Terminal, msg string) {
i, _ := strconv.Atoi(msg)
if i == 0 {
i = 1
}
right := t.cursorCol + i

row := t.content.Row(t.cursorRow)
Expand All @@ -139,6 +143,7 @@ func escapeDeleteChars(t *Terminal, msg string) {
}

t.content.SetRow(t.cursorRow, widget.TextGridRow{Cells: cells})
fmt.Println(t.content.Text())
}

func escapeEraseInLine(t *Terminal, msg string) {
Expand Down
14 changes: 14 additions & 0 deletions escape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ func TestClearScreen(t *testing.T) {
assert.Equal(t, "", term.content.Text())
}

func TestInsertDeleteChars(t *testing.T) {
term := New()
term.config.Columns = 5
term.config.Rows = 2
term.handleOutput([]byte("Hello"))
assert.Equal(t, "Hello", term.content.Text())

term.moveCursor(0, 2)
term.handleEscape("2@")
assert.Equal(t, "He llo", term.content.Text())
term.handleEscape("3P")
assert.Equal(t, "Helo", term.content.Text())
}

func TestEraseLine(t *testing.T) {
term := New()
term.config.Columns = 5
Expand Down

0 comments on commit cb7a9e5

Please sign in to comment.