aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 08:58:19 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 08:58:19 -0500
commit87b41607eef9c5273b63e3e01bce35d860d1880c (patch)
tree46a219ef8ea03170e962095a243e40ceacc47c0d
parent73b921d87cfafa197019855cf53df50695e97255 (diff)
downloadluancurses-87b41607eef9c5273b63e3e01bce35d860d1880c.tar.gz
luancurses-87b41607eef9c5273b63e3e01bce35d860d1880c.zip
add echochar
-rw-r--r--TODO1
-rw-r--r--src/curses.c32
2 files changed, 32 insertions, 1 deletions
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 },