Skip to content

Commit

Permalink
fix(term): ansi: default cursor/screen sequence values
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Mar 22, 2024
1 parent 7faadd0 commit ebda89b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions exp/term/ansi/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ func CursorPreviousLine(n int) string {
//
// See: https://vt100.net/docs/vt510-rm/CUP.html
func MoveCursor(row, col int) string {
var r, c string
if row > 1 {
r = strconv.Itoa(row)
if row < 0 {
row = 0
}
if col > 1 {
c = strconv.Itoa(col)
if col < 0 {
col = 0
}
return "\x1b[" + r + ";" + c + "H"
return "\x1b[" + strconv.Itoa(row) + ";" + strconv.Itoa(col) + "H"
}

// MoveCursorZero is a sequence for moving the cursor to the upper left corner
Expand Down
11 changes: 5 additions & 6 deletions exp/term/ansi/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ func DeleteLine(n int) string {
//
// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
func SetScrollingRegion(t, b int) string {
var ts, bs string
if t > 1 {
ts = strconv.Itoa(t)
if t < 0 {
t = 0
}
if b > 1 {
bs = strconv.Itoa(b)
if b < 0 {
b = 0
}
return "\x1b[" + ts + ";" + bs + "r"
return "\x1b[" + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r"
}

0 comments on commit ebda89b

Please sign in to comment.