notcurses-ncreel: handle +/- for tablets

This commit is contained in:
nick black 2020-07-25 20:57:31 -04:00
parent 55e654d4ab
commit 6354b26d78
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 31 additions and 7 deletions

View File

@ -50,12 +50,12 @@ struct ncfadectx; // context for a palette fade operation
typedef enum {
NCBLIT_DEFAULT, // let the ncvisual pick
NCBLIT_1x1, // full block █
NCBLIT_2x1, // full/(upper|left) blocks ▄
NCBLIT_2x1, // upper half + 1x1 ▀
NCBLIT_1x1x4, // shaded full blocks ▓▒░█
NCBLIT_2x2, // quadrants ▗▐ ▖▄▟▌▙█
NCBLIT_4x1, // four vert/horz levels █▆▄▂ / ▎▌▊█
NCBLIT_2x2, // quadrants + 2x1 ▗▐ ▖▀▟▌▙█
NCBLIT_4x1, // four vertical levels █▆▄▂
NCBLIT_BRAILLE, // 4 rows, 2 cols (braille) ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
NCBLIT_8x1, // eight vert/horz levels █▇▆▅▄▃▂▁ / ▏▎▍▌▋▊▉█
NCBLIT_8x1, // eight vertical levels █▇▆▅▄▃▂▁
NCBLIT_SIXEL, // 6 rows, 1 col (RGB), spotty support among terminals
} ncblitter_e;

View File

@ -832,6 +832,8 @@ bool ncreel_offer_input(ncreel* n, const ncinput* nc){
ncreel_next(n);
return true;
}
// FIXME there are a few more
// FIXME there are a few more:
// page up/page down
// end/home (when not using infinite scrolling)
return false;
}

View File

@ -19,6 +19,14 @@ class TabletCtx {
int getLines() const {
return lines;
}
void addLine() {
++lines;
}
void subLine() {
if(lines){
--lines;
}
}
int getIdx() const {
return idx;
}
@ -122,7 +130,21 @@ int runreels(struct notcurses* nc, struct ncplane* n, ncreel_options* nopts){
case 'd':
ncreel_del(nr, ncreel_focused(nr));
break;
case '*':
case '+':{
auto t = ncreel_focused(nr);
if(t){
auto tctx = static_cast<TabletCtx*>(nctablet_userptr(t));
tctx->addLine();
}
break;
}case '-':{
auto t = ncreel_focused(nr);
if(t){
auto tctx = static_cast<TabletCtx*>(nctablet_userptr(t));
tctx->subLine();
}
break;
}case '*':
notcurses_debug(nc, stderr);
break;
case NCKEY_LEFT:
@ -170,7 +192,7 @@ int main(int argc, char** argv){
}
int dimy, dimx;
auto nstd = notcurses_stddim_yx(nc, &dimy, &dimx);
if(ncplane_putstr_aligned(nstd, 0, NCALIGN_CENTER, "(a)dd (d)el (q)uit") <= 0){
if(ncplane_putstr_aligned(nstd, 0, NCALIGN_CENTER, "(a)dd (d)el (+/-) change lines (q)uit") <= 0){
return -1;
}
auto n = ncplane_new(nc, dimy - 1 - (margin_t + margin_b),