[tfman] toggle visibility of structure menu with 's' #2457

pull/2478/head
nick black 3 years ago
parent 5295d0c938
commit 5a205b8410
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -738,9 +738,8 @@ target_link_libraries(ncplayer
)
endif()
endif()
else()
# No binaries built
set(MANSOURCE1 "")
else()
set(MANSOURCE1 "") # no executables were built
endif() # BUILD_EXECUTABLES
############################################################################

@ -750,6 +750,7 @@ draw_domnode(struct ncplane* p, const pagedom* dom, const pagenode* n,
case LINE_IP: // indented paragraph
if(*wrotetext){
if(n->text){
ncplane_set_fg_rgb(p, 0xe0f0ff);
ncplane_puttext(p, -1, NCALIGN_LEFT, "\n\n", &b);
putpara(p, n->text);
}
@ -822,6 +823,7 @@ render_troff(struct notcurses* nc, const unsigned char* map, size_t mlen,
if(pman == NULL){
return NULL;
}
ncplane_set_base(pman, " ", 0, 0);
if(draw_content(stdn, pman)){
ncplane_destroy(pman);
return NULL;
@ -958,7 +960,7 @@ manloop(struct notcurses* nc, const char* arg){
}
break;
case 's':
// FIXME toggle structure browser visibility
docstructure_toggle(page, bar, dom.ds);
break;
case NCKEY_TAB: case L'\u21c6':
// FIXME switch between browsers

@ -14,6 +14,7 @@ typedef struct docstructure {
struct nctree* nct;
// one entry for each hierarchy level + terminator
unsigned curpath[HIERARCHY_MAX + 1];
bool visible;
} docstructure;
static int
@ -60,9 +61,22 @@ docstructure* docstructure_create(struct ncplane* n){
for(unsigned z = 0 ; z < sizeof(ds->curpath) / sizeof(*ds->curpath) ; ++z){
ds->curpath[z] = UINT_MAX;
}
ds->visible = true;
return ds;
}
// to show the structure menu, it ought be on top. otherwise, the page plane
// ought be below the bar, which ought be on top.
void docstructure_toggle(struct ncplane* p, struct ncplane* b, docstructure* ds){
if(!(ds->visible = !ds->visible)){
ncplane_move_top(p);
ncplane_move_top(b);
}else{
ncplane_move_bottom(p);
ncplane_move_bottom(notcurses_stdplane(ncplane_notcurses(p)));
}
}
void docstructure_free(docstructure* ds){
if(ds){
nctree_destroy(ds->nct);

@ -17,6 +17,8 @@ typedef enum {
struct docstructure* docstructure_create(struct ncplane* n);
void docstructure_free(struct docstructure* ds);
void docstructure_toggle(struct ncplane* p, struct ncplane* b, struct docstructure *ds);
// add the specified [sub]section to the document strucure. |line| refers to
// the row on the display plane, *not* the line in the original content.
int docstructure_add(struct docstructure* ds, const char* title, int line,

Loading…
Cancel
Save