add ncdirect_canget_cursor() #1790

This commit is contained in:
nick black 2021-06-18 14:24:26 -04:00
parent b50bab7880
commit c9a338e0fd
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 41 additions and 6 deletions

View File

@ -20,6 +20,9 @@ rearrangements of Notcurses.
* `ncplane_as_rgba()`/`ncvisual_from_plane()` now support `NCBLIT_BRAILLE`.
* `CELL_ALPHA_*` macros are now `NCALPHA_*`. The former will remain
`#define`d until ABI3.
* Filled out the complete set of `ncdirect_can*()` capability functions,
which now match the `notcurses_can*()` API. Added
`ncdirect_canget_cursor()` to check if the cursor can be located.
* 2.3.4 (2021-06-12)
* Added the flag `NCVISUAL_OPTION_NOINTERPOLATE` to use non-interpolative

View File

@ -74,12 +74,6 @@ notcurses_direct - minimal notcurses instances for styling text
**const char* ncdirect_detected_terminal(const struct ncdirect* ***n***);**
**bool ncdirect_canopen_images(const struct ncdirect* ***n***);**
**bool ncdirect_canutf8(const struct ncdirect* ***n***);**
**int ncdirect_check_pixel_support(struct ncdirect* ***n***);**
**int ncdirect_hline_interp(struct ncdirect* ***n***, const char* ***egc***, int ***len***, uint64_t ***h1***, uint64_t ***h2***);**
**int ncdirect_vline_interp(struct ncdirect* ***n***, const char* ***egc***, int ***len***, uint64_t ***h1***, uint64_t ***h2***);**
@ -94,6 +88,30 @@ notcurses_direct - minimal notcurses instances for styling text
**char* ncdirect_readline(struct ncdirect* ***n***, const char* ***prompt***);**
**bool ncdirect_cantruecolor(const struct ncdirect* ***nc***);**
**bool ncdirect_canchangecolor(const struct ncdirect* ***nc***);**
**bool ncdirect_canfade(const struct ncdirect* ***nc***);**
**bool ncdirect_canopen_images(const struct ncdirect* ***nc***);**
**bool ncdirect_canopen_videos(const struct ncdirect* ***nc***);**
**bool ncdirect_canutf8(const struct ncdirect* ***nc***);**
**int ncdirect_check_pixel_support(const struct ncdirect* ***nc***);**
**bool ncdirect_canhalfblock(const struct ncdirect* ***nc***);**
**bool ncdirect_canquadrant(const struct ncdirect* ***nc***);**
**bool ncdirect_cansextant(const struct ncdirect* ***nc***);**
**bool ncdirect_canbraille(const struct ncdirect* ***nc***);**
**bool ncdirect_canget_cursor(const struct ncdirect* ***nc***);**
```c
typedef struct ncvgeom {
int pixy, pixx; // true pixel geometry of ncvisual data

View File

@ -480,6 +480,10 @@ ncdirect_canbraille(const struct ncdirect* nc){
return ncdirect_canutf8(nc) && ncdirect_capabilities(nc)->braille;
}
// Is there support for acquiring the cursor's current position? Requires the
// u7 terminfo capability, and that we are connected to an actual terminal.
bool ncdirect_canget_cursor(const struct ncdirect* nc);
#undef ALLOC
#undef API

View File

@ -1393,3 +1393,13 @@ const char* ncdirect_detected_terminal(const ncdirect* nc){
const nccapabilities* ncdirect_capabilities(const ncdirect* n){
return &n->tcache.caps;
}
bool ncdirect_canget_cursor(const ncdirect* n){
if(get_escape(&n->tcache, ESCAPE_DSRCPR) == NULL){
return false;
}
if(n->ctermfd < 0){
return false;
}
return true;
}