summaryrefslogtreecommitdiffstats
path: root/ui/ncurses
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-15 15:51:49 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-11-13 17:31:04 +0800
commit31ae49c6bfaa3cd65969bff7448be0f6385a6255 (patch)
tree7ebd5ba1e2ea8e3632e4b32e5503dbaf0f5dc634 /ui/ncurses
parent52bec18801b226b57f53d9f075addd2c07caa3db (diff)
downloadpetitboot-31ae49c6bfaa3cd65969bff7448be0f6385a6255.zip
petitboot-31ae49c6bfaa3cd65969bff7448be0f6385a6255.tar.gz
ui/ncurses: Move general nc init code to cui module
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses')
-rw-r--r--ui/ncurses/nc-cui.c35
-rw-r--r--ui/ncurses/nc-scr.c29
-rw-r--r--ui/ncurses/nc-scr.h3
3 files changed, 32 insertions, 35 deletions
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index e02c6a6..adbb3d6 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -40,6 +40,35 @@ static struct cui_opt_data *cod_from_item(struct pmenu_item *item)
return item->data;
}
+static void cui_start(void)
+{
+ initscr(); /* Initialize ncurses. */
+ cbreak(); /* Disable line buffering. */
+ noecho(); /* Disable getch() echo. */
+ keypad(stdscr, TRUE); /* Enable num keypad keys. */
+ nonl(); /* Disable new-line translation. */
+ intrflush(stdscr, FALSE); /* Disable interrupt flush. */
+ curs_set(0); /* Make cursor invisible */
+ nodelay(stdscr, TRUE); /* Enable non-blocking getch() */
+
+ /* We may be operating with an incorrect $TERM type; in this case
+ * the keymappings will be slightly broken. We want at least
+ * backspace to work though, so we'll define both DEL and ^H to
+ * map to backspace */
+ define_key("\x7f", KEY_BACKSPACE);
+ define_key("\x08", KEY_BACKSPACE);
+
+ while (getch() != ERR) /* flush stdin */
+ (void)0;
+}
+
+static void cui_atexit(void)
+{
+ clear();
+ refresh();
+ endwin();
+}
+
/**
* cui_abort - Signal the main cui program loop to exit.
*
@@ -558,8 +587,8 @@ retry_start:
goto fail_client_init;
}
- atexit(nc_atexit);
- nc_start();
+ atexit(cui_atexit);
+ cui_start();
waiter_register_io(cui->waitset, STDIN_FILENO, WAIT_IN,
cui_process_key, cui);
@@ -618,7 +647,7 @@ int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item)
}
}
- nc_atexit();
+ cui_atexit();
return cui->abort ? 0 : -1;
}
diff --git a/ui/ncurses/nc-scr.c b/ui/ncurses/nc-scr.c
index 9a3f3df..c6172e1 100644
--- a/ui/ncurses/nc-scr.c
+++ b/ui/ncurses/nc-scr.c
@@ -29,35 +29,6 @@
#include "nc-scr.h"
-void nc_start(void)
-{
- initscr(); /* Initialize ncurses. */
- cbreak(); /* Disable line buffering. */
- noecho(); /* Disable getch() echo. */
- keypad(stdscr, TRUE); /* Enable num keypad keys. */
- nonl(); /* Disable new-line translation. */
- intrflush(stdscr, FALSE); /* Disable interrupt flush. */
- curs_set(0); /* Make cursor invisible */
- nodelay(stdscr, TRUE); /* Enable non-blocking getch() */
-
- /* We may be operating with an incorrect $TERM type; in this case
- * the keymappings will be slightly broken. We want at least
- * backspace to work though, so we'll define both DEL and ^H to
- * map to backspace */
- define_key("\x7f", KEY_BACKSPACE);
- define_key("\x08", KEY_BACKSPACE);
-
- while (getch() != ERR) /* flush stdin */
- (void)0;
-}
-
-void nc_atexit(void)
-{
- clear();
- refresh();
- endwin();
-}
-
static void nc_scr_status_clear(struct nc_scr *scr)
{
mvwhline(scr->main_ncw, LINES - nc_scr_pos_status, 0, ' ', COLS);
diff --git a/ui/ncurses/nc-scr.h b/ui/ncurses/nc-scr.h
index 9f80e65..5c4b97b 100644
--- a/ui/ncurses/nc-scr.h
+++ b/ui/ncurses/nc-scr.h
@@ -47,9 +47,6 @@ enum pb_nc_sig {
pb_removed_sig = -555,
};
-void nc_start(void);
-void nc_atexit(void);
-
static inline void nc_flush_keys(void)
{
while (getch() != ERR)
OpenPOWER on IntegriCloud