[tfman] set up plane for structure nctree

This commit is contained in:
nick black 2021-12-12 06:04:19 -05:00 committed by nick black
parent 49e9406576
commit 5afc56f980
2 changed files with 29 additions and 1 deletions

View File

@ -543,6 +543,16 @@ If things break or seem otherwise lackluster, **please** consult the
terminal. No known terminal emulators exhibit this behavior.
</details>
<details>
<summary>How can I draw a large plane, and only make a portion of it visible?</summary>
The simplest way is probably to create a plane of the same dimensions immediately above
the plane, and keep a region of it transparent, and the rest opaque. If you want the visible
area to stay in the same place on the display, but the portion being seen to change, try
making a plane twice as large in each dimension as the original plane. Make the desired area
transparent, and the rest opaque. Now move the original plane behind this plane so that the
desired area lines up with the &ldquo;hole&rdquo;.
</details>
<details>
<summary>Why no <code>NCSTYLE_REVERSE</code>?</summary>
It would consume a precious bit. You can use <code>ncchannels_reverse()</code>

View File

@ -29,10 +29,25 @@ docstructure* docstructure_create(struct ncplane* n){
if(ds == NULL){
return NULL;
}
const int ROWS = 7;
const int COLDIV = 4;
ncplane_options nopts = {
.rows = ROWS,
.cols = ncplane_dim_x(n) / COLDIV,
.y = ncplane_dim_y(n) - ROWS,
.x = ncplane_dim_x(n) - (ncplane_dim_x(n) / COLDIV) - 1,
.flags = NCPLANE_OPTION_AUTOGROW, // autogrow to right
};
struct ncplane* p = ncplane_create(n, &nopts);
if(p == NULL){
return NULL;
}
uint64_t channels = NCCHANNELS_INITIALIZER(0, 0, 0, 0x80, 0x80, 0x80);
ncplane_set_base(p, "", 0, channels);
nctree_options topts = {
.nctreecb = docstruct_callback,
};
if((ds->nct = nctree_create(n, &topts)) == NULL){
if((ds->nct = nctree_create(p, &topts)) == NULL){
free(ds);
return NULL;
}
@ -103,5 +118,8 @@ int docstructure_add(docstructure* ds, const char* title, int line,
return -1;
}
ds->curpath[z] = addpath[z];
if(nctree_redraw(ds->nct)){
return -1;
}
return 0;
}