Skip to content

Commit

Permalink
publicize nccapabilities structure, add ncdirect_capabilities() #1768
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jun 17, 2021
1 parent 0e6f525 commit 4aa7026
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/notcurses/direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ API const char* ncdirect_detected_terminal(const struct ncdirect* n)
API bool ncdirect_canopen_images(const struct ncdirect* n)
__attribute__ ((nonnull (1)));

API const nccapabilities* ncdirect_capabilities(const struct ncdirect* n)
__attribute__ ((nonnull (1)));

// Is our encoding UTF-8? Requires LANG being set to a UTF8 locale.
API bool ncdirect_canutf8(const struct ncdirect* n)
__attribute__ ((nonnull (1)));
Expand Down
6 changes: 6 additions & 0 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,12 @@ API bool ncplane_translate_abs(const struct ncplane* n, int* RESTRICT y, int* RE
API bool ncplane_set_scrolling(struct ncplane* n, bool scrollp);

// Capabilities
// terminal capabilities exported to the user
typedef struct nccapabilities {
// assigned based off nl_langinfo() in notcurses_core_init()
bool utf8; // are we using utf-8 encoding? from nl_langinfo(3)
bool can_change_colors; // can we change the palette? terminfo ccc capability
} nccapabilities;

// Returns a 16-bit bitmask of supported curses-style attributes
// (NCSTYLE_UNDERLINE, NCSTYLE_BOLD, etc.) The attribute is only
Expand Down
4 changes: 4 additions & 0 deletions src/lib/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,3 +1374,7 @@ unsigned ncdirect_supported_styles(const ncdirect* nc){
const char* ncdirect_detected_terminal(const ncdirect* nc){
return nc->tcache.termname;
}

const nccapabilities* ncdirect_capabilities(const ncdirect* n){
return &n->tcache.caps;
}
7 changes: 0 additions & 7 deletions src/lib/termdesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ typedef struct ncinputlayer {
struct esctrie* inputescapes; // trie of input escapes -> ncspecial_keys
} ncinputlayer;

// terminal capabilities exported to the user
typedef struct nccapabilities {
// assigned based off nl_langinfo() in notcurses_core_init()
bool utf8; // are we using utf-8 encoding? from nl_langinfo(3)
bool can_change_colors; // can we change the palette? terminfo ccc capability
} nccapabilities;

// terminal interface description. most of these are acquired from terminfo(5)
// (using a database entry specified by TERM). some are determined via
// heuristics based off terminal interrogation or the TERM environment
Expand Down

0 comments on commit 4aa7026

Please sign in to comment.