#include "emul_repl.h" #include "emul_inst_exec.h" #include "emul_io_std.h" #include <stdio.h> #include <string.h> #include <ncurses.h> #define READ_LINE_MAX 64 static WINDOW *win; void emul_repl_readline(char input[READ_LINE_MAX]) { printw(">>"); getnstr(input, READ_LINE_MAX); //strtok(input, "\n\0"); } void emul_repl_printline(); void emul_repl_init() { emul_inst_exec_init(); // ウィンドウポインタ取得 win = emul_getWin(); keypad(win, TRUE); } char *menu[] = { "Display help >>:help", " Exit >>:exit" }; void emul_repl_start() { char input[READ_LINE_MAX]; exitcode_t state; int y, x; char *title = "Wellcome!"; int i,j; emul_repl_init(); // title getmaxyx(win, y, x); move(y/2-2, (x-strlen(title))/2); printw("%s", title); for (i = 0; i < 2; i++) { move(y/2+i, (x-strlen(menu[i]))/2); printw("%s", menu[i]); } move(0, 0); printw(""); refresh(); getch(); wclear(win); refresh(); while (1) { emul_repl_readline(input); emul_inst_exec_loadline(input); state = emul_inst_exec_run(); if (state == Failed) { emul_out_std_debug("Abend exit\n"); } else if (state == Success) { emul_out_std_debug("Sucsess\n"); break; } } } void emul_repl_end() { emul_inst_exec_end(); }