diff options
| author | ruki <[email protected]> | 2025-10-27 23:01:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-10-27 23:01:30 +0800 |
| commit | 482a5aa7aa91c81017f272aa5947b24fc21a4615 (patch) | |
| tree | b0b0a275e160e1996c3cd4a842efd28290f52103 /xmake/core/base/tty.lua | |
| parent | bb73866d8688f76eb62c086e0e311efc53f003d1 (diff) | |
improve tty
Diffstat (limited to 'xmake/core/base/tty.lua')
| -rw-r--r-- | xmake/core/base/tty.lua | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index a52a4936f..471fb355a 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -141,7 +141,9 @@ function tty.cursor_move(row, col) if tty.has_vtansi() then row = row or 1 col = col or 1 - tty._iowrite(string.format("\x1b[%d;%dH", row, col)) + if row > 0 and col > 0 then + tty._iowrite(string.format("\x1b[%d;%dH", row, col)) + end end return tty end @@ -150,7 +152,9 @@ end function tty.cursor_move_up(n) if tty.has_vtansi() then n = n or 1 - tty._iowrite(string.format("\x1b[%dA", n)) + if n > 0 then + tty._iowrite(string.format("\x1b[%dA", n)) + end end return tty end @@ -159,7 +163,9 @@ end function tty.cursor_move_down(n) if tty.has_vtansi() then n = n or 1 - tty._iowrite(string.format("\x1b[%dB", n)) + if n > 0 then + tty._iowrite(string.format("\x1b[%dB", n)) + end end return tty end @@ -168,7 +174,9 @@ end function tty.cursor_move_right(n) if tty.has_vtansi() then n = n or 1 - tty._iowrite(string.format("\x1b[%dC", n)) + if n > 0 then + tty._iowrite(string.format("\x1b[%dC", n)) + end end return tty end @@ -177,7 +185,9 @@ end function tty.cursor_move_left(n) if tty.has_vtansi() then n = n or 1 - tty._iowrite(string.format("\x1b[%dD", n)) + if n > 0 then + tty._iowrite(string.format("\x1b[%dD", n)) + end end return tty end @@ -186,7 +196,9 @@ end function tty.cursor_move_to_col(col) if tty.has_vtansi() then col = col or 1 - tty._iowrite(string.format("\x1b[%dG", col)) + if col > 0 then + tty._iowrite(string.format("\x1b[%dG", col)) + end end return tty end |
