notcurses-ncreel: handle +/- for tablets

pull/832/head
nick black 4 years ago
parent 55e654d4ab
commit 6354b26d78
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

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

@ -832,6 +832,8 @@ bool ncreel_offer_input(ncreel* n, const ncinput* nc){
ncreel_next(n); ncreel_next(n);
return true; 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; return false;
} }

@ -19,6 +19,14 @@ class TabletCtx {
int getLines() const { int getLines() const {
return lines; return lines;
} }
void addLine() {
++lines;
}
void subLine() {
if(lines){
--lines;
}
}
int getIdx() const { int getIdx() const {
return idx; return idx;
} }
@ -122,7 +130,21 @@ int runreels(struct notcurses* nc, struct ncplane* n, ncreel_options* nopts){
case 'd': case 'd':
ncreel_del(nr, ncreel_focused(nr)); ncreel_del(nr, ncreel_focused(nr));
break; 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); notcurses_debug(nc, stderr);
break; break;
case NCKEY_LEFT: case NCKEY_LEFT:
@ -170,7 +192,7 @@ int main(int argc, char** argv){
} }
int dimy, dimx; int dimy, dimx;
auto nstd = notcurses_stddim_yx(nc, &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; return -1;
} }
auto n = ncplane_new(nc, dimy - 1 - (margin_t + margin_b), auto n = ncplane_new(nc, dimy - 1 - (margin_t + margin_b),

Loading…
Cancel
Save