From 87b41607eef9c5273b63e3e01bce35d860d1880c Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Tue, 18 Mar 2008 08:58:19 -0500 Subject: add echochar --- TODO | 1 - src/curses.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 88f33fd..55568aa 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ - chtype arrays (curs_addchstr, curs_inchstr) - the point of these routines is that they are more efficient, since you pass in an array of chtypes rather than an array of chars. how can i expose this functionality? -- curs_addch (echochar) - reading from the screen (curs_instr, curs_inch) - reading input (ungetch (curs_getch), curs_getstr - attribute support (curs_attr) diff --git a/src/curses.c b/src/curses.c index ce790f1..689a7af 100644 --- a/src/curses.c +++ b/src/curses.c @@ -379,6 +379,37 @@ static int l_addch(lua_State* L) return 1; } +static int l_echochar(lua_State* L) +{ + int is_mv; + pos p; + size_t l; + attr_t mode = 0; + chtype ch; + + is_mv = get_pos(L, &p); + ch = get_char_enum(luaL_checklstring(L, 1, &l)); + if (lua_istable(L, 2)) { + mode = get_char_attr(L, 2); + } + + if (is_mv) { + int ret; + + ret = move(p.y, p.x); + if (ret == OK) { + ret = echochar(ch | mode); + } + + lua_pushboolean(L, ret == OK); + } + else { + lua_pushboolean(L, echochar(ch | mode) == OK); + } + + return 1; +} + static int l_addstr(lua_State* L) { int is_mv, set_attrs = 0; @@ -586,6 +617,7 @@ const luaL_Reg reg[] = { { "getch", l_getch }, { "move", l_move }, { "addch", l_addch }, + { "echochar", l_echochar }, { "addstr", l_addstr }, { "erase", l_erase }, { "clear", l_clear }, -- cgit v1.2.3-54-g00ecf