diff options
-rw-r--r-- | life.teliva | 36 | ||||
-rw-r--r-- | src/lcurseslib.c | 92 | ||||
-rw-r--r-- | src/lua.c | 1 |
3 files changed, 128 insertions, 1 deletions
diff --git a/life.teliva b/life.teliva index b18298f..cd84777 100644 --- a/life.teliva +++ b/life.teliva @@ -219,8 +219,42 @@ function load_file(window, filename) end +menu = {arrow="pan"} function update(window) - curses.getch() -- just check for menu keys + c = curses.getch() + if c == curses.KEY_LEFT then + for i=1,lines*4 do + for j=2,cols*2 do + grid[i][j-1] = grid[i][j] + end + grid[i][cols*2] = 0 + end + elseif c == curses.KEY_DOWN then + for i=lines*4-1,1,-1 do + for j=1,cols*2 do + grid[i+1][j] = grid[i][j] + end + end + for j=1,cols*2 do + grid[1][j] = 0 + end + elseif c == curses.KEY_UP then + for i=2,lines*4 do + for j=1,cols*2 do + grid[i][j-1] = grid[i][j+1] + end + end + for j=1,cols*2 do + grid[lines*4][j] = 0 + end + elseif c == curses.KEY_RIGHT then + for i=1,lines*4 do + for j=cols*2-1,1,-1 do + grid[i][j+1] = grid[i][j] + end + grid[i][1] = 0 + end + end end diff --git a/src/lcurseslib.c b/src/lcurseslib.c index f1a5849..67b842f 100644 --- a/src/lcurseslib.c +++ b/src/lcurseslib.c @@ -361,6 +361,98 @@ static void register_curses_constants (lua_State *L) { CC(A_CHARTEXT); CC(A_ATTRIBUTES); CC(A_COLOR); + + /* key functions */ + CC(KEY_BREAK); + CC(KEY_DOWN); + CC(KEY_UP); + CC(KEY_LEFT); + CC(KEY_RIGHT); + CC(KEY_HOME); + CC(KEY_BACKSPACE); + + CC(KEY_DL); + CC(KEY_IL); + CC(KEY_DC); + CC(KEY_IC); + CC(KEY_EIC); + CC(KEY_CLEAR); + CC(KEY_EOS); + CC(KEY_EOL); + CC(KEY_SF); + CC(KEY_SR); + CC(KEY_NPAGE); + CC(KEY_PPAGE); + CC(KEY_STAB); + CC(KEY_CTAB); + CC(KEY_CATAB); + CC(KEY_ENTER); + CC(KEY_SRESET); + CC(KEY_RESET); + CC(KEY_PRINT); + CC(KEY_LL); + CC(KEY_A1); + CC(KEY_A3); + CC(KEY_B2); + CC(KEY_C1); + CC(KEY_C3); + CC(KEY_BTAB); + CC(KEY_BEG); + CC(KEY_CANCEL); + CC(KEY_CLOSE); + CC(KEY_COMMAND); + CC(KEY_COPY); + CC(KEY_CREATE); + CC(KEY_END); + CC(KEY_EXIT); + CC(KEY_FIND); + CC(KEY_HELP); + CC(KEY_MARK); + CC(KEY_MESSAGE); /* ncurses extension: CC(KEY_MOUSE); */ + CC(KEY_MOVE); + CC(KEY_NEXT); + CC(KEY_OPEN); + CC(KEY_OPTIONS); + CC(KEY_PREVIOUS); + CC(KEY_REDO); + CC(KEY_REFERENCE); + CC(KEY_REFRESH); + CC(KEY_REPLACE); + CC(KEY_RESIZE); + CC(KEY_RESTART); + CC(KEY_RESUME); + CC(KEY_SAVE); + CC(KEY_SBEG); + CC(KEY_SCANCEL); + CC(KEY_SCOMMAND); + CC(KEY_SCOPY); + CC(KEY_SCREATE); + CC(KEY_SDC); + CC(KEY_SDL); + CC(KEY_SELECT); + CC(KEY_SEND); + CC(KEY_SEOL); + CC(KEY_SEXIT); + CC(KEY_SFIND); + CC(KEY_SHELP); + CC(KEY_SHOME); + CC(KEY_SIC); + CC(KEY_SLEFT); + CC(KEY_SMESSAGE); + CC(KEY_SMOVE); + CC(KEY_SNEXT); + CC(KEY_SOPTIONS); + CC(KEY_SPREVIOUS); + CC(KEY_SPRINT); + CC(KEY_SREDO); + CC(KEY_SREPLACE); + CC(KEY_SRIGHT); + CC(KEY_SRSUME); + CC(KEY_SSAVE); + CC(KEY_SSUSPEND); + CC(KEY_SUNDO); + CC(KEY_SUSPEND); + CC(KEY_UNDO); #undef CC } diff --git a/src/lua.c b/src/lua.c index 068af24..f41b1fa 100644 --- a/src/lua.c +++ b/src/lua.c @@ -405,6 +405,7 @@ int main (int argc, char **argv) { } setlocale(LC_ALL, ""); initscr(); + keypad(stdscr, 1); start_color(); use_default_colors(); draw_menu(L); |