diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index e916b5371..04f4680c0 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -76,6 +76,8 @@ API int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits); // Move the cursor in direct mode. -1 to retain current location on that axis. API int ncdirect_cursor_move_yx(struct ncdirect* n, int y, int x); +API int ncdirect_cursor_enable(struct ncdirect* nc); +API int ncdirect_cursor_disable(struct ncdirect* nc); // Clear the screen. API int ncdirect_clear(struct ncdirect* nc); diff --git a/src/lib/internal.h b/src/lib/internal.h index f935febfa..624859afc 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -214,6 +214,8 @@ typedef struct ncdirect { char* setab; // set background color (ANSI) char* op; // set foreground and background color to default char* cup; // move cursor + char* civis; // hide cursor + char* cnorm; // restore cursor to default state char* hpa; // horizontal position adjusment (move cursor on row) char* vpa; // vertical position adjustment (move cursor on column) char* standout; // CELL_STYLE_STANDOUT diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 4f6a70023..6f7ec36db 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -809,6 +809,8 @@ ncdirect* ncdirect_init(const char* termtype, FILE* outfp){ term_verify_seq(&ret->cup, "cup"); term_verify_seq(&ret->hpa, "hpa"); term_verify_seq(&ret->vpa, "vpa"); + term_verify_seq(&ret->civis, "civis"); + term_verify_seq(&ret->cnorm, "cnorm"); ret->RGBflag = query_rgb(); if((ret->colors = tigetnum("colors")) <= 0){ ret->colors = 1; @@ -1007,6 +1009,20 @@ int ncdirect_dim_y(const ncdirect* nc){ return -1; } +int ncdirect_cursor_enable(ncdirect* nc){ + if(!nc->cnorm){ + return -1; + } + return term_emit("cnorm", nc->cnorm, nc->ttyfp, true); +} + +int ncdirect_cursor_disable(ncdirect* nc){ + if(!nc->civis){ + return -1; + } + return term_emit("civis", nc->civis, nc->ttyfp, true); +} + int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){ if(y == -1){ // keep row the same, horizontal move only if(!n->hpa){