ncreader: Alt-B, Alt-F for cursor movement #983

This commit is contained in:
nick black 2020-09-09 07:45:11 -04:00
parent 1f59eef9d8
commit 8bbd134504
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -226,17 +226,8 @@ int ncreader_write_egc(ncreader* n, const char* egc){
return 0; return 0;
} }
// we pass along: static bool
// * anything with Alt ncreader_ctrl_input(ncreader* n, const ncinput* ni){
// * anything with Ctrl, except 'U' (which clears all input)
// * anything synthesized, save arrow keys and backspace
bool ncreader_offer_input(ncreader* n, const ncinput* ni){
int x = n->textarea->x;
int y = n->textarea->y;
if(ni->alt){ // pass on all alts
return false;
}
if(ni->ctrl && !n->no_cmd_keys){
switch(ni->id){ switch(ni->id){
case 'U': case 'U':
ncplane_erase(n->ncp); // homes the cursor ncplane_erase(n->ncp); // homes the cursor
@ -253,6 +244,37 @@ bool ncreader_offer_input(ncreader* n, const ncinput* ni){
} }
return true; return true;
} }
static bool
ncreader_alt_input(ncreader* n, const ncinput* ni){
switch(ni->id){
case 'B': // back one word (to first cell) FIXME
ncreader_move_left(n);
break;
case 'F': // forward one word (past end cell) FIXME
ncreader_move_right(n);
break;
default:
return false;
}
return true;
}
// we pass along:
// * anything with Alt
// * anything with Ctrl, except 'U' (which clears all input)
// * anything synthesized, save arrow keys and backspace
bool ncreader_offer_input(ncreader* n, const ncinput* ni){
int x = n->textarea->x;
int y = n->textarea->y;
if(ni->alt){ // pass on all alts
return false;
}
if(ni->ctrl && !n->no_cmd_keys){
return ncreader_ctrl_input(n, ni);
}else if(ni->alt && !n->no_cmd_keys){
return ncreader_alt_input(n, ni);
}
if(ni->id == NCKEY_BACKSPACE){ if(ni->id == NCKEY_BACKSPACE){
if(n->textarea->x == 0){ if(n->textarea->x == 0){
if(n->textarea->y){ if(n->textarea->y){