From 8f1c876f63727f87227ec7739f63375931ccf847 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Tue, 18 Mar 2008 15:56:19 -0500 Subject: finish filling out the setup_term function --- TODO | 3 +-- src/curses.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 8b56bba..dce7e9d 100644 --- a/TODO +++ b/TODO @@ -3,9 +3,8 @@ - reading from the screen (curs_instr, curs_inch) - reading input (ungetch (curs_getch), curs_getstr - attribute support (curs_attr) -- finish up curs_inopts and curs_outopts - finish up curs_color (color_content, pair_content) -- scrolling support (curs_scroll) +- scrolling support (curs_scroll, setscrreg (curs_outopts)) - support the rest of the refresh options (curs_refresh) - window background support (curs_bkgd) - multiple window support (all fns that start with w, curs_overlay, curs_initscr, curs_window, curs_getyx (par, beg), curs_touch, curs_overlay) diff --git a/src/curses.c b/src/curses.c index 469e18c..125578f 100644 --- a/src/curses.c +++ b/src/curses.c @@ -226,22 +226,70 @@ static int l_setup_term(lua_State* L) const char* str; str = lua_tostring(L, -2); - /* XXX: this certainly needs expansion */ - if (!strcmp(str, "nl")) { - ret += ((lua_toboolean(L, -1) ? nl() : nonl()) == OK); - } - else if (!strcmp(str, "cbreak")) { + if (!strcmp(str, "cbreak")) { ret += ((lua_toboolean(L, -1) ? cbreak() : nocbreak()) == OK); } else if (!strcmp(str, "echo")) { ret += ((lua_toboolean(L, -1) ? echo() : noecho()) == OK); } + else if (!strcmp(str, "halfdelay")) { + ret += (halfdelay(lua_tointeger(L, -1)) == OK); + } + else if (!strcmp(str, "intrflush")) { + ret += (intrflush(stdscr, lua_toboolean(L, -1)) == OK); + } else if (!strcmp(str, "keypad")) { ret += (keypad(stdscr, lua_toboolean(L, -1)) == OK); } + else if (!strcmp(str, "meta")) { + ret += (meta(stdscr, lua_toboolean(L, -1)) == OK); + } + else if (!strcmp(str, "nodelay")) { + ret += (nodelay(stdscr, lua_toboolean(L, -1)) == OK); + } + else if (!strcmp(str, "raw")) { + ret += ((lua_toboolean(L, -1) ? raw() : noraw()) == OK); + } + else if (!strcmp(str, "qiflush")) { + lua_toboolean(L, -1) ? qiflush() : noqiflush(); + ret++; + } + else if (!strcmp(str, "timeout")) { + if (lua_isnil(L, -1)) { + ret += (notimeout(stdscr, TRUE) == OK); + } + else { + timeout(lua_tointeger(L, -1)); + ret++; + } + } + else if (!strcmp(str, "typeahead")) { + ret += ((lua_toboolean(L, -1) ? typeahead(0) : + typeahead(-1)) == OK); + } + else if (!strcmp(str, "clear")) { + ret += (clearok(stdscr, lua_toboolean(L, -1)) == OK); + } + else if (!strcmp(str, "idl")) { + ret += (idlok(stdscr, lua_toboolean(L, -1)) == OK); + } + else if (!strcmp(str, "idc")) { + idcok(stdscr, lua_toboolean(L, -1)); + ret++; + } + else if (!strcmp(str, "immed")) { + immedok(stdscr, lua_toboolean(L, -1)); + ret++; + } + else if (!strcmp(str, "leave")) { + ret += (leaveok(stdscr, lua_toboolean(L, -1)) == OK); + } else if (!strcmp(str, "scroll")) { ret += (scrollok(stdscr, lua_toboolean(L, -1)) == OK); } + else if (!strcmp(str, "nl")) { + ret += ((lua_toboolean(L, -1) ? nl() : nonl()) == OK); + } else { luaL_error(L, "Unknown or unimplemented terminal mode %s", str); } -- cgit v1.2.3