+ widgetset_post(boot_editor->widgetset);
+
+ pad_refresh(boot_editor);
+}
+
+struct boot_editor *boot_editor_init(struct cui *cui,
+ struct pmenu_item *item,
+ const struct system_info *sysinfo,
+ void (*on_exit)(struct cui *cui,
+ struct pmenu_item *item,
+ struct pb_boot_data *bd))
+{
+ struct boot_editor *boot_editor;
+
+ boot_editor = talloc_zero(cui, struct boot_editor);
+
+ if (!boot_editor)
+ return NULL;
+
+ talloc_set_destructor(boot_editor, boot_editor_destructor);
+ boot_editor->cui = cui;
+ boot_editor->item = item;
+ boot_editor->on_exit = on_exit;
+ boot_editor->state = STATE_EDIT;
+
+ boot_editor->label_x = 1;
+ boot_editor->field_x = 9;
+
+ nc_scr_init(&boot_editor->scr, pb_boot_editor_sig, 0,
+ cui, boot_editor_process_key,
+ boot_editor_post, boot_editor_unpost, boot_editor_resize);
+
+ boot_editor->scr.frame.ltitle = talloc_strdup(boot_editor,
+ "Petitboot Option Editor");
+ boot_editor->scr.frame.rtitle = NULL;
+ boot_editor->scr.frame.help = talloc_strdup(boot_editor,
+ "Enter=accept");
+ nc_scr_frame_draw(&boot_editor->scr);
+
+ if (item) {
+ struct pb_boot_data *bd = cod_from_item(item)->bd;
+ boot_editor->image = bd->image;
+ boot_editor->initrd = bd->initrd;
+ boot_editor->dtb = bd->dtb;
+ boot_editor->args = bd->args;
+ boot_editor_find_device(boot_editor, bd, sysinfo);
+ } else {
+ boot_editor->image = boot_editor->initrd =
+ boot_editor->dtb = boot_editor->args = "";
+ }
+
+ boot_editor->pad = newpad(
+ pad_height(sysinfo ? sysinfo->n_blockdevs : 0),
+ COLS);
+
+ boot_editor_setup_widgets(boot_editor, sysinfo);
+
+ boot_editor_layout_widgets(boot_editor);
+ wrefresh(boot_editor->scr.main_ncw);
+