diff --git a/doc/man/man3/notcurses_tabbed.3.md b/doc/man/man3/notcurses_tabbed.3.md index e854c4215..bb65a3d53 100644 --- a/doc/man/man3/notcurses_tabbed.3.md +++ b/doc/man/man3/notcurses_tabbed.3.md @@ -20,7 +20,7 @@ typedef struct nctabbed_options { uint64_t selchan; // channel for the selected tab header uint64_t hdrchan; // channel for unselected tab headers uint64_t sepchan; // channel for the tab separator - char* separator; // separator string (copied by nctabbed_create()) + const char* separator; // separator string (copied by nctabbed_create()) uint64_t flags; // bitmask of NCTABBED_OPTION_* } nctabbed_options; diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index ec4c8c00a..49b97106a 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -3646,7 +3646,7 @@ typedef struct nctabbed_options { uint64_t selchan; // channel for the selected tab header uint64_t hdrchan; // channel for unselected tab headers uint64_t sepchan; // channel for the tab separator - char* separator; // separator string (copied by nctabbed_create()) + const char* separator; // separator string (copied by nctabbed_create()) uint64_t flags; // bitmask of NCTABBED_OPTION_* } nctabbed_options; @@ -3982,17 +3982,17 @@ typedef struct ncsubproc_options { // see exec(2). p-types use $PATH. e-type passes environment vars. API ALLOC struct ncsubproc* ncsubproc_createv(struct ncplane* n, const ncsubproc_options* opts, - const char* bin, char* const arg[], + const char* bin, char* const arg[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__ ((nonnull (1))); API ALLOC struct ncsubproc* ncsubproc_createvp(struct ncplane* n, const ncsubproc_options* opts, - const char* bin, char* const arg[], + const char* bin, char* const arg[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__ ((nonnull (1))); API ALLOC struct ncsubproc* ncsubproc_createvpe(struct ncplane* n, const ncsubproc_options* opts, - const char* bin, char* const arg[], char* const env[], + const char* bin, char* const arg[], char* const env[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__ ((nonnull (1))); diff --git a/src/lib/internal.h b/src/lib/internal.h index 7b4324a60..01e86ac42 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -230,18 +230,6 @@ typedef struct nctab { struct nctab* next; } nctab; -typedef struct nctabbed { - ncplane* ncp; // widget ncplane - ncplane* p; // tab content ncplane - ncplane* hp; // tab headers ncplane - // a doubly-linked circular list of tabs - nctab* leftmost; // the tab most to the left - nctab* selected; // the currently selected tab - int tabcount; // tab separator (can be NULL) - int sepcols; // separator with in columns - nctabbed_options opts; // copied in nctabbed_create() -} nctabbed; - // various moving parts within a notcurses context (and the user) might need to // access the stats object, so throw a lock on it. we don't want the lock in // the actual structure since (a) it's usually unnecessary and (b) it breaks diff --git a/src/lib/tabbed.c b/src/lib/tabbed.c index 52f728f02..8dcd5886c 100644 --- a/src/lib/tabbed.c +++ b/src/lib/tabbed.c @@ -1,5 +1,25 @@ #include "internal.h" +typedef struct nctabbed_opsint { + uint64_t selchan; // channel for the selected tab header + uint64_t hdrchan; // channel for unselected tab headers + uint64_t sepchan; // channel for the tab separator + char* separator; // separator string (copied by nctabbed_create()) + uint64_t flags; // bitmask of NCTABBED_OPTION_* +} nctabbed_opsint; + +typedef struct nctabbed { + ncplane* ncp; // widget ncplane + ncplane* p; // tab content ncplane + ncplane* hp; // tab headers ncplane + // a doubly-linked circular list of tabs + nctab* leftmost; // the tab most to the left + nctab* selected; // the currently selected tab + int tabcount; // tab separator (can be NULL) + int sepcols; // separator with in columns + nctabbed_opsint opts; // copied in nctabbed_create() +} nctabbed; + void nctabbed_redraw(nctabbed* nt){ nctab* t; int drawn_cols = 0; @@ -144,8 +164,12 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){ nt->leftmost = nt->selected = NULL; nt->tabcount = 0; memcpy(&nt->opts, topts, sizeof(*topts)); - if(nt->opts.separator){ - if((nt->opts.separator = strdup(nt->opts.separator)) == NULL){ + nt->opts.selchan = topts->selchan; + nt->opts.hdrchan = topts->hdrchan; + nt->opts.sepchan = topts->sepchan; + nt->opts.flags = topts->flags; + if(topts->separator){ + if((nt->opts.separator = strdup(topts->separator)) == NULL){ logerror("Couldn't allocate nctabbed separator"); free(nt); return NULL; @@ -157,6 +181,7 @@ nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){ return NULL; } }else{ + nt->opts.separator = NULL; nt->sepcols = 0; } ncplane_dim_yx(n, &nrows, &ncols); @@ -267,6 +292,7 @@ int nctabbed_del(nctabbed* nt, nctab* t){ t->next->prev = t->prev; t->prev->next = t->next; } + free(t->name); free(t); --nt->tabcount; return 0; diff --git a/src/poc/tabbed.c b/src/poc/tabbed.c index 3741f3ede..76f2b4fe4 100644 --- a/src/poc/tabbed.c +++ b/src/poc/tabbed.c @@ -102,7 +102,11 @@ int main(int argc, char** argv){ } int tabnameind = 0; uint32_t c; - while((c = notcurses_getc_blocking(nc, NULL)) != 'q'){ + ncinput ni; + while((c = notcurses_getc_blocking(nc, &ni)) != 'q'){ + if(ni.evtype == NCTYPE_RELEASE){ + continue; + } switch(c){ case NCKEY_RIGHT: nctabbed_next(nct);