]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-scr.c
ui/ncurses: Allow both DEL and ^H to map to backspace
[petitboot] / ui / ncurses / nc-scr.c
index 062d34a7b177d835b1b81e5befc5b2fa95a37249..ff20d637781289572d962430b0a094e7195447ce 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "config.h"
+
+#define _GNU_SOURCE
+
 #include <assert.h>
 #include <stdarg.h>
 
 #include <assert.h>
 #include <stdarg.h>
 
@@ -34,6 +38,14 @@ void nc_start(void)
        intrflush(stdscr, FALSE);       /* Disable interrupt flush. */
        curs_set(0);                    /* Make cursor invisible */
        nodelay(stdscr, TRUE);          /* Enable non-blocking getch() */
        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;
 }
        while (getch() != ERR)          /* flush stdin */
                (void)0;
 }