int label_x;
int field_x;
+ int scroll_y;
+ WINDOW *pad;
struct nc_widgetset *widgetset;
struct {
struct nc_widget_label *device_l;
return boot_editor;
}
+static void pad_refresh(struct boot_editor *boot_editor)
+{
+ int y, x, rows, cols;
+
+ getmaxyx(boot_editor->scr.sub_ncw, rows, cols);
+ getbegyx(boot_editor->scr.sub_ncw, y, x);
+
+ prefresh(boot_editor->pad, boot_editor->scroll_y, 0,
+ y, x, rows, cols);
+}
+
static struct boot_editor *boot_editor_from_arg(void *arg)
{
struct boot_editor *boot_editor = arg;
widgetset_post(boot_editor->widgetset);
nc_scr_frame_draw(scr);
- redrawwin(boot_editor->scr.main_ncw);
- wrefresh(boot_editor->scr.main_ncw);
-
+ pad_refresh(boot_editor);
return 0;
}
handled = widgetset_process_key(boot_editor->widgetset, key);
if (handled) {
- wrefresh(boot_editor->scr.main_ncw);
+ pad_refresh(boot_editor);
return;
}
{
struct boot_editor *boot_editor = boot_editor_from_arg(arg);
boot_editor->scr.sig = pb_removed_sig;
+ if (boot_editor->pad)
+ delwin(boot_editor->pad);
return 0;
}
return max(widget_height(label_w), widget_height(field_w));
}
+static int pad_height(int blockdevs_height)
+{
+ return 10 + blockdevs_height;
+}
+
static void boot_editor_layout_widgets(struct boot_editor *boot_editor)
{
struct nc_widget *wf, *wl;
y++;
widget_move(widget_button_base(boot_editor->widgets.ok_b), y, 9);
widget_move(widget_button_base(boot_editor->widgets.cancel_b), y, 19);
+
+ pad_refresh(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;
+
+ w_y = widget_y(widget);
+ w_height = widget_height(widget);
+ s_max = getmaxy(boot_editor->scr.sub_ncw);
+
+ 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
+ return;
+
+ pad_refresh(boot_editor);
}
static void boot_editor_device_select_change(void *arg, int idx)
field_size = COLS - 1 - boot_editor->field_x;
+ boot_editor->pad = newpad(pad_height(sysinfo->n_blockdevs), COLS);
+
boot_editor->widgetset = set = widgetset_create(boot_editor,
boot_editor->scr.main_ncw,
- boot_editor->scr.sub_ncw);
+ boot_editor->pad);
+
+ widgetset_set_widget_focus(boot_editor->widgetset,
+ boot_editor_widget_focus, boot_editor);
boot_editor->widgets.device_l = widget_new_label(set, 0, 0, "device:");
boot_editor->widgets.device_f = widget_new_select(set, 0, 0,