add ncdirect_{en,dis}able_cursor() #402

pull/405/head
nick black 4 years ago
parent d5d827f38e
commit 1b4333861a
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -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);

@ -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

@ -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){

Loading…
Cancel
Save