]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-config.c
Fix certain calls to gettext
[petitboot] / ui / ncurses / nc-config.c
index 7c02250ce6e47765531f86364ec3639af65e47d1..64fb4c792139d71dc0891dda330752b2427dc272 100644 (file)
@@ -811,7 +811,8 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        }
 
        screen->widgets.network_l = widget_new_label(set, 0, 0, _("Network:"));
-       screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
+       screen->widgets.network_f = widget_new_select(set, 0, 0,
+                                               COLS - screen->field_x - 1);
 
        widget_select_add_option(screen->widgets.network_f,
                                        NET_CONF_TYPE_DHCP_ALL,
@@ -908,11 +909,12 @@ static void config_screen_setup_widgets(struct config_screen *screen,
        screen->widgets.allow_write_l = widget_new_label(set, 0, 0,
                        _("Disk R/W:"));
        screen->widgets.allow_write_f = widget_new_select(set, 0, 0,
-                                               COLS - screen->field_x);
+                                               COLS - screen->field_x - 1);
 
        widget_select_add_option(screen->widgets.allow_write_f, 0,
                                _("Prevent all writes to disk"),
                                !config->allow_writes);
+
        widget_select_add_option(screen->widgets.allow_write_f, 1,
                                _("Allow bootloader scripts to modify disks"),
                                config->allow_writes);
@@ -928,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);