]> git.ozlabs.org Git - petitboot/blob - ui/ncurses/nc-config.c
ui/ncurses: Add help to boot editor screen
[petitboot] / ui / ncurses / nc-config.c
1 /*
2  *  Copyright (C) 2013 IBM Corporation
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; version 2 of the License.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17
18 #if defined(HAVE_CONFIG_H)
19 #include "config.h"
20 #endif
21
22 #include <errno.h>
23 #include <stdlib.h>
24 #include <string.h>
25
26 #include <pb-config/pb-config.h>
27 #include <talloc/talloc.h>
28 #include <types/types.h>
29 #include <log/log.h>
30
31 #include "nc-cui.h"
32 #include "nc-config.h"
33 #include "nc-widgets.h"
34
35 #define N_FIELDS        24
36
37 extern const char *config_help_text;
38
39 enum net_conf_type {
40         NET_CONF_TYPE_DHCP_ALL,
41         NET_CONF_TYPE_DHCP_ONE,
42         NET_CONF_TYPE_STATIC,
43 };
44
45 struct config_screen {
46         struct nc_scr           scr;
47         struct cui              *cui;
48         struct nc_widgetset     *widgetset;
49         WINDOW                  *pad;
50
51         bool                    exit;
52         bool                    show_help;
53         void                    (*on_exit)(struct cui *);
54
55         int                     scroll_y;
56
57         int                     label_x;
58         int                     field_x;
59         int                     network_config_y;
60
61         enum net_conf_type      net_conf_type;
62
63         struct {
64                 struct nc_widget_checkbox       *autoboot_f;
65                 struct nc_widget_label          *autoboot_l;
66                 struct nc_widget_textbox        *timeout_f;
67                 struct nc_widget_label          *timeout_l;
68                 struct nc_widget_label          *timeout_help_l;
69
70                 struct nc_widget_label          *network_l;
71                 struct nc_widget_select         *network_f;
72
73                 struct nc_widget_label          *iface_l;
74                 struct nc_widget_select         *iface_f;
75                 struct nc_widget_label          *ip_addr_l;
76                 struct nc_widget_textbox        *ip_addr_f;
77                 struct nc_widget_label          *ip_mask_l;
78                 struct nc_widget_textbox        *ip_mask_f;
79                 struct nc_widget_label          *ip_addr_mask_help_l;
80                 struct nc_widget_label          *gateway_l;
81                 struct nc_widget_textbox        *gateway_f;
82                 struct nc_widget_label          *gateway_help_l;
83                 struct nc_widget_label          *dns_l;
84                 struct nc_widget_textbox        *dns_f;
85                 struct nc_widget_label          *dns_dhcp_help_l;
86                 struct nc_widget_label          *dns_help_l;
87
88                 struct nc_widget_button         *ok_b;
89                 struct nc_widget_button         *help_b;
90                 struct nc_widget_button         *cancel_b;
91         } widgets;
92 };
93
94 static struct config_screen *config_screen_from_scr(struct nc_scr *scr)
95 {
96         struct config_screen *config_screen;
97
98         assert(scr->sig == pb_config_screen_sig);
99         config_screen = (struct config_screen *)
100                 ((char *)scr - (size_t)&((struct config_screen *)0)->scr);
101         assert(config_screen->scr.sig == pb_config_screen_sig);
102         return config_screen;
103 }
104
105 static void pad_refresh(struct config_screen *screen)
106 {
107         int y, x, rows, cols;
108
109         getmaxyx(screen->scr.sub_ncw, rows, cols);
110         getbegyx(screen->scr.sub_ncw, y, x);
111
112         prefresh(screen->pad, screen->scroll_y, 0, y, x, rows, cols);
113 }
114
115 static void config_screen_process_key(struct nc_scr *scr, int key)
116 {
117         struct config_screen *screen = config_screen_from_scr(scr);
118         bool handled;
119
120         handled = widgetset_process_key(screen->widgetset, key);
121         if (screen->exit) {
122                 screen->on_exit(screen->cui);
123
124         } else if (screen->show_help || (!handled && key == 'h')) {
125                 screen->show_help = false;
126                 cui_show_help(screen->cui, "System Configuration",
127                                 config_help_text);
128
129         } else if (handled) {
130                 pad_refresh(screen);
131         }
132 }
133
134 static void config_screen_resize(struct nc_scr *scr)
135 {
136         struct config_screen *screen = config_screen_from_scr(scr);
137         (void)screen;
138 }
139
140 static int config_screen_post(struct nc_scr *scr)
141 {
142         struct config_screen *screen = config_screen_from_scr(scr);
143         widgetset_post(screen->widgetset);
144         nc_scr_frame_draw(scr);
145         redrawwin(scr->main_ncw);
146         wrefresh(screen->scr.main_ncw);
147         pad_refresh(screen);
148         return 0;
149 }
150
151 static int config_screen_unpost(struct nc_scr *scr)
152 {
153         struct config_screen *screen = config_screen_from_scr(scr);
154         widgetset_unpost(screen->widgetset);
155         return 0;
156 }
157
158 struct nc_scr *config_screen_scr(struct config_screen *screen)
159 {
160         return &screen->scr;
161 }
162
163 static int screen_process_form(struct config_screen *screen)
164 {
165         const struct system_info *sysinfo = screen->cui->sysinfo;
166         enum net_conf_type net_conf_type;
167         struct interface_config *iface;
168         struct config *config;
169         char *str, *end;
170         int rc;
171
172         config = config_copy(screen, screen->cui->config);
173
174         config->autoboot_enabled =
175                 widget_checkbox_get_value(screen->widgets.autoboot_f);
176
177
178         str = widget_textbox_get_value(screen->widgets.timeout_f);
179         if (str) {
180                 unsigned long x;
181                 errno = 0;
182                 x = strtoul(str, &end, 10);
183                 if (!errno && end != str)
184                         config->autoboot_timeout_sec = x;
185         }
186
187         net_conf_type = widget_select_get_value(screen->widgets.network_f);
188
189         /* if we don't have any network interfaces, prevent per-interface
190          * configuration */
191         if (sysinfo->n_interfaces == 0)
192                 net_conf_type = NET_CONF_TYPE_DHCP_ALL;
193
194         if (net_conf_type == NET_CONF_TYPE_DHCP_ALL) {
195                 config->network.n_interfaces = 0;
196
197         } else {
198                 int idx;
199
200                 iface = talloc_zero(config, struct interface_config);
201                 config->network.n_interfaces = 1;
202                 config->network.interfaces = talloc_array(config,
203                                 struct interface_config *, 1);
204                 config->network.interfaces[0] = iface;
205
206                 /* copy hwaddr (from the sysinfo interface data) to
207                  * the configuration */
208                 idx = widget_select_get_value(screen->widgets.iface_f);
209                 memcpy(iface->hwaddr, sysinfo->interfaces[idx]->hwaddr,
210                                 sizeof(iface->hwaddr));
211         }
212
213         if (net_conf_type == NET_CONF_TYPE_DHCP_ONE) {
214                 iface->method = CONFIG_METHOD_DHCP;
215         }
216
217         if (net_conf_type == NET_CONF_TYPE_STATIC) {
218                 char *ip, *mask, *gateway;
219
220                 ip = widget_textbox_get_value(screen->widgets.ip_addr_f);
221                 mask = widget_textbox_get_value(screen->widgets.ip_mask_f);
222                 gateway = widget_textbox_get_value(screen->widgets.gateway_f);
223
224                 if (!ip || !*ip || !mask || !*mask) {
225                         screen->scr.frame.status =
226                                 "No IP / mask values are set";
227                         nc_scr_frame_draw(&screen->scr);
228                         talloc_free(config);
229                         return -1;
230                 }
231
232                 iface->method = CONFIG_METHOD_STATIC;
233                 iface->static_config.address = talloc_asprintf(iface, "%s/%s",
234                                 ip, mask);
235                 iface->static_config.gateway = talloc_strdup(iface, gateway);
236         }
237
238         str = widget_textbox_get_value(screen->widgets.dns_f);
239         if (str && strlen(str)) {
240                 char *dns, *tmp;
241                 int i;
242
243                 for (;;) {
244                         dns = strtok_r(str, " \t", &tmp);
245
246                         if (!dns)
247                                 break;
248
249                         i = config->network.n_dns_servers++;
250                         config->network.dns_servers = talloc_realloc(config,
251                                         config->network.dns_servers,
252                                         const char *,
253                                         config->network.n_dns_servers);
254                         config->network.dns_servers[i] =
255                                 talloc_strdup(config, dns);
256
257                         str = NULL;
258                 }
259         }
260
261         rc = cui_send_config(screen->cui, config);
262         talloc_free(config);
263
264         if (rc)
265                 pb_log("cui_send_config failed!\n");
266         else
267                 pb_debug("config sent!\n");
268
269         return 0;
270 }
271
272 static void ok_click(void *arg)
273 {
274         struct config_screen *screen = arg;
275         if (screen_process_form(screen))
276                 /* errors are written to the status line, so we'll need
277                  * to refresh */
278                 wrefresh(screen->scr.main_ncw);
279         else
280                 screen->exit = true;
281 }
282
283 static void help_click(void *arg)
284 {
285         struct config_screen *screen = arg;
286         screen->show_help = true;
287 }
288
289 static void cancel_click(void *arg)
290 {
291         struct config_screen *screen = arg;
292         screen->exit = true;
293 }
294
295 static int layout_pair(struct config_screen *screen, int y,
296                 struct nc_widget_label *label,
297                 struct nc_widget *field)
298 {
299         struct nc_widget *label_w = widget_label_base(label);
300         widget_move(label_w, y, screen->label_x);
301         widget_move(field, y, screen->field_x);
302         return max(widget_height(label_w), widget_height(field));
303 }
304
305 static void config_screen_layout_widgets(struct config_screen *screen,
306                 enum net_conf_type net_conf)
307 {
308         struct nc_widget *wl, *wf, *wh;
309         int y, x, help_x;
310         bool show;
311
312         y = 1;
313         help_x = screen->field_x + 2 +
314                 widget_width(widget_textbox_base(screen->widgets.dns_f));
315
316         y += layout_pair(screen, y, screen->widgets.autoboot_l,
317                         widget_checkbox_base(screen->widgets.autoboot_f));
318
319         wf = widget_textbox_base(screen->widgets.timeout_f);
320         widget_move(widget_label_base(screen->widgets.timeout_l),
321                         y, screen->label_x);
322         widget_move(wf, y, screen->field_x);
323         widget_move(widget_label_base(screen->widgets.timeout_help_l),
324                         y, screen->field_x + widget_width(wf) + 1);
325
326         y += 2;
327
328         y += layout_pair(screen, y, screen->widgets.network_l,
329                         widget_select_base(screen->widgets.network_f));
330
331         y += 1;
332
333         /* conditionally show iface select */
334         wl = widget_label_base(screen->widgets.iface_l);
335         wf = widget_select_base(screen->widgets.iface_f);
336
337         show = net_conf == NET_CONF_TYPE_DHCP_ONE ||
338                 net_conf == NET_CONF_TYPE_STATIC;
339
340         widget_set_visible(wl, show);
341         widget_set_visible(wf, show);
342
343         if (show)
344                 y += layout_pair(screen, y, screen->widgets.iface_l, wf) + 1;
345
346         /* conditionally show static IP params */
347         show = net_conf == NET_CONF_TYPE_STATIC;
348
349         wl = widget_label_base(screen->widgets.ip_addr_l);
350         wf = widget_textbox_base(screen->widgets.ip_addr_f);
351         widget_set_visible(wl, show);
352         widget_set_visible(wf, show);
353         x = screen->field_x + widget_width(wf) + 1;
354
355         if (show)
356                 layout_pair(screen, y, screen->widgets.ip_addr_l, wf);
357
358         wl = widget_label_base(screen->widgets.ip_mask_l);
359         wf = widget_textbox_base(screen->widgets.ip_mask_f);
360         widget_set_visible(wl, show);
361         widget_set_visible(wf, show);
362
363         if (show) {
364                 widget_move(wl, y, x);
365                 widget_move(wf, y, x + 2);
366         }
367
368         /* help for IP/mask */
369         wh = widget_label_base(screen->widgets.ip_addr_mask_help_l);
370         widget_set_visible(wh, show);
371         if (show) {
372                 widget_move(wh, y, help_x);
373                 y++;
374         }
375
376         wl = widget_label_base(screen->widgets.gateway_l);
377         wf = widget_textbox_base(screen->widgets.gateway_f);
378         wh = widget_label_base(screen->widgets.gateway_help_l);
379         widget_set_visible(wl, show);
380         widget_set_visible(wf, show);
381         widget_set_visible(wh, show);
382
383         if (show) {
384                 layout_pair(screen, y, screen->widgets.gateway_l, wf);
385                 widget_move(wh, y, help_x);
386                 y++;
387         }
388
389         wh = widget_label_base(screen->widgets.dns_help_l);
390         layout_pair(screen, y, screen->widgets.dns_l,
391                         widget_textbox_base(screen->widgets.dns_f));
392         widget_move(wh, y, help_x);
393         y++;
394
395         /* we show the DNS/DHCP help if we're configuring DHCP */
396         show = net_conf != NET_CONF_TYPE_STATIC;
397         wl = widget_label_base(screen->widgets.dns_dhcp_help_l);
398         widget_set_visible(wl, show);
399         if (show) {
400                 widget_move(wl, y, screen->field_x);
401                 y += 1;
402         }
403
404         y += 1;
405
406         widget_move(widget_button_base(screen->widgets.ok_b),
407                         y, screen->field_x);
408         widget_move(widget_button_base(screen->widgets.help_b),
409                         y, screen->field_x + 10);
410         widget_move(widget_button_base(screen->widgets.cancel_b),
411                         y, screen->field_x + 20);
412 }
413
414 static void config_screen_network_change(void *arg, int value)
415 {
416         struct config_screen *screen = arg;
417         screen->net_conf_type = value;
418         widgetset_unpost(screen->widgetset);
419         config_screen_layout_widgets(screen, value);
420         widgetset_post(screen->widgetset);
421 }
422
423 static struct interface_config *first_active_interface(
424                 const struct config *config)
425 {
426         unsigned int i;
427
428         for (i = 0; i < config->network.n_interfaces; i++) {
429                 if (config->network.interfaces[i]->ignore)
430                         continue;
431                 return config->network.interfaces[i];
432         }
433         return NULL;
434 }
435
436 static enum net_conf_type find_net_conf_type(const struct config *config)
437 {
438         struct interface_config *ifcfg;
439
440         ifcfg = first_active_interface(config);
441
442         if (!ifcfg)
443                 return NET_CONF_TYPE_DHCP_ALL;
444
445         else if (ifcfg->method == CONFIG_METHOD_DHCP)
446                 return NET_CONF_TYPE_DHCP_ONE;
447
448         else if (ifcfg->method == CONFIG_METHOD_STATIC)
449                 return NET_CONF_TYPE_STATIC;
450
451         assert(0);
452         return NET_CONF_TYPE_DHCP_ALL;
453 }
454
455 static void config_screen_setup_empty(struct config_screen *screen)
456 {
457         widget_new_label(screen->widgetset, 2, screen->field_x,
458                         "Waiting for configuration data...");
459         screen->widgets.cancel_b = widget_new_button(screen->widgetset,
460                         4, screen->field_x, 6, "Cancel", cancel_click, screen);
461 }
462
463
464 static void config_screen_setup_widgets(struct config_screen *screen,
465                 const struct config *config,
466                 const struct system_info *sysinfo)
467 {
468         struct nc_widgetset *set = screen->widgetset;
469         struct interface_config *ifcfg;
470         char *str, *ip, *mask, *gw;
471         enum net_conf_type type;
472         unsigned int i;
473
474         build_assert(sizeof(screen->widgets) / sizeof(struct widget *)
475                         == N_FIELDS);
476
477         type = screen->net_conf_type;
478         ifcfg = first_active_interface(config);
479
480         screen->widgets.autoboot_l = widget_new_label(set, 0, 0, "Autoboot:");
481         screen->widgets.autoboot_f = widget_new_checkbox(set, 0, 0,
482                                         config->autoboot_enabled);
483
484         str = talloc_asprintf(screen, "%d", config->autoboot_timeout_sec);
485         screen->widgets.timeout_l = widget_new_label(set, 0, 0, "Timeout:");
486         screen->widgets.timeout_f = widget_new_textbox(set, 0, 0, 5, str);
487         screen->widgets.timeout_help_l = widget_new_label(set, 0, 0, "seconds");
488
489         widget_textbox_set_validator_integer(screen->widgets.timeout_f, 0, 999);
490
491         screen->widgets.network_l = widget_new_label(set, 0, 0, "Network");
492         screen->widgets.network_f = widget_new_select(set, 0, 0, 50);
493
494         widget_select_add_option(screen->widgets.network_f,
495                                         NET_CONF_TYPE_DHCP_ALL,
496                                         "DHCP on all active interfaces",
497                                         type == NET_CONF_TYPE_DHCP_ALL);
498         widget_select_add_option(screen->widgets.network_f,
499                                         NET_CONF_TYPE_DHCP_ONE,
500                                         "DHCP on a specific interface",
501                                         type == NET_CONF_TYPE_DHCP_ONE);
502         widget_select_add_option(screen->widgets.network_f,
503                                         NET_CONF_TYPE_STATIC,
504                                         "Static IP configuration",
505                                         type == NET_CONF_TYPE_STATIC);
506
507         widget_select_on_change(screen->widgets.network_f,
508                         config_screen_network_change, screen);
509
510         screen->widgets.iface_l = widget_new_label(set, 0, 0, "Device:");
511         screen->widgets.iface_f = widget_new_select(set, 0, 0, 50);
512
513         for (i = 0; i < sysinfo->n_interfaces; i++) {
514                 struct interface_info *info = sysinfo->interfaces[i];
515                 char str[50], mac[20];
516                 bool is_default;
517
518                 is_default = ifcfg && !memcmp(ifcfg->hwaddr, info->hwaddr,
519                                         sizeof(ifcfg->hwaddr));
520
521                 mac_str(info->hwaddr, info->hwaddr_size, mac, sizeof(mac));
522                 snprintf(str, sizeof(str), "%s [%s, %s]", info->name, mac,
523                                 info->link ? "link up" : "link down");
524
525                 widget_select_add_option(screen->widgets.iface_f,
526                                                 i, str, is_default);
527         }
528
529         gw = ip = mask = NULL;
530         if (ifcfg && ifcfg->method == CONFIG_METHOD_STATIC) {
531                 char *sep;
532
533                 str = talloc_strdup(screen, ifcfg->static_config.address);
534                 sep = strchr(str, '/');
535                 ip = str;
536
537                 if (sep) {
538                         *sep = '\0';
539                         mask = sep + 1;
540                 }
541                 gw = ifcfg->static_config.gateway;
542         }
543
544         screen->widgets.ip_addr_l = widget_new_label(set, 0, 0, "IP/mask:");
545         screen->widgets.ip_addr_f = widget_new_textbox(set, 0, 0, 16, ip);
546         screen->widgets.ip_mask_l = widget_new_label(set, 0, 0, "/");
547         screen->widgets.ip_mask_f = widget_new_textbox(set, 0, 0, 4, mask);
548         screen->widgets.ip_addr_mask_help_l =
549                 widget_new_label(set, 0, 0, "(eg. 192.168.0.10 / 24)");
550
551         widget_textbox_set_validator_ipv4(screen->widgets.ip_addr_f);
552         widget_textbox_set_validator_integer(screen->widgets.ip_mask_f, 1, 31);
553
554         screen->widgets.gateway_l = widget_new_label(set, 0, 0, "Gateway:");
555         screen->widgets.gateway_f = widget_new_textbox(set, 0, 0, 16, gw);
556         screen->widgets.gateway_help_l =
557                 widget_new_label(set, 0, 0, "(eg. 192.168.0.1)");
558
559         widget_textbox_set_validator_ipv4(screen->widgets.gateway_f);
560
561         str = talloc_strdup(screen, "");
562         for (i = 0; i < config->network.n_dns_servers; i++) {
563                 str = talloc_asprintf_append(str, "%s%s",
564                                 (i == 0) ? "" : " ",
565                                 config->network.dns_servers[i]);
566         }
567
568         screen->widgets.dns_l = widget_new_label(set, 0, 0, "DNS Server(s):");
569         screen->widgets.dns_f = widget_new_textbox(set, 0, 0, 32, str);
570         screen->widgets.dns_help_l =
571                 widget_new_label(set, 0, 0, "(eg. 192.168.0.2)");
572
573         widget_textbox_set_validator_ipv4_multi(screen->widgets.dns_f);
574
575         screen->widgets.dns_dhcp_help_l = widget_new_label(set, 0, 0,
576                         "(if not provided by DHCP server)");
577
578         screen->widgets.ok_b = widget_new_button(set, 0, 0, 6, "OK",
579                         ok_click, screen);
580         screen->widgets.help_b = widget_new_button(set, 0, 0, 6, "Help",
581                         help_click, screen);
582         screen->widgets.cancel_b = widget_new_button(set, 0, 0, 6, "Cancel",
583                         cancel_click, screen);
584 }
585
586 static void config_screen_widget_focus(struct nc_widget *widget, void *arg)
587 {
588         struct config_screen *screen = arg;
589         int w_y, s_max;
590
591         w_y = widget_y(widget) + widget_focus_y(widget);
592         s_max = getmaxy(screen->scr.sub_ncw) - 1;
593
594         if (w_y < screen->scroll_y)
595                 screen->scroll_y = w_y;
596
597         else if (w_y + screen->scroll_y + 1 > s_max)
598                 screen->scroll_y = 1 + w_y - s_max;
599
600         else
601                 return;
602
603         pad_refresh(screen);
604 }
605
606 static void config_screen_draw(struct config_screen *screen,
607                 const struct config *config,
608                 const struct system_info *sysinfo)
609 {
610         bool repost = false;
611         int height;
612
613         /* The size of the pad we'll need depends on the number of interfaces.
614          *
615          * We use N_FIELDS (which is quite conservative, as some fields share
616          * a line) as a base, then add 3 (as the network select field is
617          * takes 3 lines), and n_interfaces (as the network interface field
618          * has n_interfaces lines).
619          */
620         height = N_FIELDS + 3;
621         if (sysinfo)
622                 height += sysinfo->n_interfaces;
623         if (!screen->pad || getmaxy(screen->pad) < height) {
624                 if (screen->pad)
625                         delwin(screen->pad);
626                 screen->pad = newpad(height, COLS);
627         }
628
629         if (screen->widgetset) {
630                 widgetset_unpost(screen->widgetset);
631                 talloc_free(screen->widgetset);
632                 repost = true;
633         }
634
635         screen->widgetset = widgetset_create(screen, screen->scr.main_ncw,
636                         screen->pad);
637         widgetset_set_widget_focus(screen->widgetset,
638                         config_screen_widget_focus, screen);
639
640         if (!config || !sysinfo) {
641                 config_screen_setup_empty(screen);
642         } else {
643                 screen->net_conf_type = find_net_conf_type(config);
644
645                 config_screen_setup_widgets(screen, config, sysinfo);
646                 config_screen_layout_widgets(screen, screen->net_conf_type);
647         }
648
649         if (repost)
650                 widgetset_post(screen->widgetset);
651 }
652
653 void config_screen_update(struct config_screen *screen,
654                 const struct config *config,
655                 const struct system_info *sysinfo)
656 {
657         config_screen_draw(screen, config, sysinfo);
658         pad_refresh(screen);
659 }
660
661 static int config_screen_destroy(void *arg)
662 {
663         struct config_screen *screen = arg;
664         if (screen->pad)
665                 delwin(screen->pad);
666         return 0;
667 }
668
669 struct config_screen *config_screen_init(struct cui *cui,
670                 const struct config *config,
671                 const struct system_info *sysinfo,
672                 void (*on_exit)(struct cui *))
673 {
674         struct config_screen *screen;
675
676         screen = talloc_zero(cui, struct config_screen);
677         talloc_set_destructor(screen, config_screen_destroy);
678         nc_scr_init(&screen->scr, pb_config_screen_sig, 0,
679                         cui, config_screen_process_key,
680                         config_screen_post, config_screen_unpost,
681                         config_screen_resize);
682
683         screen->cui = cui;
684         screen->on_exit = on_exit;
685         screen->label_x = 2;
686         screen->field_x = 17;
687
688         screen->scr.frame.ltitle = talloc_strdup(screen,
689                         "Petitboot System Configuration");
690         screen->scr.frame.rtitle = NULL;
691         screen->scr.frame.help = talloc_strdup(screen,
692                         "tab=next, shift+tab=previous");
693         nc_scr_frame_draw(&screen->scr);
694
695         scrollok(screen->scr.sub_ncw, true);
696
697         config_screen_draw(screen, config, sysinfo);
698
699         return screen;
700 }