mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[tfman] toggle visibility of structure menu with 's' #2457
This commit is contained in:
parent
5295d0c938
commit
5a205b8410
@ -738,9 +738,8 @@ target_link_libraries(ncplayer
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
# No binaries built
|
set(MANSOURCE1 "") # no executables were built
|
||||||
set(MANSOURCE1 "")
|
|
||||||
endif() # BUILD_EXECUTABLES
|
endif() # BUILD_EXECUTABLES
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
@ -750,6 +750,7 @@ draw_domnode(struct ncplane* p, const pagedom* dom, const pagenode* n,
|
|||||||
case LINE_IP: // indented paragraph
|
case LINE_IP: // indented paragraph
|
||||||
if(*wrotetext){
|
if(*wrotetext){
|
||||||
if(n->text){
|
if(n->text){
|
||||||
|
ncplane_set_fg_rgb(p, 0xe0f0ff);
|
||||||
ncplane_puttext(p, -1, NCALIGN_LEFT, "\n\n", &b);
|
ncplane_puttext(p, -1, NCALIGN_LEFT, "\n\n", &b);
|
||||||
putpara(p, n->text);
|
putpara(p, n->text);
|
||||||
}
|
}
|
||||||
@ -822,6 +823,7 @@ render_troff(struct notcurses* nc, const unsigned char* map, size_t mlen,
|
|||||||
if(pman == NULL){
|
if(pman == NULL){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
ncplane_set_base(pman, " ", 0, 0);
|
||||||
if(draw_content(stdn, pman)){
|
if(draw_content(stdn, pman)){
|
||||||
ncplane_destroy(pman);
|
ncplane_destroy(pman);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -958,7 +960,7 @@ manloop(struct notcurses* nc, const char* arg){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
// FIXME toggle structure browser visibility
|
docstructure_toggle(page, bar, dom.ds);
|
||||||
break;
|
break;
|
||||||
case NCKEY_TAB: case L'\u21c6':
|
case NCKEY_TAB: case L'\u21c6':
|
||||||
// FIXME switch between browsers
|
// FIXME switch between browsers
|
||||||
|
@ -14,6 +14,7 @@ typedef struct docstructure {
|
|||||||
struct nctree* nct;
|
struct nctree* nct;
|
||||||
// one entry for each hierarchy level + terminator
|
// one entry for each hierarchy level + terminator
|
||||||
unsigned curpath[HIERARCHY_MAX + 1];
|
unsigned curpath[HIERARCHY_MAX + 1];
|
||||||
|
bool visible;
|
||||||
} docstructure;
|
} docstructure;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -60,9 +61,22 @@ docstructure* docstructure_create(struct ncplane* n){
|
|||||||
for(unsigned z = 0 ; z < sizeof(ds->curpath) / sizeof(*ds->curpath) ; ++z){
|
for(unsigned z = 0 ; z < sizeof(ds->curpath) / sizeof(*ds->curpath) ; ++z){
|
||||||
ds->curpath[z] = UINT_MAX;
|
ds->curpath[z] = UINT_MAX;
|
||||||
}
|
}
|
||||||
|
ds->visible = true;
|
||||||
return ds;
|
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){
|
void docstructure_free(docstructure* ds){
|
||||||
if(ds){
|
if(ds){
|
||||||
nctree_destroy(ds->nct);
|
nctree_destroy(ds->nct);
|
||||||
|
@ -17,6 +17,8 @@ typedef enum {
|
|||||||
struct docstructure* docstructure_create(struct ncplane* n);
|
struct docstructure* docstructure_create(struct ncplane* n);
|
||||||
void docstructure_free(struct docstructure* ds);
|
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
|
// 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.
|
// the row on the display plane, *not* the line in the original content.
|
||||||
int docstructure_add(struct docstructure* ds, const char* title, int line,
|
int docstructure_add(struct docstructure* ds, const char* title, int line,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user