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,6 +226,40 @@ int ncreader_write_egc(ncreader* n, const char* egc){
return 0; return 0;
} }
static bool
ncreader_ctrl_input(ncreader* n, const ncinput* ni){
switch(ni->id){
case 'U':
ncplane_erase(n->ncp); // homes the cursor
ncplane_erase(n->textarea);
break;
case 'B':
ncreader_move_left(n);
break;
case 'F':
ncreader_move_right(n);
break;
default:
return false; // pass on all other ctrls
}
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: // we pass along:
// * anything with Alt // * anything with Alt
// * anything with Ctrl, except 'U' (which clears all input) // * anything with Ctrl, except 'U' (which clears all input)
@ -237,21 +271,9 @@ bool ncreader_offer_input(ncreader* n, const ncinput* ni){
return false; return false;
} }
if(ni->ctrl && !n->no_cmd_keys){ if(ni->ctrl && !n->no_cmd_keys){
switch(ni->id){ return ncreader_ctrl_input(n, ni);
case 'U': }else if(ni->alt && !n->no_cmd_keys){
ncplane_erase(n->ncp); // homes the cursor return ncreader_alt_input(n, ni);
ncplane_erase(n->textarea);
break;
case 'B':
ncreader_move_left(n);
break;
case 'F':
ncreader_move_right(n);
break;
default:
return false; // pass on all other ctrls
}
return true;
} }
if(ni->id == NCKEY_BACKSPACE){ if(ni->id == NCKEY_BACKSPACE){
if(n->textarea->x == 0){ if(n->textarea->x == 0){