From 8bbd1345041aee0cb5f5176720831884acdee04b Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 9 Sep 2020 07:45:11 -0400 Subject: [PATCH] ncreader: Alt-B, Alt-F for cursor movement #983 --- src/lib/reader.c | 52 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/lib/reader.c b/src/lib/reader.c index a30feb9e0..1e8d6aa0e 100644 --- a/src/lib/reader.c +++ b/src/lib/reader.c @@ -226,6 +226,40 @@ int ncreader_write_egc(ncreader* n, const char* egc){ 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: // * anything with Alt // * anything with Ctrl, except 'U' (which clears all input) @@ -237,21 +271,9 @@ bool ncreader_offer_input(ncreader* n, const ncinput* ni){ return false; } if(ni->ctrl && !n->no_cmd_keys){ - 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; + 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(n->textarea->x == 0){