]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Implement intra-field scrolling
authorJeremy Kerr <jk@ozlabs.org>
Tue, 19 Nov 2013 03:20:30 +0000 (14:20 +1100)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 22 Nov 2013 05:13:14 +0000 (13:13 +0800)
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>
ui/ncurses/nc-boot-editor.c
ui/ncurses/nc-config.c

index 741f83595a19df99953cc7752642f93811eab5dd..5765c955fe14b53747d3b63db126110aac464062 100644 (file)
@@ -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;
index ca8c44c0e6bfb74a3208f251e83cdd135fb3eb01..4eeeff830aed783a67874bebab16f32a8ba047ed 100644 (file)
@@ -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;