diff options
| author | ruki <[email protected]> | 2020-05-31 22:11:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-31 22:11:16 +0800 |
| commit | 0f6136ff2b2e43b60c11c265f990e9dd022d7a65 (patch) | |
| tree | 76d2419b088c93baf704718ccf790e30aa494305 /xmake/core/base/tty.lua | |
| parent | 41bd7287e986fcf881c8d20494058c576bbcf252 (diff) | |
add some cursor ops for tty
Diffstat (limited to 'xmake/core/base/tty.lua')
| -rw-r--r-- | xmake/core/base/tty.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index d1245fc1a..7ad78ab3e 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -56,6 +56,48 @@ function tty.erase_line() return tty end +-- erases the screen from the current line down to the bottom of the screen. +function tty.erase_down() + tty._iowrite("\x1b[J") + return tty +end + +-- erases the screen from the current line up to the top of the screen. +function tty.erase_up() + tty._iowrite("\x1b[1J") + return tty +end + +-- erases the screen with the background colour and moves the cursor to home. +function tty.erase_screen() + tty._iowrite("\x1b[2J") + return tty +end + +-- save current cursor position. +function tty.cursor_save() + tty._iowrite("\x1b[s") + return tty +end + +-- restores cursor position after a save cursor. +function tty.cursor_restore() + tty._iowrite("\x1b[u") + return tty +end + +-- save current cursor position and color attrs +function tty.cursor_and_attrs_save() + tty._iowrite("\x1b7") + return tty +end + +-- restores cursor position and color attrs after a save cursor. +function tty.cursor_and_attrs_restore() + tty._iowrite("\x1b8") + return tty +end + -- carriage return function tty.cr() tty._iowrite("\r") |
