From 52a443ec7535c0d8d6ca7e16a48b11dfc45dd2f8 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Tue, 18 Mar 2008 15:21:50 -0500 Subject: 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 --- src/curses.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3-54-g00ecf