mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
Set up sane logging for direct mode
All our diagnostic macros required a struct notcurses from which to extract the loglevel. Eliminate this parameter, and update all caller sites. Add a library-wide (but not exported) loglevel variable, and set it from both notcurses_core_init() and ncdirect_core_init(). Add two new direct mode flags, NCDIRECT_OPTION_VERBOSE and NCDIRECT_OPTION_VERY_VERBOSE, mapping them to NCLOGLEVEL_WARNING and NCLOGLEVEL_INFO respectively. Closes #1690.
This commit is contained in:
parent
391c58e4ed
commit
c8dfa17485
3
NEWS.md
3
NEWS.md
@ -10,7 +10,6 @@ rearrangements of Notcurses.
|
||||
or fail. The new routines rely on the terminal answering the Send Device
|
||||
Attributes escape; if it does not, Notcurses may refuse to start, or even
|
||||
hang. Please report a bug if you run into this.
|
||||
|
||||
It is still necessary to supply a correct `TERM` environment variable,
|
||||
because this is used to index into the `terminfo(5)` database, which
|
||||
seeds most common escapes. The extended capabilities of some modern
|
||||
@ -25,6 +24,8 @@ rearrangements of Notcurses.
|
||||
`ncdirect_canget_cursor()` to check if the cursor can be located.
|
||||
* `ncdirect_dim_y()` and `ncdirect_dim_x()` no longer accept a
|
||||
`const ncdirect*`, since they update the term parameters. Sorry!
|
||||
* Added `NCDIRECT_OPTION_VERBOSE` and `NCDIRECT_OPTION_VERY_VERBOSE`.
|
||||
They map to `NCLOGLEVEL_WARNING` and `NCLOGLEVEL_TRACE`, respectively.
|
||||
|
||||
* 2.3.4 (2021-06-12)
|
||||
* Added the flag `NCVISUAL_OPTION_NOINTERPOLATE` to use non-interpolative
|
||||
|
@ -14,6 +14,8 @@ notcurses_direct - minimal notcurses instances for styling text
|
||||
#define NCDIRECT_OPTION_INHIBIT_SETLOCALE 0x0001ull
|
||||
#define NCDIRECT_OPTION_INHIBIT_CBREAK 0x0002ull
|
||||
#define NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS 0x0008ull
|
||||
#define NCDIRECT_OPTION_VERBOSE 0x0010ull
|
||||
#define NCDIRECT_OPTION_VERY_VERBOSE 0x0020ull
|
||||
```
|
||||
|
||||
**struct ncdirect* ncdirect_init(const char* ***termtype***, FILE* ***fp***, uint64_t ***flags***);**
|
||||
@ -170,6 +172,12 @@ The following flags are defined:
|
||||
**SIGTERM**, and **SIGABRT**, cleaning up the terminal on such exceptions.
|
||||
With this flag, the handler will not be installed.
|
||||
|
||||
* **NCDIRECT_OPTION_VERBOSE**: Enable diagnostics to **stderr** at the level of
|
||||
**NCLOGLEVEL_WARNING**.
|
||||
|
||||
* **NCDIRECT_OPTION_VERY_VERBOSE**: Enable all diagnostics (equivalent to
|
||||
**NCLOGLEVEL_TRACE**). Implies **NCDIRECT_OPTION_VERBOSE**.
|
||||
|
||||
An appropriate **terminfo(5)** entry must exist for the terminal. This entry is
|
||||
usually selected using the value of the **TERM** environment variable (see
|
||||
**getenv(3)**), but a non-**NULL** value for **termtype** will override this. An
|
||||
@ -225,6 +233,12 @@ support, and 1 if pixel support is successfully detected.
|
||||
|
||||
All other functions return 0 on success, and non-zero on error.
|
||||
|
||||
# NOTES
|
||||
|
||||
You are recommended to accept **-v** and **-vv** as command-line options,
|
||||
mapping them to **NCDIRECT_OPTION_VERBOSE** and
|
||||
**NCDIRECT_OPTION_VERY_VERBOSE** respectively.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
**getenv(3)**,
|
||||
|
@ -212,6 +212,17 @@ A subprocess can be streamed to a plane with an **ncsubproc**, etc.
|
||||
|
||||
**notcurses_cursor_disable** returns -1 if the cursor is already invisible.
|
||||
|
||||
# NOTES
|
||||
|
||||
Several command-line options and keybindings are recommended for Notcurses
|
||||
rendered-mode programs:
|
||||
|
||||
* **-l[0-8]** ought be mapped to the various **NCLOGLEVEL** values.
|
||||
Alternatively, map **-v** to **NCLOGLEVEL_WARNING**, and map
|
||||
**-vv** to **NCLOGLEVEL_INFO**.
|
||||
* **-k** ought be mapped to **NCOPTION_NO_ALTERNATE_SCREEN**.
|
||||
* Ctrl+L ought be mapped to **notcurses_refresh(3)**.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
**getenv(3)**,
|
||||
|
@ -29,6 +29,13 @@ extern "C" {
|
||||
// registration of these signal handlers. Chosen to match fullscreen mode.
|
||||
#define NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS 0x0008ull
|
||||
|
||||
// Enable logging (to stderr) at the NCLOGLEVEL_WARNING level.
|
||||
#define NCDIRECT_OPTION_VERBOSE 0x0010ull
|
||||
|
||||
// Enable logging (to stderr) at the NCLOGLEVEL_TRACE level. This will enable
|
||||
// all diagnostics, a superset of NCDIRECT_OPTION_VERBOSE (which this implies).
|
||||
#define NCDIRECT_OPTION_VERY_VERBOSE 0x0020ull
|
||||
|
||||
// Initialize a direct-mode Notcurses context on the connected terminal at 'fp'.
|
||||
// 'fp' must be a tty. You'll usually want stdout. Direct mode supports a
|
||||
// limited subset of Notcurses routines which directly affect 'fp', and neither
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
int loglevel = NCLOGLEVEL_SILENT;
|
||||
|
||||
static inline char
|
||||
capyn(const char* cap){
|
||||
return cap ? 'y' : 'n';
|
||||
|
@ -779,8 +779,8 @@ ncdirect_stop_minimal(void* vnc){
|
||||
}
|
||||
|
||||
ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
if(flags > (NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS << 1)){ // allow them through with warning
|
||||
logwarn((struct notcurses*)NULL, "Passed unsupported flags 0x%016jx\n", (uintmax_t)flags);
|
||||
if(flags > (NCDIRECT_OPTION_VERY_VERBOSE << 1)){ // allow them through with warning
|
||||
logwarn("Passed unsupported flags 0x%016jx\n", (uintmax_t)flags);
|
||||
}
|
||||
if(outfp == NULL){
|
||||
outfp = stdout;
|
||||
@ -793,7 +793,7 @@ ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
ret->flags = flags;
|
||||
ret->ttyfp = outfp;
|
||||
if(!(flags & NCDIRECT_OPTION_INHIBIT_SETLOCALE)){
|
||||
init_lang(NULL);
|
||||
init_lang();
|
||||
}
|
||||
const char* encoding = nl_langinfo(CODESET);
|
||||
bool utf8 = false;
|
||||
@ -805,8 +805,17 @@ ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
// don't set the loglevel until we've locked in signal handling, lest we
|
||||
// change the loglevel out from under a running instance.
|
||||
if(flags & NCDIRECT_OPTION_VERY_VERBOSE){
|
||||
loglevel = NCLOGLEVEL_TRACE;
|
||||
}else if(flags & NCDIRECT_OPTION_VERBOSE){
|
||||
loglevel = NCLOGLEVEL_WARNING;
|
||||
}else{
|
||||
loglevel = NCLOGLEVEL_SILENT;
|
||||
}
|
||||
// we don't need a controlling tty for everything we do; allow a failure here
|
||||
ret->ctermfd = get_tty_fd(NULL, ret->ttyfp);
|
||||
ret->ctermfd = get_tty_fd(ret->ttyfp);
|
||||
const char* shortname_term;
|
||||
int termerr;
|
||||
if(setupterm(termtype, ret->ctermfd, &termerr) != OK){
|
||||
|
20
src/lib/fd.c
20
src/lib/fd.c
@ -109,7 +109,7 @@ ncfdplane_create_internal(ncplane* n, const ncfdplane_options* opts, int fd,
|
||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn,
|
||||
bool thread){
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
ncfdplane* ret = malloc(sizeof(*ret));
|
||||
if(ret == NULL){
|
||||
@ -310,7 +310,7 @@ ncsubproc* ncsubproc_createv(ncplane* n, const ncsubproc_options* opts,
|
||||
return NULL;
|
||||
}
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
int fd = -1;
|
||||
ncsubproc* ret = malloc(sizeof(*ret));
|
||||
@ -345,7 +345,7 @@ ncsubproc* ncsubproc_createvp(ncplane* n, const ncsubproc_options* opts,
|
||||
return NULL;
|
||||
}
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
int fd = -1;
|
||||
ncsubproc* ret = malloc(sizeof(*ret));
|
||||
@ -380,7 +380,7 @@ ncsubproc* ncsubproc_createvpe(ncplane* n, const ncsubproc_options* opts,
|
||||
return NULL;
|
||||
}
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
int fd = -1;
|
||||
ncsubproc* ret = malloc(sizeof(*ret));
|
||||
@ -459,16 +459,16 @@ ncplane* ncsubproc_plane(ncsubproc* n){
|
||||
|
||||
// if ttyfp is a tty, return a file descriptor extracted from it. otherwise,
|
||||
// try to get the controlling terminal. otherwise, return -1.
|
||||
int get_tty_fd(notcurses* nc, FILE* ttyfp){
|
||||
int get_tty_fd(FILE* ttyfp){
|
||||
int fd = -1;
|
||||
if(ttyfp){
|
||||
if((fd = fileno(ttyfp)) < 0){
|
||||
logwarn(nc, "No file descriptor was available in outfp %p\n", ttyfp);
|
||||
logwarn("No file descriptor was available in outfp %p\n", ttyfp);
|
||||
}else{
|
||||
if(isatty(fd)){
|
||||
fd = dup(fd);
|
||||
}else{
|
||||
loginfo(nc, "File descriptor %d was not a TTY\n", fd);
|
||||
loginfo("File descriptor %d was not a TTY\n", fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
@ -476,15 +476,15 @@ int get_tty_fd(notcurses* nc, FILE* ttyfp){
|
||||
if(fd < 0){
|
||||
fd = open("/dev/tty", O_RDWR | O_CLOEXEC);
|
||||
if(fd < 0){
|
||||
loginfo(nc, "Error opening /dev/tty (%s)\n", strerror(errno));
|
||||
loginfo("Error opening /dev/tty (%s)\n", strerror(errno));
|
||||
}else{
|
||||
if(!isatty(fd)){
|
||||
loginfo(nc, "File descriptor for /dev/tty (%d) is not actually a TTY\n", fd);
|
||||
loginfo("File descriptor for /dev/tty (%d) is not actually a TTY\n", fd);
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
loginfo(nc, "Returning TTY fd %d\n", fd);
|
||||
loginfo("Returning TTY fd %d\n", fd);
|
||||
return fd;
|
||||
}
|
||||
|
@ -146,11 +146,11 @@ calc_highgradient(nccell* c, uint32_t ul, uint32_t ur, uint32_t ll,
|
||||
int ncplane_highgradient(ncplane* n, uint32_t ul, uint32_t ur,
|
||||
uint32_t ll, uint32_t lr, int ystop, int xstop){
|
||||
if(!notcurses_canutf8(ncplane_notcurses(n))){
|
||||
logerror(ncplane_notcurses(n), "Highdef gradients require UTF8\n");
|
||||
logerror("Highdef gradients require UTF8\n");
|
||||
return -1;
|
||||
}
|
||||
if(check_gradient_channel_args(ul, ur, ll, lr)){
|
||||
logerror(ncplane_notcurses(n), "Invalid highdef gradient channels\n");
|
||||
logerror("Invalid highdef gradient channels\n");
|
||||
return -1;
|
||||
}
|
||||
int yoff, xoff, ymax, xmax;
|
||||
@ -208,7 +208,7 @@ int ncplane_gradient(ncplane* n, const char* egc, uint32_t stylemask,
|
||||
uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br,
|
||||
int ystop, int xstop){
|
||||
if(check_gradient_args(ul, ur, bl, br)){
|
||||
logerror(ncplane_notcurses(n), "Illegal gradient inputs\n");
|
||||
logerror("Illegal gradient inputs\n");
|
||||
return -1;
|
||||
}
|
||||
if(egc == NULL){
|
||||
@ -218,11 +218,11 @@ int ncplane_gradient(ncplane* n, const char* egc, uint32_t stylemask,
|
||||
ncplane_cursor_yx(n, &yoff, &xoff);
|
||||
// must be at least 1x1, with its upper-left corner at the current cursor
|
||||
if(ystop < yoff){
|
||||
logerror(ncplane_notcurses(n), "Ystop %d < yoff %d\n", ystop, yoff);
|
||||
logerror("Ystop %d < yoff %d\n", ystop, yoff);
|
||||
return -1;
|
||||
}
|
||||
if(xstop < xoff){
|
||||
logerror(ncplane_notcurses(n), "Xstop %d < xoff %d\n", xstop, xoff);
|
||||
logerror("Xstop %d < xoff %d\n", xstop, xoff);
|
||||
return -1;
|
||||
}
|
||||
ncplane_dim_yx(n, &ymax, &xmax);
|
||||
@ -268,18 +268,18 @@ int ncplane_stain(ncplane* n, int ystop, int xstop,
|
||||
uint64_t tl, uint64_t tr, uint64_t bl, uint64_t br){
|
||||
// Can't use default or palette-indexed colors in a gradient
|
||||
if(check_gradient_args(tl, tr, bl, br)){
|
||||
logerror(ncplane_notcurses(n), "Illegal staining inputs\n");
|
||||
logerror("Illegal staining inputs\n");
|
||||
return -1;
|
||||
}
|
||||
int yoff, xoff, ymax, xmax;
|
||||
ncplane_cursor_yx(n, &yoff, &xoff);
|
||||
// must be at least 1x1, with its upper-left corner at the current cursor
|
||||
if(ystop < yoff){
|
||||
logerror(ncplane_notcurses(n), "Ystop %d < yoff %d\n", ystop, yoff);
|
||||
logerror("Ystop %d < yoff %d\n", ystop, yoff);
|
||||
return -1;
|
||||
}
|
||||
if(xstop < xoff){
|
||||
logerror(ncplane_notcurses(n), "Xstop %d < xoff %d\n", xstop, xoff);
|
||||
logerror("Xstop %d < xoff %d\n", xstop, xoff);
|
||||
return -1;
|
||||
}
|
||||
ncplane_dim_yx(n, &ymax, &xmax);
|
||||
@ -346,7 +346,7 @@ rotate_channels(ncplane* src, const nccell* c, uint32_t* fchan, uint32_t* bchan)
|
||||
*bchan = *fchan;
|
||||
return 0;
|
||||
}
|
||||
logerror(ncplane_notcurses(src), "Invalid EGC for rotation [%s]\n", egc);
|
||||
logerror("Invalid EGC for rotation [%s]\n", egc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -48,12 +48,12 @@ int notcurses_linesigs_disable(notcurses* n){
|
||||
}
|
||||
struct termios tios;
|
||||
if(tcgetattr(n->ttyfd, &tios)){
|
||||
logerror(n, "Couldn't preserve terminal state for %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
logerror("Couldn't preserve terminal state for %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
tios.c_lflag &= ~ISIG;
|
||||
if(tcsetattr(n->ttyfd, TCSANOW, &tios)){
|
||||
logerror(n, "Error disabling signals on %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
logerror("Error disabling signals on %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -67,12 +67,12 @@ int notcurses_linesigs_enable(notcurses* n){
|
||||
}
|
||||
struct termios tios;
|
||||
if(tcgetattr(n->ttyfd, &tios)){
|
||||
logerror(n, "Couldn't preserve terminal state for %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
logerror("Couldn't preserve terminal state for %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
tios.c_lflag |= ~ISIG;
|
||||
if(tcsetattr(n->ttyfd, TCSANOW, &tios)){
|
||||
logerror(n, "Error disabling signals on %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
logerror("Error disabling signals on %d (%s)\n", n->ttyfd, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -1109,7 +1109,7 @@ int ncinputlayer_init(tinfo* tcache, FILE* infp, queried_terminals_e* detected){
|
||||
setbuffer(infp, NULL, 0);
|
||||
nilayer->inputescapes = NULL;
|
||||
nilayer->infd = fileno(infp);
|
||||
nilayer->ttyfd = isatty(nilayer->infd) ? -1 : get_tty_fd(NULL, infp);
|
||||
nilayer->ttyfd = isatty(nilayer->infd) ? -1 : get_tty_fd(infp);
|
||||
if(prep_special_keys(nilayer)){
|
||||
return -1;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ void update_write_stats(const struct timespec* time1, const struct timespec* tim
|
||||
|
||||
void sigwinch_handler(int signo);
|
||||
|
||||
void init_lang(notcurses* nc); // nc may be NULL, only used for logging
|
||||
void init_lang(void);
|
||||
|
||||
// load |ti| from the terminfo database, which must already have been
|
||||
// initialized. set |utf8| if we've verified UTF8 output encoding.
|
||||
@ -1196,37 +1196,37 @@ void nclog(const char* fmt, ...);
|
||||
bool is_linux_console(const notcurses* nc, unsigned no_font_changes);
|
||||
|
||||
// logging
|
||||
#define logerror(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_ERROR){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
}else{ fprintf(stderr, "%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
}while(0);
|
||||
extern int loglevel;
|
||||
|
||||
#define logwarn(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_WARNING){ \
|
||||
#define logerror(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_ERROR){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
}else{ fprintf(stderr, "%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
}while(0);
|
||||
} while(0);
|
||||
|
||||
#define loginfo(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_INFO){ \
|
||||
#define logwarn(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_WARNING){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
} }while(0);
|
||||
} while(0);
|
||||
|
||||
#define logverbose(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_VERBOSE){ \
|
||||
#define loginfo(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_INFO){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
} }while(0);
|
||||
} while(0);
|
||||
|
||||
#define logdebug(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_DEBUG){ \
|
||||
#define logverbose(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_VERBOSE){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
} }while(0);
|
||||
} while(0);
|
||||
|
||||
#define logtrace(nc, fmt, ...) do{ \
|
||||
if(nc){ if((nc)->loglevel >= NCLOGLEVEL_TRACE){ \
|
||||
#define logdebug(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_DEBUG){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
} }while(0);
|
||||
} while(0);
|
||||
|
||||
#define logtrace(fmt, ...) do{ \
|
||||
if(loglevel >= NCLOGLEVEL_TRACE){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
|
||||
} while(0);
|
||||
|
||||
int term_setstyle(FILE* out, unsigned cur, unsigned targ, unsigned stylebit,
|
||||
const char* ton, const char* toff);
|
||||
@ -1509,7 +1509,7 @@ int cbreak_mode(int ttyfd, const struct termios* tpreserved);
|
||||
|
||||
int set_fd_nonblocking(int fd, unsigned state, unsigned* oldstate);
|
||||
|
||||
int get_tty_fd(notcurses* nc, FILE* ttyfp);
|
||||
int get_tty_fd(FILE* ttyfp);
|
||||
|
||||
// Given the four channels arguments, verify that:
|
||||
//
|
||||
|
@ -65,7 +65,7 @@ puttext_line(ncplane* n, ncalign_e align, const char* text, size_t* bytes){
|
||||
wchar_t w;
|
||||
const size_t consumed = mbrtowc(&w, text + b, MB_CUR_MAX, &mbstate);
|
||||
if(consumed == (size_t)-2 || consumed == (size_t)-1){
|
||||
logerror(ncplane_notcurses(n), "Invalid UTF-8 after %d bytes\n", b);
|
||||
logerror("Invalid UTF-8 after %d bytes\n", b);
|
||||
return -1;
|
||||
}
|
||||
//fprintf(stderr, "converted [%s] -> %lc\n", text + b, w);
|
||||
|
@ -314,8 +314,8 @@ shim_lower_eighth(struct consolefontdesc* cfd, unsigned idx){
|
||||
|
||||
// add UCS2 codepoint |w| to |map| for font idx |fidx|
|
||||
static int
|
||||
add_to_map(const notcurses* nc, struct unimapdesc* map, wchar_t w, unsigned fidx){
|
||||
logdebug(nc, "Adding mapping U+%04x -> %03u\n", w, fidx);
|
||||
add_to_map(struct unimapdesc* map, wchar_t w, unsigned fidx){
|
||||
logdebug("Adding mapping U+%04x -> %03u\n", w, fidx);
|
||||
struct unipair* tmp = realloc(map->entries, sizeof(*map->entries) * (map->entry_ct + 1));
|
||||
if(tmp == NULL){
|
||||
return -1;
|
||||
@ -373,7 +373,7 @@ program_line_drawing_chars(const notcurses* nc, struct unimapdesc* map){
|
||||
for(unsigned idx = 0 ; idx < map->entry_ct ; ++idx){
|
||||
for(size_t widx = 0 ; widx < wcslen(s->ws) ; ++widx){
|
||||
if(map->entries[idx].unicode == s->ws[widx]){
|
||||
logtrace(nc, "Found desired character U+%04x -> %03u\n",
|
||||
logtrace("Found desired character U+%04x -> %03u\n",
|
||||
map->entries[idx].unicode, map->entries[idx].fontpos);
|
||||
found[widx] = true;
|
||||
if(fontidx == -1){
|
||||
@ -385,24 +385,24 @@ program_line_drawing_chars(const notcurses* nc, struct unimapdesc* map){
|
||||
if(fontidx > -1){
|
||||
for(size_t widx = 0 ; widx < wcslen(s->ws) ; ++widx){
|
||||
if(!found[widx]){
|
||||
if(add_to_map(nc, map, s->ws[widx], fontidx)){
|
||||
if(add_to_map(map, s->ws[widx], fontidx)){
|
||||
return -1;
|
||||
}
|
||||
++toadd;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
logwarn(nc, "Couldn't find any glyphs for set %zu\n", sidx);
|
||||
logwarn("Couldn't find any glyphs for set %zu\n", sidx);
|
||||
}
|
||||
}
|
||||
if(toadd == 0){
|
||||
return 0;
|
||||
}
|
||||
if(ioctl(nc->ttyfd, PIO_UNIMAP, map)){
|
||||
logwarn(nc, "Error setting kernel unicode map (%s)\n", strerror(errno));
|
||||
logwarn("Error setting kernel unicode map (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo(nc, "Successfully added %d kernel unicode mapping%s\n",
|
||||
loginfo("Successfully added %d kernel unicode mapping%s\n",
|
||||
toadd, toadd == 1 ? "" : "s");
|
||||
return 0;
|
||||
}
|
||||
@ -441,7 +441,7 @@ program_block_drawing_chars(const notcurses* nc, struct consolefontdesc* cfd,
|
||||
if(map->entries[i].unicode >= 0x2580 && map->entries[i].unicode <= 0x259f){
|
||||
for(size_t s = 0 ; s < sizeof(shimmers) / sizeof(*shimmers) ; ++s){
|
||||
if(map->entries[i].unicode == shimmers[s].w){
|
||||
logdebug(nc, "Found %lc at fontidx %u\n", shimmers[s].w, i);
|
||||
logdebug("Found %lc at fontidx %u\n", shimmers[s].w, i);
|
||||
shimmers[s].found = true;
|
||||
break;
|
||||
}
|
||||
@ -458,29 +458,28 @@ program_block_drawing_chars(const notcurses* nc, struct consolefontdesc* cfd,
|
||||
}
|
||||
}
|
||||
if(candidate == 0){
|
||||
logwarn(nc, "Ran out of replaceable glyphs for U+%04lx\n", (long)shimmers[s].w);
|
||||
logwarn("Ran out of replaceable glyphs for U+%04lx\n", (long)shimmers[s].w);
|
||||
return -1;
|
||||
}
|
||||
if(shimmers[s].glyphfxn(cfd, candidate)){
|
||||
logwarn(nc, "Error replacing glyph for U+%04lx at %u\n", (long)shimmers[s].w, candidate);
|
||||
logwarn("Error replacing glyph for U+%04lx at %u\n", (long)shimmers[s].w, candidate);
|
||||
return -1;
|
||||
}
|
||||
if(add_to_map(nc, map, shimmers[s].w, candidate)){
|
||||
if(add_to_map(map, shimmers[s].w, candidate)){
|
||||
return -1;
|
||||
}
|
||||
++added;
|
||||
}
|
||||
}
|
||||
if(ioctl(nc->ttyfd, PIO_FONTX, cfd)){
|
||||
logwarn(nc, "Error programming kernel font (%s)\n", strerror(errno));
|
||||
logwarn("Error programming kernel font (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if(ioctl(nc->ttyfd, PIO_UNIMAP, map)){
|
||||
logwarn(nc, "Error setting kernel unicode map (%s)\n", strerror(errno));
|
||||
logwarn("Error setting kernel unicode map (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo(nc, "Successfully added %d kernel font glyph%s\n",
|
||||
added, added == 1 ? "" : "s");
|
||||
loginfo("Successfully added %d kernel font glyph%s\n", added, added == 1 ? "" : "s");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -488,20 +487,20 @@ static int
|
||||
reprogram_linux_font(const notcurses* nc, struct consolefontdesc* cfd,
|
||||
struct unimapdesc* map){
|
||||
if(ioctl(nc->ttyfd, GIO_FONTX, cfd)){
|
||||
logwarn(nc, "Error reading Linux kernelfont (%s)\n", strerror(errno));
|
||||
logwarn("Error reading Linux kernelfont (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo(nc, "Kernel font size (glyphcount): %hu\n", cfd->charcount);
|
||||
loginfo(nc, "Kernel font character geometry: 8x%hu\n", cfd->charheight);
|
||||
loginfo("Kernel font size (glyphcount): %hu\n", cfd->charcount);
|
||||
loginfo("Kernel font character geometry: 8x%hu\n", cfd->charheight);
|
||||
if(cfd->charcount > 512){
|
||||
logwarn(nc, "Warning: kernel returned excess charcount\n");
|
||||
logwarn("Warning: kernel returned excess charcount\n");
|
||||
return -1;
|
||||
}
|
||||
if(ioctl(nc->ttyfd, GIO_UNIMAP, map)){
|
||||
logwarn(nc, "Error reading Linux unimap (%s)\n", strerror(errno));
|
||||
logwarn("Error reading Linux unimap (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
loginfo(nc, "Kernel Unimap size: %hu/%hu\n", map->entry_ct, USHRT_MAX);
|
||||
loginfo("Kernel Unimap size: %hu/%hu\n", map->entry_ct, USHRT_MAX);
|
||||
// for certain sets of characters, we're not going to draw them in, but we
|
||||
// do want to ensure they map to something plausible...
|
||||
if(program_line_drawing_chars(nc, map)){
|
||||
@ -520,7 +519,7 @@ reprogram_console_font(const notcurses* nc){
|
||||
size_t totsize = 32 * cfd.charcount;
|
||||
cfd.chardata = malloc(totsize);
|
||||
if(cfd.chardata == NULL){
|
||||
logwarn(nc, "Error acquiring %zub for font descriptors (%s)\n", totsize, strerror(errno));
|
||||
logwarn("Error acquiring %zub for font descriptors (%s)\n", totsize, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
struct unimapdesc map = {};
|
||||
@ -528,7 +527,7 @@ reprogram_console_font(const notcurses* nc){
|
||||
totsize = map.entry_ct * sizeof(struct unipair);
|
||||
map.entries = malloc(totsize);
|
||||
if(map.entries == NULL){
|
||||
logwarn(nc, "Error acquiring %zub for Unicode font map (%s)\n", totsize, strerror(errno));
|
||||
logwarn("Error acquiring %zub for Unicode font map (%s)\n", totsize, strerror(errno));
|
||||
free(cfd.chardata);
|
||||
return -1;
|
||||
}
|
||||
@ -545,12 +544,12 @@ bool is_linux_console(const notcurses* nc, unsigned no_font_changes){
|
||||
}
|
||||
int mode;
|
||||
if(ioctl(nc->ttyfd, KDGETMODE, &mode)){
|
||||
logdebug(nc, "Not a Linux console, KDGETMODE failed\n");
|
||||
logdebug("Not a Linux console, KDGETMODE failed\n");
|
||||
return false;
|
||||
}
|
||||
loginfo(nc, "Verified Linux console, mode %d\n", mode);
|
||||
loginfo("Verified Linux console, mode %d\n", mode);
|
||||
if(no_font_changes){
|
||||
logdebug(nc, "Not reprogramming the console font due to option\n");
|
||||
logdebug("Not reprogramming the console font due to option\n");
|
||||
return true;
|
||||
}
|
||||
reprogram_console_font(nc);
|
||||
|
@ -344,11 +344,11 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
|
||||
opts = &zeroed;
|
||||
}
|
||||
if(opts->sectioncount <= 0 || !opts->sections){
|
||||
logerror(ncplane_notcurses(n), "Invalid %d-ary section information\n", opts->sectioncount);
|
||||
logerror("Invalid %d-ary section information\n", opts->sectioncount);
|
||||
return NULL;
|
||||
}
|
||||
if(opts->flags >= (NCMENU_OPTION_HIDING << 1u)){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
int totalheight = 1;
|
||||
int totalwidth = 2; // start with two-character margin on the left
|
||||
@ -396,7 +396,7 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
|
||||
}
|
||||
free(ret);
|
||||
}
|
||||
logerror(ncplane_notcurses(n), "Error creating ncmenu\n");
|
||||
logerror("Error creating ncmenu\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ int ncmenu_unroll(ncmenu* n, int sectionidx){
|
||||
return -1;
|
||||
}
|
||||
if(sectionidx < 0 || sectionidx >= n->sectioncount){
|
||||
logerror(ncplane_notcurses(n->ncp), "Unrolled invalid sectionidx %d\n", sectionidx);
|
||||
logerror("Unrolled invalid sectionidx %d\n", sectionidx);
|
||||
return -1;
|
||||
}
|
||||
if(n->sections[sectionidx].enabled_item_count <= 0){
|
||||
|
@ -370,22 +370,22 @@ make_ncpile(notcurses* nc, ncplane* n){
|
||||
ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
|
||||
const ncplane_options* nopts){
|
||||
if(nopts->flags >= (NCPLANE_OPTION_MARGINALIZED << 1u)){
|
||||
logwarn(nc, "Provided unsupported flags %016jx\n", (uintmax_t)nopts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)nopts->flags);
|
||||
}
|
||||
if(nopts->flags & NCPLANE_OPTION_HORALIGNED || nopts->flags & NCPLANE_OPTION_VERALIGNED){
|
||||
if(n == NULL){
|
||||
logerror(nc, "Alignment requires a parent plane\n");
|
||||
logerror("Alignment requires a parent plane\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){
|
||||
if(nopts->rows != 0 || nopts->cols != 0){
|
||||
logerror(nc, "Geometry specified with margins (r=%d, c=%d)\n",
|
||||
logerror("Geometry specified with margins (r=%d, c=%d)\n",
|
||||
nopts->rows, nopts->cols);
|
||||
return NULL;
|
||||
}
|
||||
}else if(nopts->rows <= 0 || nopts->cols <= 0){
|
||||
logerror(nc, "Won't create denormalized plane (r=%d, c=%d)\n",
|
||||
logerror("Won't create denormalized plane (r=%d, c=%d)\n",
|
||||
nopts->rows, nopts->cols);
|
||||
return NULL;
|
||||
}
|
||||
@ -415,7 +415,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
|
||||
}
|
||||
size_t fbsize = sizeof(*p->fb) * (p->leny * p->lenx);
|
||||
if((p->fb = malloc(fbsize)) == NULL){
|
||||
logerror(nc, "Error allocating cellmatrix (r=%d, c=%d)\n",
|
||||
logerror("Error allocating cellmatrix (r=%d, c=%d)\n",
|
||||
p->leny, p->lenx);
|
||||
free(p);
|
||||
return NULL;
|
||||
@ -488,7 +488,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
|
||||
pthread_mutex_unlock(&nc->statlock);
|
||||
pthread_mutex_unlock(&nc->pilelock);
|
||||
}
|
||||
loginfo(nc, "Created new %dx%d plane \"%s\" @ %dx%d\n",
|
||||
loginfo("Created new %dx%d plane \"%s\" @ %dx%d\n",
|
||||
p->leny, p->lenx, p->name ? p->name : "", p->absy, p->absx);
|
||||
return p;
|
||||
}
|
||||
@ -547,29 +547,29 @@ void ncplane_home(ncplane* n){
|
||||
|
||||
inline int ncplane_cursor_move_yx(ncplane* n, int y, int x){
|
||||
if(x >= n->lenx){
|
||||
logerror(ncplane_notcurses(n), "Target x %d >= length %d\n", x, n->lenx);
|
||||
logerror("Target x %d >= length %d\n", x, n->lenx);
|
||||
return -1;
|
||||
}else if(x < 0){
|
||||
if(x < -1){
|
||||
logerror(ncplane_notcurses(n), "Negative target x %d\n", x);
|
||||
logerror("Negative target x %d\n", x);
|
||||
return -1;
|
||||
}
|
||||
}else{
|
||||
n->x = x;
|
||||
}
|
||||
if(y >= n->leny){
|
||||
logerror(ncplane_notcurses(n), "Target y %d >= height %d\n", y, n->leny);
|
||||
logerror("Target y %d >= height %d\n", y, n->leny);
|
||||
return -1;
|
||||
}else if(y < 0){
|
||||
if(y < -1){
|
||||
logerror(ncplane_notcurses(n), "Negative target y %d\n", y);
|
||||
logerror("Negative target y %d\n", y);
|
||||
return -1;
|
||||
}
|
||||
}else{
|
||||
n->y = y;
|
||||
}
|
||||
if(cursor_invalid_p(n)){
|
||||
logerror(ncplane_notcurses(n), "Invalid cursor following move (%d/%d)\n", n->y, n->x);
|
||||
logerror("Invalid cursor following move (%d/%d)\n", n->y, n->x);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -630,41 +630,41 @@ int resize_callbacks_children(ncplane* n){
|
||||
int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,
|
||||
int keeplenx, int yoff, int xoff, int ylen, int xlen){
|
||||
if(keepleny < 0 || keeplenx < 0){ // can't retain negative size
|
||||
logerror(ncplane_notcurses_const(n), "Can't retain negative size %dx%d\n", keepleny, keeplenx);
|
||||
logerror("Can't retain negative size %dx%d\n", keepleny, keeplenx);
|
||||
return -1;
|
||||
}
|
||||
if(keepy < 0 || keepx < 0){ // can't start at negative origin
|
||||
logerror(ncplane_notcurses_const(n), "Can't retain negative offset %dx%d\n", keepy, keepx);
|
||||
logerror("Can't retain negative offset %dx%d\n", keepy, keepx);
|
||||
return -1;
|
||||
}
|
||||
if((!keepleny && keeplenx) || (keepleny && !keeplenx)){ // both must be 0
|
||||
logerror(ncplane_notcurses_const(n), "Can't retain null dimension %dx%d\n", keepleny, keeplenx);
|
||||
logerror("Can't retain null dimension %dx%d\n", keepleny, keeplenx);
|
||||
return -1;
|
||||
}
|
||||
// can't be smaller than keep length
|
||||
if(ylen < keepleny){
|
||||
logerror(ncplane_notcurses_const(n), "Can't map in y dimension: %d < %d\n", ylen, keepleny);
|
||||
logerror("Can't map in y dimension: %d < %d\n", ylen, keepleny);
|
||||
return -1;
|
||||
}
|
||||
if(xlen < keeplenx){
|
||||
logerror(ncplane_notcurses_const(n), "Can't map in x dimension: %d < %d\n", xlen, keeplenx);
|
||||
logerror("Can't map in x dimension: %d < %d\n", xlen, keeplenx);
|
||||
return -1;
|
||||
}
|
||||
if(ylen <= 0 || xlen <= 0){ // can't resize to trivial or negative size
|
||||
logerror(ncplane_notcurses_const(n), "Can't achieve meaningless size %dx%d\n", ylen, xlen);
|
||||
logerror("Can't achieve meaningless size %dx%d\n", ylen, xlen);
|
||||
return -1;
|
||||
}
|
||||
int rows, cols;
|
||||
ncplane_dim_yx(n, &rows, &cols);
|
||||
if(keepleny + keepy > rows){
|
||||
logerror(ncplane_notcurses_const(n), "Can't keep %d@%d rows from %d\n", keepleny, keepy, rows);
|
||||
logerror("Can't keep %d@%d rows from %d\n", keepleny, keepy, rows);
|
||||
return -1;
|
||||
}
|
||||
if(keeplenx + keepx > cols){
|
||||
logerror(ncplane_notcurses_const(n), "Can't keep %d@%d cols from %d\n", keeplenx, keepx, cols);
|
||||
logerror("Can't keep %d@%d cols from %d\n", keeplenx, keepx, cols);
|
||||
return -1;
|
||||
}
|
||||
loginfo(ncplane_notcurses_const(n), "%dx%d @ %d/%d → %d/%d @ %d/%d (keeping %dx%d from %d/%d)\n", rows, cols, n->absy, n->absx, ylen, xlen, n->absy + keepy + yoff, n->absx + keepx + xoff, keepleny, keeplenx, keepy, keepx);
|
||||
loginfo("%dx%d @ %d/%d → %d/%d @ %d/%d (keeping %dx%d from %d/%d)\n", rows, cols, n->absy, n->absx, ylen, xlen, n->absy + keepy + yoff, n->absx + keepx + xoff, keepleny, keeplenx, keepy, keepx);
|
||||
if(n->absy == n->absy + keepy && n->absx == n->absx + keepx &&
|
||||
rows == ylen && cols == xlen){
|
||||
return 0;
|
||||
@ -685,7 +685,7 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny,
|
||||
return -1;
|
||||
}
|
||||
if(n->tam){
|
||||
loginfo(ncplane_notcurses_const(n), "TAM realloc to %d entries\n", newarea);
|
||||
loginfo("TAM realloc to %d entries\n", newarea);
|
||||
tament* tmptam = realloc(n->tam, sizeof(*tmptam) * newarea);
|
||||
if(tmptam == NULL){
|
||||
free(fb);
|
||||
@ -780,11 +780,11 @@ int ncplane_destroy(ncplane* ncp){
|
||||
return 0;
|
||||
}
|
||||
if(ncplane_notcurses(ncp)->stdplane == ncp){
|
||||
logerror(ncplane_notcurses(ncp), "Won't destroy standard plane\n");
|
||||
logerror("Won't destroy standard plane\n");
|
||||
return -1;
|
||||
}
|
||||
//notcurses_debug(ncplane_notcurses(ncp), stderr);
|
||||
loginfo(ncplane_notcurses_const(ncp), "Destroying %dx%d plane \"%s\" @ %dx%d\n",
|
||||
loginfo("Destroying %dx%d plane \"%s\" @ %dx%d\n",
|
||||
ncp->leny, ncp->lenx, ncp->name ? ncp->name : NULL, ncp->absy, ncp->absx);
|
||||
int ret = 0;
|
||||
// dissolve our binding from behind (->bprev is either NULL, or its
|
||||
@ -826,7 +826,7 @@ int ncplane_genocide(ncplane *ncp){
|
||||
return 0;
|
||||
}
|
||||
if(ncplane_notcurses(ncp)->stdplane == ncp){
|
||||
logerror(ncplane_notcurses(ncp), "Won't destroy standard plane\n");
|
||||
logerror("Won't destroy standard plane\n");
|
||||
return -1;
|
||||
}
|
||||
int ret = 0;
|
||||
@ -932,7 +932,7 @@ init_banner(const notcurses* nc){
|
||||
// of "C" or "POSIX"). recommended practice is for the client code to have
|
||||
// called setlocale() themselves, and set the NCOPTION_INHIBIT_SETLOCALE flag.
|
||||
// if that flag is set, we take the locale and encoding as we get them.
|
||||
void init_lang(struct notcurses* nc){
|
||||
void init_lang(void){
|
||||
const char* encoding = nl_langinfo(CODESET);
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
return; // already utf-8, great!
|
||||
@ -940,19 +940,19 @@ void init_lang(struct notcurses* nc){
|
||||
const char* lang = getenv("LANG");
|
||||
// if LANG was explicitly set to C/POSIX, life sucks, roll with it
|
||||
if(lang && (!strcmp(lang, "C") || !strcmp(lang, "POSIX"))){
|
||||
loginfo(nc, "LANG was explicitly set to %s, not changing locale\n", lang);
|
||||
loginfo("LANG was explicitly set to %s, not changing locale\n", lang);
|
||||
return;
|
||||
}
|
||||
setlocale(LC_ALL, "");
|
||||
encoding = nl_langinfo(CODESET);
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
loginfo(nc, "Set locale from LANG; client should call setlocale(2)!\n");
|
||||
loginfo("Set locale from LANG; client should call setlocale(2)!\n");
|
||||
return;
|
||||
}
|
||||
setlocale(LC_CTYPE, "C.UTF-8");
|
||||
encoding = nl_langinfo(CODESET);
|
||||
if(encoding && !strcmp(encoding, "UTF-8")){
|
||||
loginfo(nc, "Forced UTF-8 encoding; client should call setlocale(2)!\n");
|
||||
loginfo("Forced UTF-8 encoding; client should call setlocale(2)!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1010,7 +1010,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
ret->rstate.mstreamfp = NULL;
|
||||
ret->loglevel = opts->loglevel;
|
||||
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
||||
init_lang(ret);
|
||||
init_lang();
|
||||
}
|
||||
const char* encoding = nl_langinfo(CODESET);
|
||||
bool utf8;
|
||||
@ -1049,7 +1049,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->ttyfd = get_tty_fd(ret, ret->ttyfp);
|
||||
ret->ttyfd = get_tty_fd(ret->ttyfp);
|
||||
is_linux_console(ret, !!(opts->flags & NCOPTION_NO_FONT_CHANGES));
|
||||
if(ret->ttyfd < 0){
|
||||
fprintf(stderr, "Defaulting to %dx%d (output is not to a terminal)\n", DEFAULT_ROWS, DEFAULT_COLS);
|
||||
@ -1072,6 +1072,9 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
// don't set loglevel until we've acquired the signal handler, lest we
|
||||
// change the loglevel out from under a running instance
|
||||
loglevel = opts->loglevel;
|
||||
int termerr;
|
||||
if(setupterm(opts->termtype, ret->ttyfd, &termerr) != OK){
|
||||
fprintf(stderr, "Terminfo error %d (see terminfo(3ncurses))\n", termerr);
|
||||
@ -1506,9 +1509,8 @@ int cell_load(ncplane* n, nccell* c, const char* gcluster){
|
||||
static inline int
|
||||
ncplane_put(ncplane* n, int y, int x, const char* egc, int cols,
|
||||
uint16_t stylemask, uint64_t channels, int bytes){
|
||||
const notcurses* nc = ncplane_notcurses_const(n);
|
||||
if(n->sprite){
|
||||
logerror(nc, "Can't write glyphs (%s) to sprixelated plane\n", egc);
|
||||
logerror("Can't write glyphs (%s) to sprixelated plane\n", egc);
|
||||
return -1;
|
||||
}
|
||||
// FIXME reject any control or space characters here--should be iswgraph()
|
||||
@ -1517,13 +1519,13 @@ ncplane_put(ncplane* n, int y, int x, const char* egc, int cols,
|
||||
// specified, we must always try to print at exactly that location.
|
||||
if(x != -1){
|
||||
if(x + cols > n->lenx){
|
||||
logerror(nc, "Target x %d + %d cols >= length %d\n", x, cols, n->lenx);
|
||||
logerror("Target x %d + %d cols >= length %d\n", x, cols, n->lenx);
|
||||
ncplane_cursor_move_yx(n, y, x); // update cursor, though
|
||||
return -1;
|
||||
}
|
||||
}else if(y == -1 && n->x + cols > n->lenx){
|
||||
if(!n->scrolling){
|
||||
logerror(nc, "No room to output [%.*s] %d/%d\n", bytes, egc, n->y, n->x);
|
||||
logerror("No room to output [%.*s] %d/%d\n", bytes, egc, n->y, n->x);
|
||||
return -1;
|
||||
}
|
||||
scroll_down(n);
|
||||
@ -1864,17 +1866,17 @@ int ncplane_box(ncplane* n, const nccell* ul, const nccell* ur,
|
||||
ncplane_cursor_yx(n, &yoff, &xoff);
|
||||
// must be at least 2x2, with its upper-left corner at the current cursor
|
||||
if(ystop < yoff + 1){
|
||||
logerror(ncplane_notcurses(n), "ystop (%d) insufficient for yoff (%d)\n", ystop, yoff);
|
||||
logerror("ystop (%d) insufficient for yoff (%d)\n", ystop, yoff);
|
||||
return -1;
|
||||
}
|
||||
if(xstop < xoff + 1){
|
||||
logerror(ncplane_notcurses(n), "xstop (%d) insufficient for xoff (%d)\n", xstop, xoff);
|
||||
logerror("xstop (%d) insufficient for xoff (%d)\n", xstop, xoff);
|
||||
return -1;
|
||||
}
|
||||
ncplane_dim_yx(n, &ymax, &xmax);
|
||||
// must be within the ncplane
|
||||
if(xstop >= xmax || ystop >= ymax){
|
||||
logerror(ncplane_notcurses(n), "Boundary (%dx%d) beyond plane (%dx%d)\n", ystop, xstop, ymax, xmax);
|
||||
logerror("Boundary (%dx%d) beyond plane (%dx%d)\n", ystop, xstop, ymax, xmax);
|
||||
return -1;
|
||||
}
|
||||
unsigned edges;
|
||||
@ -2061,24 +2063,23 @@ void ncplane_erase(ncplane* n){
|
||||
}
|
||||
|
||||
int ncplane_erase_region(ncplane* n, int ystart, int xstart, int ylen, int xlen){
|
||||
const notcurses* nc = ncplane_notcurses_const(n);
|
||||
if(ylen < 0 || xlen < 0){
|
||||
logerror(nc, "Won't erase section of negative length (%d, %d)\n", ylen, xlen);
|
||||
logerror("Won't erase section of negative length (%d, %d)\n", ylen, xlen);
|
||||
return -1;
|
||||
}
|
||||
if(ystart < 0 || xstart < 0){
|
||||
logerror(nc, "Illegal start of erase (%d, %d)\n", ystart, xstart);
|
||||
logerror("Illegal start of erase (%d, %d)\n", ystart, xstart);
|
||||
return -1;
|
||||
}
|
||||
if(ystart >= ncplane_dim_y(n) || ystart + ylen > ncplane_dim_y(n)){
|
||||
logerror(nc, "Illegal y spec for erase (%d, %d)\n", ystart, ylen);
|
||||
logerror("Illegal y spec for erase (%d, %d)\n", ystart, ylen);
|
||||
return -1;
|
||||
}
|
||||
if(ylen == 0){
|
||||
ylen = ncplane_dim_y(n) - ystart;
|
||||
}
|
||||
if(xstart >= ncplane_dim_x(n) || xstart + xlen > ncplane_dim_x(n)){
|
||||
logerror(nc, "Illegal x spec for erase (%d, %d)\n", xstart, xlen);
|
||||
logerror("Illegal x spec for erase (%d, %d)\n", xstart, xlen);
|
||||
return -1;
|
||||
}
|
||||
if(xlen == 0){
|
||||
@ -2322,14 +2323,13 @@ int ncplane_resize_maximize(ncplane* n){
|
||||
}
|
||||
|
||||
int ncplane_resize_realign(ncplane* n){
|
||||
const notcurses* nc = ncplane_notcurses_const(n);
|
||||
const ncplane* parent = ncplane_parent_const(n);
|
||||
if(parent == n){
|
||||
logerror(nc, "Can't realign a root plane\n");
|
||||
logerror("Can't realign a root plane\n");
|
||||
return 0;
|
||||
}
|
||||
if(n->halign == NCALIGN_UNALIGNED && n->valign == NCALIGN_UNALIGNED){
|
||||
logerror(nc, "Passed a non-aligned plane\n");
|
||||
logerror("Passed a non-aligned plane\n");
|
||||
return -1;
|
||||
}
|
||||
int xpos = ncplane_x(n);
|
||||
@ -2352,11 +2352,11 @@ int ncplane_resize_realign(ncplane* n){
|
||||
ncplane* ncplane_reparent(ncplane* n, ncplane* newparent){
|
||||
const notcurses* nc = ncplane_notcurses_const(n);
|
||||
if(n == nc->stdplane){
|
||||
logerror(nc, "Won't reparent standard plane\n");
|
||||
logerror("Won't reparent standard plane\n");
|
||||
return NULL; // can't reparent standard plane
|
||||
}
|
||||
if(n->boundto == newparent){
|
||||
loginfo(nc, "Won't reparent plane to itself\n");
|
||||
loginfo("Won't reparent plane to itself\n");
|
||||
return n;
|
||||
}
|
||||
//notcurses_debug(ncplane_notcurses(n), stderr);
|
||||
@ -2651,11 +2651,11 @@ ncplane_as_rgba_internal(const ncplane* nc, ncblitter_e blit,
|
||||
int* pxdimy, int* pxdimx){
|
||||
const notcurses* ncur = ncplane_notcurses_const(nc);
|
||||
if(begy < 0 || begx < 0){
|
||||
logerror(ncur, "Nil offset (%d,%d)\n", begy, begx);
|
||||
logerror("Nil offset (%d,%d)\n", begy, begx);
|
||||
return NULL;
|
||||
}
|
||||
if(begx >= nc->lenx || begy >= nc->leny){
|
||||
logerror(ncur, "Invalid offset (%d,%d)\n", begy, begx);
|
||||
logerror("Invalid offset (%d,%d)\n", begy, begx);
|
||||
return NULL;
|
||||
}
|
||||
if(lenx == -1){ // -1 means "to the end"; use all space available
|
||||
@ -2665,26 +2665,26 @@ ncplane_as_rgba_internal(const ncplane* nc, ncblitter_e blit,
|
||||
leny = nc->leny - begy;
|
||||
}
|
||||
if(lenx <= 0 || leny <= 0){ // no need to draw zero-size object, exit
|
||||
logerror(ncur, "Nil geometry (%dx%d)\n", leny, lenx);
|
||||
logerror("Nil geometry (%dx%d)\n", leny, lenx);
|
||||
return NULL;
|
||||
}
|
||||
//fprintf(stderr, "sum: %d/%d avail: %d/%d\n", begy + leny, begx + lenx, nc->leny, nc->lenx);
|
||||
if(begx + lenx > nc->lenx || begy + leny > nc->leny){
|
||||
logerror(ncur, "Invalid specs %d + %d > %d or %d + %d > %d\n",
|
||||
logerror("Invalid specs %d + %d > %d or %d + %d > %d\n",
|
||||
begx, lenx, nc->lenx, begy, leny, nc->leny);
|
||||
return NULL;
|
||||
}
|
||||
if(blit == NCBLIT_PIXEL){ // FIXME extend this to support sprixels
|
||||
logerror(ncur, "Pixel blitter %d not yet supported\n", blit);
|
||||
logerror("Pixel blitter %d not yet supported\n", blit);
|
||||
return NULL;
|
||||
}
|
||||
if(blit == NCBLIT_DEFAULT){
|
||||
logerror(ncur, "Must specify exact blitter, not NCBLIT_DEFAULT\n");
|
||||
logerror("Must specify exact blitter, not NCBLIT_DEFAULT\n");
|
||||
return NULL;
|
||||
}
|
||||
const struct blitset* bset = lookup_blitset(&ncur->tcache, blit, false);
|
||||
if(bset == NULL){
|
||||
logerror(ncur, "Blitter %d invalid in current environment\n", blit);
|
||||
logerror("Blitter %d invalid in current environment\n", blit);
|
||||
return NULL;
|
||||
}
|
||||
//fprintf(stderr, "ALLOCATING %u %d %d %p\n", 4u * lenx * leny * 2, leny, lenx, bset);
|
||||
@ -2766,11 +2766,11 @@ uint32_t* ncplane_as_rgba(const ncplane* nc, ncblitter_e blit,
|
||||
// return a heap-allocated copy of the contents
|
||||
char* ncplane_contents(ncplane* nc, int begy, int begx, int leny, int lenx){
|
||||
if(begy < 0 || begx < 0){
|
||||
logerror(ncplane_notcurses_const(nc), "Beginning coordinates (%d/%d) below 0\n", begy, begx);
|
||||
logerror("Beginning coordinates (%d/%d) below 0\n", begy, begx);
|
||||
return NULL;
|
||||
}
|
||||
if(begx >= nc->lenx || begy >= nc->leny){
|
||||
logerror(ncplane_notcurses_const(nc), "Beginning coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
logerror("Beginning coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
begy, begx, nc->leny, nc->lenx);
|
||||
return NULL;
|
||||
}
|
||||
@ -2781,11 +2781,11 @@ char* ncplane_contents(ncplane* nc, int begy, int begx, int leny, int lenx){
|
||||
leny = nc->leny - begy;
|
||||
}
|
||||
if(lenx < 0 || leny < 0){ // no need to draw zero-size object, exit
|
||||
logerror(ncplane_notcurses_const(nc), "Lengths (%d/%d) below 0\n", leny, lenx);
|
||||
logerror("Lengths (%d/%d) below 0\n", leny, lenx);
|
||||
return NULL;
|
||||
}
|
||||
if(begx + lenx > nc->lenx || begy + leny > nc->leny){
|
||||
logerror(ncplane_notcurses_const(nc), "Ending coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
logerror("Ending coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
begy + leny, begx + lenx, nc->leny, nc->lenx);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -219,16 +219,15 @@ create_##T(nc##X##plot* ncpp, ncplane* n, const ncplot_options* opts, const T mi
|
||||
opts = &zeroed; \
|
||||
} \
|
||||
if(opts->flags >= (NCPLOT_OPTION_PRINTSAMPLE << 1u)){ \
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags); \
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags); \
|
||||
} \
|
||||
const notcurses* nc = ncplane_notcurses_const(n); \
|
||||
/* if miny == maxy (enabling domain detection), they both must be equal to 0 */ \
|
||||
if(miny == maxy && miny){ \
|
||||
ncplane_destroy(n); \
|
||||
return false; \
|
||||
} \
|
||||
if(opts->rangex < 0){ \
|
||||
logerror(nc, "Supplied negative independent range %d\n", opts->rangex); \
|
||||
logerror("Supplied negative independent range %d\n", opts->rangex); \
|
||||
ncplane_destroy(n); \
|
||||
return false; \
|
||||
} \
|
||||
@ -238,7 +237,7 @@ create_##T(nc##X##plot* ncpp, ncplane* n, const ncplot_options* opts, const T mi
|
||||
} \
|
||||
/* DETECTMAXONLY can't be used without domain detection */ \
|
||||
if(opts->flags & NCPLOT_OPTION_DETECTMAXONLY && (miny != maxy)){ \
|
||||
logerror(nc, "Supplied DETECTMAXONLY without domain detection"); \
|
||||
logerror("Supplied DETECTMAXONLY without domain detection"); \
|
||||
ncplane_destroy(n); \
|
||||
return false; \
|
||||
} \
|
||||
|
@ -8,7 +8,7 @@ ncprogbar* ncprogbar_create(ncplane* n, const ncprogbar_options* opts){
|
||||
opts = &default_opts;
|
||||
}
|
||||
if(opts->flags > (NCPROGBAR_OPTION_RETROGRADE << 1u)){
|
||||
logwarn(ncplane_notcurses(n), "Invalid flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Invalid flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
ncprogbar* ret = malloc(sizeof(*ret));
|
||||
if(ret){
|
||||
@ -169,7 +169,7 @@ progbar_redraw(ncprogbar* n){
|
||||
int ncprogbar_set_progress(ncprogbar* n, double p){
|
||||
//fprintf(stderr, "PROGRESS: %g\n", p);
|
||||
if(p < 0 || p > 1){
|
||||
logerror(ncplane_notcurses(ncprogbar_plane(n)), "Invalid progress %g\n", p);
|
||||
logerror("Invalid progress %g\n", p);
|
||||
return -1;
|
||||
}
|
||||
n->progress = p;
|
||||
|
@ -6,7 +6,7 @@ ncreader* ncreader_create(ncplane* n, const ncreader_options* opts){
|
||||
opts = &zeroed;
|
||||
}
|
||||
if(opts->flags > NCREADER_OPTION_CURSOR){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
ncreader* nr = malloc(sizeof(*nr));
|
||||
if(nr == NULL){
|
||||
@ -187,7 +187,7 @@ int ncreader_move_down(ncreader* n){
|
||||
int ncreader_write_egc(ncreader* n, const char* egc){
|
||||
const int cols = ncstrwidth(egc);
|
||||
if(cols < 0){
|
||||
logerror(ncplane_notcurses(n->ncp), "Fed illegal UTF-8 [%s]\n", egc);
|
||||
logerror("Fed illegal UTF-8 [%s]\n", egc);
|
||||
return -1;
|
||||
}
|
||||
if(n->textarea->x >= n->textarea->lenx - cols){
|
||||
|
@ -298,7 +298,7 @@ ncreel_draw_tablet(const ncreel* nr, nctablet* t, int frontiertop,
|
||||
int ll = t->cbfxn(t, direction == DIRECTION_DOWN);
|
||||
//fprintf(stderr, "RETURNRETURNRETURN %p %d (%d, %d, %d) DIR %d\n", t, ll, cby, cbleny, leny, direction);
|
||||
if(ll > cbleny){
|
||||
logwarn(ncplane_notcurses(nr->p), "Tablet callback returned %d lines, %d allowed\n", ll, cbleny);
|
||||
logwarn("Tablet callback returned %d lines, %d allowed\n", ll, cbleny);
|
||||
ll = cbleny;
|
||||
}
|
||||
if(ll != cbleny){
|
||||
@ -669,7 +669,7 @@ int ncreel_redraw(ncreel* nr){
|
||||
if(focused){
|
||||
//fprintf(stderr, "drawing focused tablet %p dir: %d fulcrum: %d!\n", focused, nr->direction, fulcrum);
|
||||
if(ncreel_draw_tablet(nr, focused, fulcrum, fulcrum, DIRECTION_DOWN)){
|
||||
logerror(ncplane_notcurses(nr->p), "Error drawing tablet\n");
|
||||
logerror("Error drawing tablet\n");
|
||||
return -1;
|
||||
}
|
||||
//fprintf(stderr, "drew focused tablet %p -> %p lastdir: %d!\n", focused, focused->p, nr->direction);
|
||||
@ -681,25 +681,25 @@ int ncreel_redraw(ncreel* nr){
|
||||
if(nr->direction == LASTDIRECTION_DOWN){
|
||||
otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
|
||||
if(otherend == NULL){
|
||||
logerror(ncplane_notcurses(nr->p), "Error drawing higher tablets\n");
|
||||
logerror("Error drawing higher tablets\n");
|
||||
return -1;
|
||||
}
|
||||
otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
|
||||
}else{ // DIRECTION_UP
|
||||
otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
|
||||
if(otherend == NULL){
|
||||
logerror(ncplane_notcurses(nr->p), "Error drawing higher tablets\n");
|
||||
logerror("Error drawing higher tablets\n");
|
||||
return -1;
|
||||
}
|
||||
otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
|
||||
}
|
||||
if(otherend == NULL){
|
||||
logerror(ncplane_notcurses(nr->p), "Error drawing following tablets\n");
|
||||
logerror("Error drawing following tablets\n");
|
||||
return -1;
|
||||
}
|
||||
//notcurses_debug(ncplane_notcurses(nr->p), stderr);
|
||||
if(tighten_reel(nr)){
|
||||
logerror(ncplane_notcurses(nr->p), "Error tightening reel\n");
|
||||
logerror("Error tightening reel\n");
|
||||
return -1;
|
||||
}
|
||||
//notcurses_debug(ncplane_notcurses(nr->p), stderr);
|
||||
@ -707,7 +707,7 @@ int ncreel_redraw(ncreel* nr){
|
||||
nr->vft = nr->tablets; // update the visually-focused tablet pointer
|
||||
//fprintf(stderr, "DONE ARRANGING\n");
|
||||
if(draw_ncreel_borders(nr)){
|
||||
logerror(ncplane_notcurses(nr->p), "Error drawing reel borders\n");
|
||||
logerror("Error drawing reel borders\n");
|
||||
return -1; // enforces specified dimensional minima
|
||||
}
|
||||
return 0;
|
||||
@ -718,13 +718,12 @@ validate_ncreel_opts(ncplane* n, const ncreel_options* ropts){
|
||||
if(n == NULL){
|
||||
return false;
|
||||
}
|
||||
const notcurses* nc = ncplane_notcurses_const(n);
|
||||
if(ropts->flags >= (NCREEL_OPTION_CIRCULAR << 1u)){
|
||||
logwarn(nc, "Provided unsupported flags 0x%016jx\n", (uintmax_t)ropts->flags);
|
||||
logwarn("Provided unsupported flags 0x%016jx\n", (uintmax_t)ropts->flags);
|
||||
}
|
||||
if(ropts->flags & NCREEL_OPTION_CIRCULAR){
|
||||
if(!(ropts->flags & NCREEL_OPTION_INFINITESCROLL)){
|
||||
logerror(nc, "Can't set circular without infinitescroll\n");
|
||||
logerror("Can't set circular without infinitescroll\n");
|
||||
return false; // can't set circular without infinitescroll
|
||||
}
|
||||
}
|
||||
@ -734,11 +733,11 @@ validate_ncreel_opts(ncplane* n, const ncreel_options* ropts){
|
||||
NCBOXMASK_TOP |
|
||||
NCBOXMASK_BOTTOM;
|
||||
if(ropts->bordermask > fullmask){
|
||||
logerror(nc, "Bad bordermask: 0x%016x\n", ropts->bordermask);
|
||||
logerror("Bad bordermask: 0x%016x\n", ropts->bordermask);
|
||||
return false;
|
||||
}
|
||||
if(ropts->tabletmask > fullmask){
|
||||
logerror(nc, "Bad tabletmask: 0x%016x\n", ropts->bordermask);
|
||||
logerror("Bad tabletmask: 0x%016x\n", ropts->bordermask);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -787,7 +786,7 @@ nctablet* ncreel_add(ncreel* nr, nctablet* after, nctablet *before,
|
||||
nctablet* t;
|
||||
if(after && before){
|
||||
if(after->next != before || before->prev != after){
|
||||
logerror(ncplane_notcurses(nr->p), "bad before (%p) / after (%p) spec\n", before, after);
|
||||
logerror("bad before (%p) / after (%p) spec\n", before, after);
|
||||
return NULL;
|
||||
}
|
||||
}else if(!after && !before){
|
||||
|
@ -85,7 +85,7 @@ void cell_release(ncplane* n, nccell* c){
|
||||
// Duplicate one cell onto another when they share a plane. Convenience wrapper.
|
||||
int nccell_duplicate(ncplane* n, nccell* targ, const nccell* c){
|
||||
if(cell_duplicate_far(&n->pool, targ, n, c) < 0){
|
||||
logerror(ncplane_notcurses(n), "Failed duplicating cell\n");
|
||||
logerror("Failed duplicating cell\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@ -468,27 +468,27 @@ int ncplane_mergedown(ncplane* restrict src, ncplane* restrict dst,
|
||||
int dsty, int dstx){
|
||||
//fprintf(stderr, "Merging down %d/%d @ %d/%d to %d/%d\n", leny, lenx, begsrcy, begsrcx, dsty, dstx);
|
||||
if(dsty >= dst->leny || dstx >= dst->lenx){
|
||||
logerror(ncplane_notcurses_const(dst), "Dest origin %d/%d ≥ dest dimensions %d/%d\n",
|
||||
logerror("Dest origin %d/%d ≥ dest dimensions %d/%d\n",
|
||||
dsty, dstx, dst->leny, dst->lenx);
|
||||
return -1;
|
||||
}
|
||||
if(dst->leny - leny < dsty || dst->lenx - lenx < dstx){
|
||||
logerror(ncplane_notcurses_const(dst), "Dest len %d/%d ≥ dest dimensions %d/%d\n",
|
||||
logerror("Dest len %d/%d ≥ dest dimensions %d/%d\n",
|
||||
leny, lenx, dst->leny, dst->lenx);
|
||||
return -1;
|
||||
}
|
||||
if(begsrcy >= src->leny || begsrcx >= src->lenx){
|
||||
logerror(ncplane_notcurses_const(dst), "Source origin %d/%d ≥ source dimensions %d/%d\n",
|
||||
logerror("Source origin %d/%d ≥ source dimensions %d/%d\n",
|
||||
begsrcy, begsrcx, src->leny, src->lenx);
|
||||
return -1;
|
||||
}
|
||||
if(src->leny - leny < begsrcy || src->lenx - lenx < begsrcx){
|
||||
logerror(ncplane_notcurses_const(dst), "Source len %d/%d ≥ source dimensions %d/%d\n",
|
||||
logerror("Source len %d/%d ≥ source dimensions %d/%d\n",
|
||||
leny, lenx, src->leny, src->lenx);
|
||||
return -1;
|
||||
}
|
||||
if(src->sprite || dst->sprite){
|
||||
logerror(ncplane_notcurses_const(dst), "Can't merge sprixel planes\n");
|
||||
logerror("Can't merge sprixel planes\n");
|
||||
return -1;
|
||||
}
|
||||
const int totalcells = dst->leny * dst->lenx;
|
||||
@ -496,7 +496,7 @@ int ncplane_mergedown(ncplane* restrict src, ncplane* restrict dst,
|
||||
const size_t crenderlen = sizeof(struct crender) * totalcells;
|
||||
struct crender* rvec = malloc(crenderlen);
|
||||
if(!rendfb || !rvec){
|
||||
logerror(ncplane_notcurses_const(dst), "Error allocating render state for %dx%d\n", leny, lenx);
|
||||
logerror("Error allocating render state for %dx%d\n", leny, lenx);
|
||||
free(rendfb);
|
||||
free(rvec);
|
||||
return -1;
|
||||
@ -1460,11 +1460,11 @@ int notcurses_cursor_yx(notcurses* nc, int* y, int* x){
|
||||
|
||||
int notcurses_cursor_enable(notcurses* nc, int y, int x){
|
||||
if(y < 0 || x < 0){
|
||||
logerror(nc, "Illegal cursor placement: %d, %d\n", y, x);
|
||||
logerror("Illegal cursor placement: %d, %d\n", y, x);
|
||||
return -1;
|
||||
}
|
||||
if(y >= nc->margin_t || x >= nc->margin_l){
|
||||
logerror(nc, "Illegal cursor placement: %d, %d\n", y, x);
|
||||
logerror("Illegal cursor placement: %d, %d\n", y, x);
|
||||
return -1;
|
||||
}
|
||||
// if we're already at the demanded location, we must already be visible, and
|
||||
@ -1496,7 +1496,7 @@ int notcurses_cursor_enable(notcurses* nc, int y, int x){
|
||||
|
||||
int notcurses_cursor_disable(notcurses* nc){
|
||||
if(nc->cursorx < 0 || nc->cursory < 0){
|
||||
logerror(nc, "Cursor is not enabled\n");
|
||||
logerror("Cursor is not enabled\n");
|
||||
return -1;
|
||||
}
|
||||
if(nc->ttyfd >= 0){
|
||||
|
@ -238,7 +238,7 @@ ncselector* ncselector_create(ncplane* n, const ncselector_options* opts){
|
||||
}
|
||||
unsigned itemcount = 0;
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
if(opts->items){
|
||||
for(const struct ncselector_item* i = opts->items ; i->option ; ++i){
|
||||
@ -834,7 +834,7 @@ ncmultiselector* ncmultiselector_create(ncplane* n, const ncmultiselector_option
|
||||
opts = &zeroed;
|
||||
}
|
||||
if(opts->flags > 0){
|
||||
logwarn(ncplane_notcurses(n), "Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
logwarn("Provided unsupported flags %016jx\n", (uintmax_t)opts->flags);
|
||||
}
|
||||
unsigned itemcount = 0;
|
||||
if(opts->items){
|
||||
|
@ -113,7 +113,7 @@ int setup_signals(void* vnc, bool no_quit_sigs, bool no_winch_sig,
|
||||
// don't register ourselves if we don't intend to set up signal handlers
|
||||
// we expect NULL (nothing registered), and want to register nc
|
||||
if(!atomic_compare_exchange_strong(&signal_nc, &expected, nc)){
|
||||
loginfo(nc, "%p is already registered for signals (provided %p)\n", expected, nc);
|
||||
loginfo("%p is already registered for signals (provided %p)\n", expected, nc);
|
||||
return -1;
|
||||
}
|
||||
if(!no_winch_sig){
|
||||
|
@ -71,13 +71,12 @@ void nctabbed_ensure_selected_header_visible(nctabbed* nt){
|
||||
}
|
||||
|
||||
static bool
|
||||
nctabbed_validate_opts(ncplane* n, const nctabbed_options* opts){
|
||||
notcurses* nc = ncplane_notcurses(n);
|
||||
nctabbed_validate_opts(const nctabbed_options* opts){
|
||||
if(opts->flags > NCTABBED_OPTION_BOTTOM){
|
||||
logwarn(nc, "Provided unsupported flags 0x%016jx\n", (uint64_t)opts->flags);
|
||||
logwarn("Provided unsupported flags 0x%016jx\n", (uint64_t)opts->flags);
|
||||
}
|
||||
if(opts->sepchan && !opts->separator){
|
||||
logwarn(nc, "Provided non-zero separator channel when separator is NULL")
|
||||
logwarn("Provided non-zero separator channel when separator is NULL")
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -131,15 +130,14 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
ncplane_options nopts = {};
|
||||
int nrows, ncols;
|
||||
nctabbed* nt;
|
||||
notcurses* nc = ncplane_notcurses(n);
|
||||
if(!topts){
|
||||
topts = &zeroed;
|
||||
}
|
||||
if(!nctabbed_validate_opts(n, topts)){
|
||||
if(!nctabbed_validate_opts(topts)){
|
||||
return NULL;
|
||||
}
|
||||
if((nt = malloc(sizeof(*nt))) == NULL){
|
||||
logerror(nc, "Couldn't allocate nctabbed");
|
||||
logerror("Couldn't allocate nctabbed");
|
||||
return NULL;
|
||||
}
|
||||
nt->ncp = n;
|
||||
@ -148,12 +146,12 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
memcpy(&nt->opts, topts, sizeof(*topts));
|
||||
if(nt->opts.separator){
|
||||
if((nt->opts.separator = strdup(nt->opts.separator)) == NULL){
|
||||
logerror(nc, "Couldn't allocate nctabbed separator");
|
||||
logerror("Couldn't allocate nctabbed separator");
|
||||
free(nt);
|
||||
return NULL;
|
||||
}
|
||||
if((nt->sepcols = ncstrwidth(nt->opts.separator)) < 0){
|
||||
logerror(nc, "Separator string contains illegal characters");
|
||||
logerror("Separator string contains illegal characters");
|
||||
free(nt->opts.separator);
|
||||
free(nt);
|
||||
return NULL;
|
||||
@ -167,7 +165,7 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
nopts.cols = ncols;
|
||||
nopts.rows = nrows - 1;
|
||||
if((nt->p = ncplane_create(n, &nopts)) == NULL){
|
||||
logerror(nc, "Couldn't create the tab content plane");
|
||||
logerror("Couldn't create the tab content plane");
|
||||
ncplane_genocide(n);
|
||||
free(nt);
|
||||
return NULL;
|
||||
@ -175,7 +173,7 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
nopts.y = nrows - 2;
|
||||
nopts.rows = 1;
|
||||
if((nt->hp = ncplane_create(n, &nopts)) == NULL){
|
||||
logerror(nc, "Couldn't create the tab headers plane");
|
||||
logerror("Couldn't create the tab headers plane");
|
||||
ncplane_genocide(n);
|
||||
free(nt);
|
||||
return NULL;
|
||||
@ -185,7 +183,7 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
nopts.cols = ncols;
|
||||
nopts.rows = 1;
|
||||
if((nt->hp = ncplane_create(n, &nopts)) == NULL){
|
||||
logerror(nc, "Couldn't create the tab headers plane");
|
||||
logerror("Couldn't create the tab headers plane");
|
||||
ncplane_genocide(n);
|
||||
free(nt);
|
||||
return NULL;
|
||||
@ -193,7 +191,7 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
nopts.y = 1;
|
||||
nopts.rows = nrows - 1;
|
||||
if((nt->p = ncplane_create(n, &nopts)) == NULL){
|
||||
logerror(nc, "Couldn't create the tab content plane");
|
||||
logerror("Couldn't create the tab content plane");
|
||||
ncplane_genocide(n);
|
||||
free(nt);
|
||||
return NULL;
|
||||
@ -206,10 +204,9 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
|
||||
nctab* nctabbed_add(nctabbed* nt, nctab* after, nctab* before, tabcb cb,
|
||||
const char* name, void* opaque){
|
||||
nctab* t;
|
||||
notcurses* nc = ncplane_notcurses(nt->ncp);
|
||||
if(after && before){
|
||||
if(after->next != before || before->prev != after){
|
||||
logerror(ncplane_notcurses(nt->ncp), "bad before (%p) / after (%p) spec\n", before, after);
|
||||
logerror("bad before (%p) / after (%p) spec\n", before, after);
|
||||
return NULL;
|
||||
}
|
||||
}else if(!after && !before){
|
||||
@ -217,16 +214,16 @@ nctab* nctabbed_add(nctabbed* nt, nctab* after, nctab* before, tabcb cb,
|
||||
after = nt->selected;
|
||||
}
|
||||
if((t = malloc(sizeof(*t))) == NULL){
|
||||
logerror(nc, "Couldn't allocate nctab")
|
||||
logerror("Couldn't allocate nctab")
|
||||
return NULL;
|
||||
}
|
||||
if((t->name = strdup(name)) == NULL){
|
||||
logerror(nc, "Couldn't allocate the tab name");
|
||||
logerror("Couldn't allocate the tab name");
|
||||
free(t);
|
||||
return NULL;
|
||||
}
|
||||
if((t->namecols = ncstrwidth(name)) < 0){
|
||||
logerror(nc, "Tab name contains illegal characters")
|
||||
logerror("Tab name contains illegal characters")
|
||||
free(t->name);
|
||||
free(t);
|
||||
return NULL;
|
||||
@ -255,7 +252,7 @@ nctab* nctabbed_add(nctabbed* nt, nctab* after, nctab* before, tabcb cb,
|
||||
|
||||
int nctabbed_del(nctabbed* nt, nctab* t){
|
||||
if(!t){
|
||||
logerror(ncplane_notcurses(nt->ncp), "Provided NULL nctab");
|
||||
logerror("Provided NULL nctab");
|
||||
return -1;
|
||||
}
|
||||
if(nt->tabcount == 1){
|
||||
@ -275,19 +272,19 @@ int nctabbed_del(nctabbed* nt, nctab* t){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nctab_move(nctabbed* nt, nctab* t, nctab* after, nctab* before){
|
||||
int nctab_move(nctabbed* nt __attribute__ ((unused)), nctab* t, nctab* after, nctab* before){
|
||||
if(after && before){
|
||||
if(after->prev != before || before->next != after){
|
||||
logerror(ncplane_notcurses(nt->ncp), "bad before (%p) / after (%p) spec\n", before, after);
|
||||
logerror("bad before (%p) / after (%p) spec\n", before, after);
|
||||
return -1;
|
||||
}
|
||||
}else if(!after && !before){
|
||||
logerror(ncplane_notcurses(nt->ncp), "bad before (%p) / after (%p) spec\n", before, after);
|
||||
logerror("bad before (%p) / after (%p) spec\n", before, after);
|
||||
return -1;
|
||||
}
|
||||
// bad things would happen
|
||||
if(t == after || t == before){
|
||||
logerror(ncplane_notcurses(nt->ncp), "Cannot move a tab before or after itself.");
|
||||
logerror("Cannot move a tab before or after itself.");
|
||||
return -1;
|
||||
}
|
||||
t->prev->next = t->next;
|
||||
@ -427,13 +424,12 @@ tabcb nctab_set_cb(nctab* t, tabcb newcb){
|
||||
int nctab_set_name(nctab* t, const char* newname){
|
||||
int newnamecols;
|
||||
char* prevname = t->name;
|
||||
notcurses* nc = ncplane_notcurses(t->nt->ncp);
|
||||
if((newnamecols = ncstrwidth(newname)) < 0){
|
||||
logerror(nc, "New tab name contains illegal characters");
|
||||
logerror("New tab name contains illegal characters");
|
||||
return -1;
|
||||
}
|
||||
if((t->name = strdup(newname)) == NULL){
|
||||
logerror(nc, "Couldn't allocate new tab name");
|
||||
logerror("Couldn't allocate new tab name");
|
||||
t->name = prevname;
|
||||
return -1;
|
||||
}
|
||||
@ -451,13 +447,12 @@ void* nctab_set_userptr(nctab* t, void* newopaque){
|
||||
int nctabbed_set_separator(nctabbed* nt, const char* separator){
|
||||
int newsepcols;
|
||||
char* prevsep = nt->opts.separator;
|
||||
notcurses* nc = ncplane_notcurses(nt->ncp);
|
||||
if((newsepcols = ncstrwidth(separator)) < 0){
|
||||
logerror(nc, "New tab separator contains illegal characters");
|
||||
logerror("New tab separator contains illegal characters");
|
||||
return -1;
|
||||
}
|
||||
if((nt->opts.separator = strdup(separator)) == NULL){
|
||||
logerror(nc, "Couldn't allocate new tab separator");
|
||||
logerror("Couldn't allocate new tab separator");
|
||||
nt->opts.separator = prevsep;
|
||||
return -1;
|
||||
}
|
||||
|
@ -123,25 +123,24 @@ nctree_inner_create(ncplane* n, const struct nctree_options* opts){
|
||||
}
|
||||
|
||||
nctree* nctree_create(ncplane* n, const struct nctree_options* opts){
|
||||
notcurses* nc = ncplane_notcurses(n);
|
||||
if(opts->flags){
|
||||
logwarn(nc, "Passed invalid flags 0x%016jx\n", (uint64_t)opts->flags);
|
||||
logwarn("Passed invalid flags 0x%016jx\n", (uint64_t)opts->flags);
|
||||
}
|
||||
if(opts->count == 0 || opts->items == NULL){
|
||||
logerror(nc, "Can't create empty tree\n");
|
||||
logerror("Can't create empty tree\n");
|
||||
goto error;
|
||||
}
|
||||
if(opts->nctreecb == NULL){
|
||||
logerror(nc, "Can't use NULL callback\n");
|
||||
logerror("Can't use NULL callback\n");
|
||||
goto error;
|
||||
}
|
||||
if(opts->indentcols < 0){
|
||||
logerror(nc, "Can't indent negative columns\n");
|
||||
logerror("Can't indent negative columns\n");
|
||||
goto error;
|
||||
}
|
||||
nctree* ret = nctree_inner_create(n, opts);
|
||||
if(ret == NULL){
|
||||
logerror(nc, "Couldn't prepare nctree\n");
|
||||
logerror("Couldn't prepare nctree\n");
|
||||
goto error;
|
||||
}
|
||||
return ret;
|
||||
|
@ -17,9 +17,9 @@
|
||||
ncvisual_implementation visual_implementation = { };
|
||||
|
||||
// to be called at startup -- performs any necessary engine initialization.
|
||||
int ncvisual_init(int loglevel){
|
||||
int ncvisual_init(int logl){
|
||||
if(visual_implementation.visual_init){
|
||||
return visual_implementation.visual_init(loglevel);
|
||||
return visual_implementation.visual_init(logl);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -139,10 +139,10 @@ int ncvisual_blitset_geom(const notcurses* nc, const tinfo* tcache,
|
||||
lenx = &fakelenx;
|
||||
}
|
||||
if(vopts && vopts->flags >= (NCVISUAL_OPTION_NOINTERPOLATE << 1u)){
|
||||
logwarn(nc, "Warning: unknown ncvisual options %016jx\n", (uintmax_t)vopts->flags);
|
||||
logwarn("Warning: unknown ncvisual options %016jx\n", (uintmax_t)vopts->flags);
|
||||
}
|
||||
if(vopts && (vopts->flags & NCVISUAL_OPTION_CHILDPLANE) && !vopts->n){
|
||||
logerror(nc, "Requested child plane with NULL n\n");
|
||||
logerror("Requested child plane with NULL n\n");
|
||||
return -1;
|
||||
}
|
||||
int begy, begx;
|
||||
@ -151,18 +151,18 @@ int ncvisual_blitset_geom(const notcurses* nc, const tinfo* tcache,
|
||||
*leny = vopts ? vopts->leny : 0;
|
||||
//fprintf(stderr, "blit %dx%d+%dx%d %p\n", begy, begx, *leny, *lenx, ncv->data);
|
||||
if(begy < 0 || begx < 0 || *lenx <= -1 || *leny <= -1){
|
||||
logerror(nc, "Invalid geometry for visual %d %d %d %d\n", begy, begx, *leny, *lenx);
|
||||
logerror("Invalid geometry for visual %d %d %d %d\n", begy, begx, *leny, *lenx);
|
||||
return -1;
|
||||
}
|
||||
if(n){
|
||||
//fprintf(stderr, "OUR DATA: %p rows/cols: %d/%d\n", n->data, n->pixy, n->pixx);
|
||||
if(n->data == NULL){
|
||||
logerror(nc, "No data in visual\n");
|
||||
logerror("No data in visual\n");
|
||||
return -1;
|
||||
}
|
||||
//fprintf(stderr, "blit %d/%d to %dx%d+%dx%d scaling: %d\n", n->pixy, n->pixx, begy, begx, *leny, *lenx, vopts ? vopts->scaling : 0);
|
||||
if(begx >= n->pixx || begy >= n->pixy){
|
||||
logerror(nc, "Visual too large %d > %d or %d > %d\n", begy, n->pixy, begx, n->pixx);
|
||||
logerror("Visual too large %d > %d or %d > %d\n", begy, n->pixy, begx, n->pixx);
|
||||
return -1;
|
||||
}
|
||||
if(*lenx == 0){ // 0 means "to the end"; use all available source material
|
||||
@ -173,17 +173,17 @@ int ncvisual_blitset_geom(const notcurses* nc, const tinfo* tcache,
|
||||
}
|
||||
//fprintf(stderr, "blit %d/%d to %dx%d+%dx%d scaling: %d flags: 0x%016lx\n", n->pixy, n->pixx, begy, begx, *leny, *lenx, vopts ? vopts->scaling : 0, vopts ? vopts->flags : 0);
|
||||
if(*lenx <= 0 || *leny <= 0){ // no need to draw zero-size object, exit
|
||||
logerror(nc, "Zero-size object %d %d\n", *leny, *lenx);
|
||||
logerror("Zero-size object %d %d\n", *leny, *lenx);
|
||||
return -1;
|
||||
}
|
||||
if(begx + *lenx > n->pixx || begy + *leny > n->pixy){
|
||||
logerror(nc, "Geometry too large %d > %d or %d > %d\n", begy + *leny, n->pixy, begx + *lenx, n->pixx);
|
||||
logerror("Geometry too large %d > %d or %d > %d\n", begy + *leny, n->pixy, begx + *lenx, n->pixx);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
const struct blitset* bset = rgba_blitter(tcache, vopts);
|
||||
if(!bset){
|
||||
logerror(nc, "Couldn't get a blitter for %d\n", vopts ? vopts->blitter : NCBLIT_DEFAULT);
|
||||
logerror("Couldn't get a blitter for %d\n", vopts ? vopts->blitter : NCBLIT_DEFAULT);
|
||||
return -1;
|
||||
}
|
||||
if(blitter){
|
||||
@ -192,27 +192,27 @@ int ncvisual_blitset_geom(const notcurses* nc, const tinfo* tcache,
|
||||
if(bset->geom == NCBLIT_PIXEL && vopts){
|
||||
if(vopts->n){
|
||||
if(vopts->n == notcurses_stdplane_const(nc)){
|
||||
logerror(nc, "Won't blit bitmaps to the standard plane\n");
|
||||
logerror("Won't blit bitmaps to the standard plane\n");
|
||||
return -1;
|
||||
}
|
||||
if(vopts->y && !(vopts->flags & NCVISUAL_OPTION_VERALIGNED)){
|
||||
logerror(nc, "Non-origin y placement %d for sprixel\n", vopts->y);
|
||||
logerror("Non-origin y placement %d for sprixel\n", vopts->y);
|
||||
return -1;
|
||||
}
|
||||
if(vopts->x && !(vopts->flags & NCVISUAL_OPTION_HORALIGNED)){
|
||||
logerror(nc, "Non-origin x placement %d for sprixel\n", vopts->x);
|
||||
logerror("Non-origin x placement %d for sprixel\n", vopts->x);
|
||||
return -1;
|
||||
}
|
||||
// FIXME clamp to sprixel limits
|
||||
if(vopts->scaling == NCSCALE_NONE || vopts->scaling == NCSCALE_NONE_HIRES){
|
||||
int rows = (*leny + nc->tcache.cellpixy - 1) / nc->tcache.cellpixy;
|
||||
if(rows > ncplane_dim_y(vopts->n)){
|
||||
logerror(nc, "Sprixel too tall %d for plane %d\n", *leny, ncplane_dim_y(vopts->n) * nc->tcache.cellpixy);
|
||||
logerror("Sprixel too tall %d for plane %d\n", *leny, ncplane_dim_y(vopts->n) * nc->tcache.cellpixy);
|
||||
return -1;
|
||||
}
|
||||
int cols = (*lenx + nc->tcache.cellpixx - 1) / nc->tcache.cellpixx;
|
||||
if(cols > ncplane_dim_x(vopts->n)){
|
||||
logerror(nc, "Sprixel too wide %d for plane %d\n", *lenx, ncplane_dim_x(vopts->n) * nc->tcache.cellpixx);
|
||||
logerror("Sprixel too wide %d for plane %d\n", *lenx, ncplane_dim_x(vopts->n) * nc->tcache.cellpixx);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -234,13 +234,13 @@ int ncvisual_blitset_geom(const notcurses* nc, const tinfo* tcache,
|
||||
}
|
||||
if(vopts && vopts->flags & NCVISUAL_OPTION_HORALIGNED){
|
||||
if(vopts->x < NCALIGN_UNALIGNED || vopts->x > NCALIGN_RIGHT){
|
||||
logerror(nc, "Bad x %d for horizontal alignment\n", vopts->x);
|
||||
logerror("Bad x %d for horizontal alignment\n", vopts->x);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(vopts && vopts->flags & NCVISUAL_OPTION_VERALIGNED){
|
||||
if(vopts->y < NCALIGN_UNALIGNED || vopts->y > NCALIGN_RIGHT){
|
||||
logerror(nc, "Bad y %d for vertical alignment\n", vopts->y);
|
||||
logerror("Bad y %d for vertical alignment\n", vopts->y);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -838,7 +838,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
|
||||
uint64_t flags, uint32_t transcolor){
|
||||
ncplane* stdn = notcurses_stdplane(nc);
|
||||
if(n == stdn){
|
||||
logerror(nc, "Won't blit bitmaps to the standard plane\n");
|
||||
logerror("Won't blit bitmaps to the standard plane\n");
|
||||
return NULL;
|
||||
}
|
||||
int disppixy = 0, disppixx = 0, outy = 0;
|
||||
|
@ -588,8 +588,8 @@ int ffmpeg_log_level(int level){
|
||||
return AV_LOG_TRACE;
|
||||
}
|
||||
|
||||
int ffmpeg_init(int loglevel){
|
||||
av_log_set_level(ffmpeg_log_level(loglevel));
|
||||
int ffmpeg_init(int logl){
|
||||
av_log_set_level(ffmpeg_log_level(logl));
|
||||
// FIXME could also use av_log_set_callback() and capture the message...
|
||||
return 0;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ char* oiio_subtitle(const ncvisual* ncv) { // no support in OIIO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int oiio_init(int loglevel __attribute__ ((unused))) {
|
||||
int oiio_init(int logl __attribute__ ((unused))) {
|
||||
// FIXME set OIIO global attribute "debug" based on loglevel
|
||||
// FIXME check OIIO_VERSION_STRING components against linked openimageio_version()
|
||||
return 0; // allow success here
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include <langinfo.h>
|
||||
|
||||
const char* datadir = NOTCURSES_SHARE;
|
||||
ncloglevel_e loglevel = NCLOGLEVEL_SILENT;
|
||||
ncloglevel_e cliloglevel = NCLOGLEVEL_SILENT;
|
||||
|
||||
auto testing_notcurses() -> struct notcurses* {
|
||||
notcurses_options nopts{};
|
||||
// get loglevel from command line. enabling it by default leads to
|
||||
// more confusion than useful information, so leave it off by default.
|
||||
nopts.loglevel = loglevel;
|
||||
nopts.loglevel = cliloglevel;
|
||||
nopts.flags = NCOPTION_SUPPRESS_BANNERS | NCOPTION_NO_ALTERNATE_SCREEN;
|
||||
auto nc = notcurses_init(&nopts, nullptr);
|
||||
return nc;
|
||||
@ -53,7 +53,7 @@ handle_opts(const char** argv){
|
||||
}else if(strcmp(*argv, "-p") == 0){
|
||||
inarg = true;
|
||||
}else if(strncmp(*argv, "-l", 2) == 0){ // just require -l
|
||||
loglevel = NCLOGLEVEL_TRACE;
|
||||
cliloglevel = NCLOGLEVEL_TRACE;
|
||||
}
|
||||
++argv;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user