notcurses_directmode()->ncdirect_init()

pull/396/head
nick black 4 years ago
parent 314eba5530
commit bb579d0d05
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -334,8 +334,8 @@ bool notcurses_canchangecolors(const struct notcurses* nc);
"Direct mode" makes a limited subset of notcurses is available for manipulating
typical scrolling or file-backed output. These functions output directly and
immediately to the provided `FILE*`, and `notcurses_render()` is neither
supported nor necessary for such an instance. Use `notcurses_directmode()` to
create a direct mode context:
supported nor necessary for such an instance. Use `ncdirect_init()` to create a
direct mode context:
```c
struct ncdirect; // minimal state for a terminal
@ -346,7 +346,7 @@ struct ncdirect; // minimal state for a terminal
// supports nor requires notcurses_render(). This can be used to add color and
// styling to text in the standard output paradigm. Returns NULL on error,
// including any failure initializing terminfo.
struct ncdirect* notcurses_directmode(const char* termtype, FILE* fp);
struct ncdirect* ncdirect_init(const char* termtype, FILE* fp);
// Release 'nc' and any associated resources. 0 on success, non-0 on failure.
int ncdirect_stop(struct ncdirect* nc);

@ -14,6 +14,7 @@ libnotcurses.so.1 libnotcurses1 #MINVER#
ncdirect_dimy@Base 1.2.3
ncdirect_fg@Base 1.2.1
ncdirect_fg_default@Base 1.2.1
ncdirect_init@Base 1.2.3
ncdirect_stop@Base 1.2.1
ncdirect_styles_off@Base 1.2.1
ncdirect_styles_on@Base 1.2.1

@ -43,7 +43,7 @@ control of notcurses behavior, including signal handlers, alternative screens,
and overriding the TERM environment variable. A **terminfo** entry appropriate
for the actual terminal must be available.
**notcurses_directmode(3)** makes available a very restricted subset of
**ncdirect_init(3)** makes available a very restricted subset of
notcurses functionality. This subset is intended to be interleaved with user-
generated output, and is limited to coloring and styling. Direct mode is
documented in **notcurses_directmode(3)**

@ -1,16 +1,16 @@
% notcurses_directmode(3)
% ncdirect_init(3)
% nick black <nickblack@linux.com>
% v1.2.2
# NAME
notcurses_directmode - minimal notcurses instances for styling text
ncdirect_init - minimal notcurses instances for styling text
# SYNOPSIS
**#include <notcurses.h>**
**struct ncdirect* notcurses_directmode(const char *termtype, FILE* fp);**
**struct ncdirect* ncdirect_init(const char *termtype, FILE* fp);**
**int ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b);**
@ -42,7 +42,7 @@ notcurses_directmode - minimal notcurses instances for styling text
# DESCRIPTION
**notcurses_directmode** prepares the **FILE** provided as **fp** (which must
**ncdirect_init** prepares the **FILE** provided as **fp** (which must
be attached to a terminal) for colorizing and styling. On success, a pointer to
a valid **struct ncdirect** is returned. **NULL** is returned on failure.
Before the process exits, **ncdirect_stop(3)** should be called to reset the
@ -67,9 +67,9 @@ be specified for either **y** or **x** to leave that axis unchanged.
# RETURN VALUES
**notcurses_directmode** returns **NULL** on failure. Otherwise, the return
value points to a valid **struct ncdirect**, which can be used until it is
provided to **ncdirect_stop**.
**ncdirect_init** returns **NULL** on failure. Otherwise, the return value
points to a valid **struct ncdirect**, which can be used until it is provided
to **ncdirect_stop**.
# SEE ALSO

@ -14,7 +14,7 @@ namespace ncpp
public:
explicit Direct (const char *termtype = nullptr, FILE *fp = nullptr)
{
direct = notcurses_directmode (termtype, fp == nullptr ? stdout : fp);
direct = ncdirect_init (termtype, fp == nullptr ? stdout : fp);
if (direct == nullptr)
throw init_error ("notcurses failed to initialize direct mode");
}

@ -38,7 +38,7 @@ struct notcurses; // notcurses state for a given terminal, composed of ncplanes
// supports nor requires notcurses_render(). This can be used to add color and
// styling to text in the standard output paradigm. Returns NULL on error,
// including any failure initializing terminfo.
API struct ncdirect* notcurses_directmode(const char* termtype, FILE* fp);
API struct ncdirect* ncdirect_init(const char* termtype, FILE* fp);
// Direct mode. This API can be used to colorize and stylize output generated
// outside of notcurses, without ever calling notcurses_render(). These should

@ -238,7 +238,7 @@ int palette256_set(palette256* p, int idx, unsigned rgb);
int palette256_get_rgb(const palette256* p, int idx, unsigned* r, unsigned* g, unsigned* b);
void palette256_free(palette256* p);
bool notcurses_canchangecolor(const struct notcurses* nc);
struct ncdirect* notcurses_directmode(const char* termtype, FILE* fp);
struct ncdirect* ncdirect_init(const char* termtype, FILE* fp);
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);

@ -80,7 +80,7 @@ class Notcurses:
class Ncdirect:
def __init__(self):
self.nc = lib.notcurses_directmode(ffi.NULL, sys.stdout)
self.nc = lib.ncdirect_init(ffi.NULL, sys.stdout)
def __del__(self):
lib.ncdirect_stop(self.nc)

@ -488,7 +488,7 @@ int main(int argc, char** argv){
fprintf(stderr, "Warning: error closing renderfile\n");
}
}
struct ncdirect* ncd = notcurses_directmode(NULL, stdout);
struct ncdirect* ncd = ncdirect_init(NULL, stdout);
if(!ncd){
return EXIT_FAILURE;
}

@ -479,6 +479,7 @@ const char* ncmenu_selected(const ncmenu* n, ncinput* ni){
}
bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
fprintf(stderr, "KEY: %lc %u\n", nc->id, nc->id);
if(n->unrolledsection < 0){
return false;
}
@ -492,12 +493,12 @@ bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
return false;
}
return true;
}else if(nc->id == NCKEY_UP){
}else if(nc->id == NCKEY_UP || nc->id == NCKEY_SCROLL_UP){
if(ncmenu_previtem(n)){
return false;
}
return true;
}else if(nc->id == NCKEY_DOWN){
}else if(nc->id == NCKEY_DOWN || nc->id == NCKEY_SCROLL_DOWN){
if(ncmenu_nextitem(n)){
return false;
}

@ -764,7 +764,7 @@ ffmpeg_log_level(ncloglevel_e level){
#endif
}
ncdirect* notcurses_directmode(const char* termtype, FILE* outfp){
ncdirect* ncdirect_init(const char* termtype, FILE* outfp){
ncdirect* ret = malloc(sizeof(*ret));
if(ret == NULL){
return ret;

@ -48,5 +48,8 @@ int main(void){
fprintf(stderr, "Error stopping notcurses\n");
return EXIT_FAILURE;
}
struct ncdirect* n;
if((n = ncdirect_init()) == NULL){
}
return EXIT_SUCCESS;
}

@ -44,7 +44,7 @@ int main(void){
if(!setlocale(LC_ALL, "")){
return EXIT_FAILURE;
}
struct ncdirect* nc = notcurses_directmode(NULL, stdout);
struct ncdirect* nc = ncdirect_initmode(NULL, stdout);
if(!nc){
return EXIT_FAILURE;
}

@ -8,7 +8,7 @@ TEST_CASE("DirectMode") {
FILE* outfp_{};
outfp_ = fopen("/dev/tty", "wb");
REQUIRE(nullptr != outfp_);
struct ncdirect* nc_ = notcurses_directmode(NULL, outfp_);
struct ncdirect* nc_ = ncdirect_init(NULL, outfp_);
REQUIRE(nullptr != nc_);
SUBCASE("SetItalic") {

Loading…
Cancel
Save