diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-09-09 14:39:34 +1000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-09-10 15:49:29 +1000 |
commit | 68a146bb02f81e746d13b362daaf290a51697a5a (patch) | |
tree | c779f710d0d27c7a2cec3a9cad53cb0fad63aaae /ui/ncurses | |
parent | b6f99a457cb906277b172a0332a1e16ddba99228 (diff) | |
download | talos-petitboot-68a146bb02f81e746d13b362daaf290a51697a5a.tar.gz talos-petitboot-68a146bb02f81e746d13b362daaf290a51697a5a.zip |
ui/ncurses: Improve scrolling behaviour
The nc-config screen now includes several select options with a FIELD
height greater than one, but config_screen_widget_focus() will only
scroll down enough to see the first line of text.
Update config_screen_widget_focus() to try and make as much of the
focussed widget visible as possible.
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Diffstat (limited to 'ui/ncurses')
-rw-r--r-- | ui/ncurses/nc-config.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index 2750bbb..64fb4c7 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -930,18 +930,22 @@ static void config_screen_setup_widgets(struct config_screen *screen, static void config_screen_widget_focus(struct nc_widget *widget, void *arg) { struct config_screen *screen = arg; - int w_y, s_max; + int w_y, w_height, w_focus, s_max, adjust; - w_y = widget_y(widget) + widget_focus_y(widget); + w_height = widget_height(widget); + w_focus = widget_focus_y(widget); + w_y = widget_y(widget) + w_focus; s_max = getmaxy(screen->scr.sub_ncw) - 1; if (w_y < screen->scroll_y) screen->scroll_y = w_y; - else if (w_y + screen->scroll_y + 1 > s_max) - screen->scroll_y = 1 + w_y - s_max; - - else + else if (w_y + screen->scroll_y + 1 > s_max) { + /* Fit as much of the widget into the screen as possible */ + adjust = min(s_max - 1, w_height - w_focus); + if (w_y + adjust >= screen->scroll_y + s_max) + screen->scroll_y = max(0, 1 + w_y + adjust - s_max); + } else return; pad_refresh(screen); |