From ae0b7d588a1ff9b11b6fcb6537fd14153ed643bc Mon Sep 17 00:00:00 2001 From: Eric Melville Date: Fri, 31 Aug 2001 01:56:06 +0000 Subject: [PATCH] Properly move cursor when home and end keys are used. --- gnu/lib/libdialog/checklist.c | 12 ++++++++++-- gnu/lib/libdialog/radiolist.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gnu/lib/libdialog/checklist.c b/gnu/lib/libdialog/checklist.c index 188b542931df..c696d47dcdf8 100644 --- a/gnu/lib/libdialog/checklist.c +++ b/gnu/lib/libdialog/checklist.c @@ -43,7 +43,7 @@ dialog_checklist(unsigned char *title, unsigned char *prompt, int height, int wi { int i, j, x, y, cur_x, cur_y, old_x, old_y, box_x, box_y, key = 0, button, choice, l, k, scroll, max_choice, item_no = 0, *status; - int redraw_menu = FALSE; + int redraw_menu = FALSE, cursor_reset = FALSE; int rval = 0, onlist = 1, ok_space, cancel_space; char okButton, cancelButton; WINDOW *dialog, *list; @@ -452,6 +452,7 @@ draw: scroll = 0; choice = 0; redraw_menu = TRUE; + cursor_reset = TRUE; onlist = 1; break; @@ -461,6 +462,7 @@ draw: scroll = 0; choice = max_choice - 1; redraw_menu = TRUE; + cursor_reset = TRUE; onlist = 1; break; @@ -581,7 +583,13 @@ draw: print_button(dialog, " OK ", y, x, !button); } wnoutrefresh(dialog); - wmove(list, old_y, old_x); + if (cursor_reset) { + wmove(list, choice, check_x+1); + cursor_reset = FALSE; + } + else { + wmove(list, old_y, old_x); + } wrefresh(list); redraw_menu = FALSE; } diff --git a/gnu/lib/libdialog/radiolist.c b/gnu/lib/libdialog/radiolist.c index 5166ccecfefd..39b362b7b07a 100644 --- a/gnu/lib/libdialog/radiolist.c +++ b/gnu/lib/libdialog/radiolist.c @@ -46,7 +46,7 @@ dialog_radiolist(unsigned char *title, unsigned char *prompt, int height, int wi { int i, j, x, y, cur_x, cur_y, old_x, old_y, box_x, box_y, key = 0, button, choice, l, k, scroll, max_choice, *status, item_no = 0, was_on = 0; - int redraw_menu = FALSE; + int redraw_menu = FALSE, cursor_reset = FALSE; int rval = 0, onlist = 1, ok_space, cancel_space; char okButton, cancelButton; WINDOW *dialog, *list; @@ -455,6 +455,7 @@ draw: scroll = 0; choice = 0; redraw_menu = TRUE; + cursor_reset = TRUE; onlist = 1; break; @@ -464,6 +465,7 @@ draw: scroll = 0; choice = max_choice - 1; redraw_menu = TRUE; + cursor_reset = TRUE; onlist = 1; break; @@ -575,7 +577,13 @@ draw: print_button(dialog, " OK ", y, x, !button); } wnoutrefresh(dialog); - wmove(list, old_y, old_x); + if (cursor_reset) { + wmove(list, choice, check_x+1); + cursor_reset = FALSE; + } + else { + wmove(list, old_y, old_x); + } wrefresh(list); redraw_menu = FALSE; }