]> git.ozlabs.org Git - petitboot/blob - ui/ncurses/nc-boot-editor.h
ui/ncurses: Add basic config editor
[petitboot] / ui / ncurses / nc-boot-editor.h
1 /*
2  *  Copyright (C) 2009 Sony Computer Entertainment Inc.
3  *  Copyright 2009 Sony Corp.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; version 2 of the License.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #if !defined(_PB_NC_KED_H)
20 #define _PB_NC_KED_H
21
22 #include <linux/input.h> /* This must be included before ncurses.h */
23 #if defined HAVE_NCURSESW_FORM_H
24 #  include <ncursesw/form.h>
25 #elif defined HAVE_NCURSES_FORM_H
26 #  include <ncurses/form.h>
27 #elif defined HAVE_FORM_H
28 #  include <form.h>
29 #else
30 #  error "Curses form.h not found."
31 #endif
32
33 #include "types/types.h"
34 #include "ui/common/ui-system.h"
35 #include "nc-scr.h"
36
37 enum boot_editor_attr_field {
38         boot_editor_attr_field_normal = A_NORMAL,
39         boot_editor_attr_field_selected = A_REVERSE,
40 };
41
42 enum boot_editor_attr_cursor {
43         boot_editor_attr_cursor_ins = A_NORMAL,
44         boot_editor_attr_cursor_ovl = A_NORMAL | A_UNDERLINE,
45 };
46
47 /**
48  * enum boot_editor_result - Result code for boot_editor:on_exit().
49  * @boot_editor_cancel: The user canceled the operation.
50  * @boot_editor_update: The args were updated.
51  */
52
53 enum boot_editor_result {
54         boot_editor_cancel,
55         boot_editor_update,
56 };
57
58 /**
59  * struct boot_editor - kexec args editor.
60  */
61
62 struct boot_editor {
63         struct nc_scr   scr;
64         void            *data;
65         struct pmenu    *original_pmenu;
66         void            (*on_exit)(struct boot_editor *boot_editor,
67                                         enum boot_editor_result result,
68                                         struct pb_boot_data *bd);
69         enum boot_editor_attr_cursor attr_cursor;
70
71         struct nc_widgetset     *widgetset;
72         struct {
73                 struct nc_widget_label          *image_l;
74                 struct nc_widget_textbox        *image_f;
75                 struct nc_widget_label          *initrd_l;
76                 struct nc_widget_textbox        *initrd_f;
77                 struct nc_widget_label          *dtb_l;
78                 struct nc_widget_textbox        *dtb_f;
79                 struct nc_widget_label          *args_l;
80                 struct nc_widget_textbox        *args_f;
81                 struct nc_widget_button         *ok_b;
82                 struct nc_widget_button         *cancel_b;
83         } widgets;
84 };
85
86 struct boot_editor *boot_editor_init(struct pmenu *menu,
87                 const struct pb_boot_data *bd,
88                 void (*on_exit)(struct boot_editor *,
89                                 enum boot_editor_result,
90                                 struct pb_boot_data *));
91
92 #endif