diff --git a/emul_repl.c b/emul_repl.c index 2a40397..61019f5 100644 --- a/emul_repl.c +++ b/emul_repl.c @@ -10,9 +10,28 @@ static WINDOW *win; void emul_repl_readline(char input[READ_LINE_MAX]) { + char c; + int i = 0; + int y, x; printw(">>"); - getnstr(input, READ_LINE_MAX); - //strtok(input, "\n\0"); + refresh(); + noecho(); + while( (c = getch()) != '\n' ) { + if (c == KEY_BACKSPACE) { + getyx(win, y, x); + input[--i] = '\0'; + move(y, x-1); + } else { + input[i++] = c; + echochar(c); + } + } + echo(); + input[i++] = '\0'; + printw("\r"); + clrtoeol(); + //printw("\n"); + refresh(); } void emul_repl_printline(); @@ -21,7 +40,7 @@ emul_inst_exec_init(); // ウィンドウポインタ取得 win = emul_getWin(); - keypad(win, TRUE); + keypad(stdscr, TRUE); } char *menu[] = {