aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 15:21:50 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-03-18 15:21:50 -0500
commit52a443ec7535c0d8d6ca7e16a48b11dfc45dd2f8 (patch)
tree38c27519336537347a8b0c64bf0918f35f82bc50
parente156e0114f9a4b3392846b362ed31c38efa66062 (diff)
downloadluancurses-52a443ec7535c0d8d6ca7e16a48b11dfc45dd2f8.tar.gz
luancurses-52a443ec7535c0d8d6ca7e16a48b11dfc45dd2f8.zip
allow using "default" for color pair 0, and handle this in init_pair by calling assume_default_colors when init_pair is called with "default" as the first argument
-rw-r--r--src/curses.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/curses.c b/src/curses.c
index 09e76d6..469e18c 100644
--- a/src/curses.c
+++ b/src/curses.c
@@ -44,6 +44,8 @@ static void init_color_pairs(lua_State* L)
{
lua_getfield(L, LUA_REGISTRYINDEX, REG_TABLE);
lua_newtable(L);
+ lua_pushinteger(L, 0);
+ lua_setfield(L, -2, "default");
lua_setfield(L, -2, "color_pairs");
lua_pop(L, 1);
}
@@ -346,7 +348,12 @@ static int l_init_pair(lua_State* L)
bg_val = lua_tointeger(L, -1);
lua_pop(L, 3);
- lua_pushboolean(L, (init_pair(name_val, fg_val, bg_val) == OK));
+ if (name_val != 0) {
+ lua_pushboolean(L, (init_pair(name_val, fg_val, bg_val) == OK));
+ }
+ else {
+ lua_pushboolean(L, (assume_default_colors(fg_val, bg_val) == OK));
+ }
return 1;
}