1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

termui: add show_cursor() and hide_cursor() (#9087)

This commit is contained in:
James Addison 2021-03-04 10:31:26 +00:00 committed by GitHub
parent 9bb073580e
commit a64d9b3e12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -68,7 +68,8 @@ pub fn init(cfg Config) &Context {
}
if ctx.cfg.hide_cursor {
print('\x1b[?25l')
ctx.hide_cursor()
ctx.flush()
}
if ctx.cfg.window_title != '' {

View File

@ -77,7 +77,8 @@ fn (mut ctx Context) termios_setup() ? {
}
if ctx.cfg.hide_cursor {
print('\x1b[?25l')
ctx.hide_cursor()
ctx.flush()
}
if ctx.cfg.window_title != '' {

View File

@ -58,6 +58,18 @@ pub fn (mut ctx Context) set_cursor_position(x int, y int) {
ctx.write('\x1b[$y;${x}H')
}
[inline]
// show_cursor will make the cursor appear if it is not already visible
pub fn (mut ctx Context) show_cursor() {
ctx.write('\x1b[?25h')
}
// hide_cursor will make the cursor invisible
[inline]
pub fn (mut ctx Context) hide_cursor() {
ctx.write('\x1b[?25l')
}
[inline]
// set_color sets the current foreground color used by any succeeding `draw_*` calls.
pub fn (mut ctx Context) set_color(c Color) {