diff options
author | Geoff Levand <geoffrey.levand@am.sony.com> | 2009-07-09 10:40:43 -0700 |
---|---|---|
committer | Geoff Levand <geoffrey.levand@am.sony.com> | 2009-07-09 10:40:43 -0700 |
commit | f57a6400e6b513695e2d1e9d1b08b0d5e562051c (patch) | |
tree | 511abc7f79a999b78b3762575de559dbaf192a00 /ui | |
parent | 3bb091f52586bee88ed0d9380ce4df55d837fd5e (diff) | |
download | petitboot-f57a6400e6b513695e2d1e9d1b08b0d5e562051c.zip petitboot-f57a6400e6b513695e2d1e9d1b08b0d5e562051c.tar.gz |
Fix ked backspace
Fix a bug in the ked editor field backspace logic.
Stop deleting chars when cursor reaches front of feild
buffer.
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ncurses/nc-ked.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/ui/ncurses/nc-ked.c b/ui/ncurses/nc-ked.c index 3bdbd6c..0f52934 100644 --- a/ui/ncurses/nc-ked.c +++ b/ui/ncurses/nc-ked.c @@ -48,12 +48,15 @@ static struct ked *ked_from_arg(void *arg) * @req: An ncurses request or char to send to form_driver(). */ -static void ked_move_cursor(struct ked *ked, int req) +static int ked_move_cursor(struct ked *ked, int req) { + int result; + wchgat(ked->scr.sub_ncw, 1, ked_attr_field_selected, 0, 0); - form_driver(ked->ncf, req); + result = form_driver(ked->ncf, req); wchgat(ked->scr.sub_ncw, 1, ked->attr_cursor, 0, 0); wrefresh(ked->scr.main_ncw); + return result; } /** @@ -93,12 +96,15 @@ static void ked_insert_mode_tog(struct ked *ked) * @req: An ncurses request to send to form_driver(). */ -static void ked_move_field(struct ked *ked, int req) +static int ked_move_field(struct ked *ked, int req) { + int result; + set_field_back(current_field(ked->ncf), ked_attr_field_normal); - form_driver(ked->ncf, req); + result = form_driver(ked->ncf, req); set_field_back(current_field(ked->ncf), ked_attr_field_selected); ked_move_cursor(ked, REQ_END_FIELD); + return result; } static int ked_post(struct nc_scr *scr) @@ -187,12 +193,15 @@ static void ked_process_key(struct nc_scr *scr) while (1) { int c = getch(); + if (c == ERR) + return; + + /* DBGS("%d (%o)\n", c, c); */ + switch (c) { default: ked_move_cursor(ked, c); - break; - case ERR: - return; + break; /* hot keys */ case 2: { /* CTRL-B */ @@ -252,8 +261,8 @@ static void ked_process_key(struct nc_scr *scr) ked_move_cursor(ked, REQ_RIGHT_CHAR); break; case KEY_BACKSPACE: - ked_move_cursor(ked, REQ_LEFT_CHAR); - ked_move_cursor(ked, REQ_DEL_CHAR); + if (ked_move_cursor(ked, REQ_LEFT_CHAR) == E_OK) + ked_move_cursor(ked, REQ_DEL_CHAR); break; case KEY_DC: ked_move_cursor(ked, REQ_DEL_CHAR); |