diff --git a/vlib/term/ui/input_windows.c.v b/vlib/term/ui/input_windows.c.v index 87ecf6cef5..af8aaeb04f 100644 --- a/vlib/term/ui/input_windows.c.v +++ b/vlib/term/ui/input_windows.c.v @@ -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 != '' { diff --git a/vlib/term/ui/termios_nix.c.v b/vlib/term/ui/termios_nix.c.v index b2c0357e00..4672125977 100644 --- a/vlib/term/ui/termios_nix.c.v +++ b/vlib/term/ui/termios_nix.c.v @@ -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 != '' { diff --git a/vlib/term/ui/ui.v b/vlib/term/ui/ui.v index 4a76212c9d..1d8ed694f4 100644 --- a/vlib/term/ui/ui.v +++ b/vlib/term/ui/ui.v @@ -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) {