mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
add ncdirect_clear() #343
This commit is contained in:
parent
6d629025e3
commit
ce3e5d112e
@ -375,6 +375,7 @@ int ncdirect_dim_y(const struct ncdirect* nc);
|
||||
int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_clear(struct ncdirect* nc); // clear the screen
|
||||
```
|
||||
|
||||
### Alignment
|
||||
|
@ -34,6 +34,8 @@ notcurses_directmode - minimal notcurses instances for styling text
|
||||
|
||||
**int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);**
|
||||
|
||||
**int ncdirect_clear(struct ncdirect* nc)**
|
||||
|
||||
**int ncdirect_stop(struct ncdirect* nc);**
|
||||
|
||||
# DESCRIPTION
|
||||
@ -55,6 +57,9 @@ display capabilities, and/or display errors. notcurses natively targets
|
||||
**ncdirect_dim_x** returns the current number of columns, and **ncdirect_dim_y**
|
||||
the current number of rows.
|
||||
|
||||
**ncdirect_clear** clears the screen using a control code if one exists in
|
||||
terminfo. Otherwise, it prints successive newlines to scroll everything off.
|
||||
|
||||
# RETURN VALUES
|
||||
|
||||
**notcurses_directmode** returns **NULL** on failure. Otherwise, the return
|
||||
|
@ -73,6 +73,9 @@ API int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);
|
||||
|
||||
// Clear the screen.
|
||||
API int ncdirect_clear(struct ncdirect* nc);
|
||||
|
||||
// Release 'nc' and any associated resources. 0 on success, non-0 on failure.
|
||||
API int ncdirect_stop(struct ncdirect* nc);
|
||||
|
||||
|
@ -233,14 +233,15 @@ int palette256_get_rgb(const palette256* p, int idx, unsigned* r, unsigned* g, u
|
||||
void palette256_free(palette256* p);
|
||||
bool notcurses_canchangecolor(const struct notcurses* nc);
|
||||
struct ncdirect* notcurses_directmode(const char* termtype, FILE* fp);
|
||||
int ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b);
|
||||
int ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b);
|
||||
int ncdirect_fg(struct ncdirect* nc, unsigned rgb);
|
||||
int ncdirect_bg(struct ncdirect* nc, unsigned rgb);
|
||||
int ncdirect_bg_rgb8(struct ncdirect* n, unsigned r, unsigned g, unsigned b);
|
||||
int ncdirect_fg_rgb8(struct ncdirect* n, unsigned r, unsigned g, unsigned b);
|
||||
int ncdirect_fg(struct ncdirect* n, unsigned rgb);
|
||||
int ncdirect_bg(struct ncdirect* n, unsigned rgb);
|
||||
int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);
|
||||
int ncdirect_stop(struct ncdirect* nc);
|
||||
int ncdirect_clear(struct ncdirect* n);
|
||||
int ncdirect_stop(struct ncdirect* n);
|
||||
struct ncvisual* ncplane_visual_open(struct ncplane* nc, const char* file, int* averr);
|
||||
typedef enum {
|
||||
NCSCALE_NONE,
|
||||
|
@ -198,6 +198,7 @@ typedef struct ncdirect {
|
||||
char* italoff; // CELL_STYLE_ITALIC (disable)
|
||||
char* initc; // set a palette entry's RGB value
|
||||
char* oc; // restore original colors
|
||||
char* clear; // clear the screen
|
||||
bool RGBflag; // terminfo-reported "RGB" flag for 24bpc directcolor
|
||||
bool CCCflag; // terminfo-reported "CCC" flag for palette set capability
|
||||
FILE* ttyfp; // FILE* for controlling tty, from opts->ttyfp
|
||||
|
@ -803,6 +803,7 @@ ncdirect* notcurses_directmode(const char* termtype, FILE* outfp){
|
||||
term_verify_seq(&ret->oc, "oc");
|
||||
term_verify_seq(&ret->setaf, "setaf");
|
||||
term_verify_seq(&ret->setab, "setab");
|
||||
term_verify_seq(&ret->clear, "clear");
|
||||
ret->RGBflag = query_rgb();
|
||||
if((ret->colors = tigetnum("colors")) <= 0){
|
||||
ret->colors = 1;
|
||||
@ -971,6 +972,13 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ncdirect_clear(ncdirect* nc){
|
||||
if(!nc->clear){
|
||||
// FIXME scroll output off the screen
|
||||
}
|
||||
return term_emit("clear", nc->clear, nc->ttyfp, true);
|
||||
}
|
||||
|
||||
int ncdirect_stop(ncdirect* nc){
|
||||
int ret = 0;
|
||||
if(nc){
|
||||
|
@ -31,7 +31,6 @@ int main(int argc, char** argv){
|
||||
if(notcurses_render(nc)){
|
||||
goto err;
|
||||
}
|
||||
sleep(1);
|
||||
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
|
||||
err:
|
||||
|
Loading…
x
Reference in New Issue
Block a user