diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-11-19 14:20:30 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-11-22 13:13:14 +0800 |
commit | b7a7eb9a248f8afb1667b3e6675b49853e567ce1 (patch) | |
tree | 6e200c25699e4b60666cf8847547f4e3d0c3754f /ui/ncurses | |
parent | e921d7bc8ed3980494518d22b0e754a6b3a603b1 (diff) | |
download | talos-petitboot-b7a7eb9a248f8afb1667b3e6675b49853e567ce1.tar.gz talos-petitboot-b7a7eb9a248f8afb1667b3e6675b49853e567ce1.zip |
ui/ncurses: Implement intra-field scrolling
Now that we can calculate the focus within a field, ensure that the
focussed-element remains scrolled.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses')
-rw-r--r-- | ui/ncurses/nc-boot-editor.c | 11 | ||||
-rw-r--r-- | ui/ncurses/nc-config.c | 11 |
2 files changed, 10 insertions, 12 deletions
diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c index 741f835..5765c95 100644 --- a/ui/ncurses/nc-boot-editor.c +++ b/ui/ncurses/nc-boot-editor.c @@ -275,17 +275,16 @@ static void boot_editor_layout_widgets(struct boot_editor *boot_editor) static void boot_editor_widget_focus(struct nc_widget *widget, void *arg) { struct boot_editor *boot_editor = arg; - int w_y, w_height, s_max; + int w_y, s_max; - w_y = widget_y(widget); - w_height = widget_height(widget); - s_max = getmaxy(boot_editor->scr.sub_ncw); + w_y = widget_y(widget) + widget_focus_y(widget); + s_max = getmaxy(boot_editor->scr.sub_ncw) - 1; if (w_y < boot_editor->scroll_y) boot_editor->scroll_y = w_y; - else if (w_y + w_height + boot_editor->scroll_y > s_max - 1) - boot_editor->scroll_y = 1 + w_y + w_height - s_max; + else if (w_y + boot_editor->scroll_y + 1 > s_max) + boot_editor->scroll_y = 1 + w_y - s_max; else return; diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c index ca8c44c..4eeeff8 100644 --- a/ui/ncurses/nc-config.c +++ b/ui/ncurses/nc-config.c @@ -535,17 +535,16 @@ 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, w_height, s_max; + int w_y, s_max; - w_y = widget_y(widget); - w_height = widget_height(widget); - s_max = getmaxy(screen->scr.sub_ncw); + w_y = widget_y(widget) + widget_focus_y(widget); + s_max = getmaxy(screen->scr.sub_ncw) - 1; if (w_y < screen->scroll_y) screen->scroll_y = w_y; - else if (w_y + w_height + screen->scroll_y > s_max - 1) - screen->scroll_y = 1 + w_y + w_height - s_max; + else if (w_y + screen->scroll_y + 1 > s_max) + screen->scroll_y = 1 + w_y - s_max; else return; |