]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Move general nc init code to cui module
authorJeremy Kerr <jk@ozlabs.org>
Tue, 15 Oct 2013 07:51:49 +0000 (15:51 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 13 Nov 2013 09:31:04 +0000 (17:31 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/nc-cui.c
ui/ncurses/nc-scr.c
ui/ncurses/nc-scr.h

index e02c6a66b2a19669a9d6de229a18ee348a2069ed..adbb3d60d9875904ef28878f42f7b820bf1cc128 100644 (file)
@@ -40,6 +40,35 @@ static struct cui_opt_data *cod_from_item(struct pmenu_item *item)
        return item->data;
 }
 
        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.
  *
 /**
  * cui_abort - Signal the main cui program loop to exit.
  *
@@ -558,8 +587,8 @@ retry_start:
                goto fail_client_init;
        }
 
                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);
 
        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;
 }
 
        return cui->abort ? 0 : -1;
 }
index 9a3f3dfc77d0dd1b45dfdbdfff40256ba0e36899..c6172e1e4c6d11e0e022d92cbc6fef9a2f7c90c8 100644 (file)
 
 #include "nc-scr.h"
 
 
 #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);
 static void nc_scr_status_clear(struct nc_scr *scr)
 {
        mvwhline(scr->main_ncw, LINES - nc_scr_pos_status, 0, ' ', COLS);
index 9f80e65c1462727718d03a4b1456110a14f0e332..5c4b97b1c89418acc8719edf1d6ca5deb01a69d2 100644 (file)
@@ -47,9 +47,6 @@ enum pb_nc_sig {
        pb_removed_sig     = -555,
 };
 
        pb_removed_sig     = -555,
 };
 
-void nc_start(void);
-void nc_atexit(void);
-
 static inline void nc_flush_keys(void)
 {
        while (getch() != ERR)
 static inline void nc_flush_keys(void)
 {
        while (getch() != ERR)