summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-scr.h
diff options
context:
space:
mode:
authorGeoff Levand <geoffrey.levand@am.sony.com>2009-04-12 15:11:57 +0000
committerJeremy Kerr <jk@ozlabs.org>2009-06-30 15:29:25 +0800
commit863c609797ca6d556dd3a4586fc07a6f4a5472d4 (patch)
treea4727c82acc5795b56962928c29fa4b113fb3d82 /ui/ncurses/nc-scr.h
parent24990ffe86e0fa80dff2da365541ae67e427c57a (diff)
downloadtalos-petitboot-863c609797ca6d556dd3a4586fc07a6f4a5472d4.tar.gz
talos-petitboot-863c609797ca6d556dd3a4586fc07a6f4a5472d4.zip
Add ncurses UI menu
Add support for an ncurses UI menu object. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses/nc-scr.h')
-rw-r--r--ui/ncurses/nc-scr.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/ui/ncurses/nc-scr.h b/ui/ncurses/nc-scr.h
new file mode 100644
index 0000000..c08fcd4
--- /dev/null
+++ b/ui/ncurses/nc-scr.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 Sony Computer Entertainment Inc.
+ * Copyright 2009 Sony Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if !defined(_PB_NC_SCR_H)
+#define _PB_NC_SCR_H
+
+#include <ncurses.h>
+
+#define DBG(fmt, args...) pb_log("DBG: " fmt, ## args)
+#define DBGS(fmt, args...) \
+ pb_log("DBG:%s:%d: " fmt, __func__, __LINE__, ## args)
+
+enum pb_nc_sig {
+ pb_cui_sig = 111,
+ pb_pmenu_sig = 222,
+ pb_item_sig = 333,
+ pb_ked_sig = 444,
+ pb_removed_sig = -555,
+};
+
+void nc_start(void);
+void nc_atexit(void);
+
+static inline void nc_flush_keys(void)
+{
+ while (getch() != ERR)
+ (void)0;
+}
+
+enum nc_scr_pos {
+ nc_scr_pos_title = 0,
+ nc_scr_pos_title_sep = 1,
+ nc_scr_pos_sub = 2,
+
+ nc_scr_pos_help_sep = 3,
+ nc_scr_pos_help = 2,
+ nc_scr_pos_status = 1,
+
+ nc_scr_frame_lines = 5,
+};
+
+struct nc_frame {
+ char *title;
+ char *help;
+ char *status;
+};
+
+struct nc_scr {
+ enum pb_nc_sig sig;
+ struct nc_frame frame;
+ WINDOW *main_ncw;
+ WINDOW *sub_ncw;
+ void *ui_ctx;
+ int (*post)(struct nc_scr *scr);
+ int (*unpost)(struct nc_scr *scr);
+ void (*process_key)(struct nc_scr *scr);
+ void (*resize)(struct nc_scr *scr);
+};
+
+int nc_scr_init(struct nc_scr *scr, enum pb_nc_sig sig, int begin_x,
+ void *ui_ctx,
+ void (*process_key)(struct nc_scr *),
+ int (*post)(struct nc_scr *),
+ int (*unpost)(struct nc_scr *),
+ void (*resize)(struct nc_scr *));
+void nc_scr_status_free(struct nc_scr *scr);
+void nc_scr_status_printf(struct nc_scr *scr, const char *format, ...);
+void nc_scr_frame_draw(struct nc_scr *scr);
+
+#endif
OpenPOWER on IntegriCloud