about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lcurses/window.c10
-rw-r--r--src/lua.c7
-rw-r--r--src/menu.c5
-rw-r--r--src/teliva.h3
4 files changed, 16 insertions, 9 deletions
diff --git a/src/lcurses/window.c b/src/lcurses/window.c
index 66820de..452f8b2 100644
--- a/src/lcurses/window.c
+++ b/src/lcurses/window.c
@@ -309,12 +309,12 @@ Refresh the window terminal display from the virtual screen.
 @see curses.doupdate
 @see noutrefresh
 */
-extern void draw_menu (lua_State *L);
+extern void render_trusted_teliva_data (lua_State *L);
 static int
 Wrefresh(lua_State *L)
 {
 	int result = wrefresh(checkwin(L, 1));
-	draw_menu(L);
+	render_trusted_teliva_data(L);
 	return pushokresult(result);
 }
 
@@ -1307,9 +1307,9 @@ static int
 Wgetch(lua_State *L)
 {
 	WINDOW *w = checkwin(L, 1);
-	draw_menu(L);  /* Apps can draw what they want on screen,
-	                * but Teliva's menu is always visible when
-	                * asking the user to make a decision. */
+	render_trusted_teliva_data(L);  /* Apps can draw what they want on screen,
+	                                 * but Teliva's UI is always visible when
+	                                 * asking the user to make a decision. */
 	int c = wgetch(w);
 
 	if (c == ERR)
diff --git a/src/lua.c b/src/lua.c
index c46f9c4..22872a6 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -1126,6 +1126,11 @@ static int pmain (lua_State *L) {
 
 
 extern void draw_menu (lua_State *);
+void render_trusted_teliva_data (lua_State *L) {
+  init_pair(COLOR_PAIR_ERROR, COLOR_ERROR_FOREGROUND, COLOR_ERROR_BACKGROUND);
+  init_pair(COLOR_PAIR_MENU, COLOR_FOREGROUND, COLOR_BACKGROUND);
+  draw_menu(L);
+}
 
 
 int main (int argc, char **argv) {
@@ -1145,7 +1150,7 @@ int main (int argc, char **argv) {
   keypad(stdscr, 1);
   start_color();
   assume_default_colors(COLOR_FOREGROUND, COLOR_BACKGROUND);
-  draw_menu(L);
+  render_trusted_teliva_data(L);
   echo();
   s.argc = argc;
   s.argv = argv;
diff --git a/src/menu.c b/src/menu.c
index b5173bb..b02c522 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -2,6 +2,7 @@
 #include <string.h>
 
 #include "lua.h"
+#include "teliva.h"
 
 
 int menu_column = 0;
@@ -21,7 +22,7 @@ void draw_menu_item (const char* key, const char* name) {
 }
 
 void draw_menu (lua_State *L) {
-  attron(A_BOLD|A_REVERSE);
+  attron(A_BOLD|A_REVERSE|COLOR_PAIR(COLOR_PAIR_MENU));
   for (int x = 0; x < COLS; ++x)
     mvaddch(LINES-1, x, ' ');
   menu_column = 2;
@@ -36,5 +37,5 @@ void draw_menu (lua_State *L) {
       draw_menu_item(lua_tostring(L, -2), lua_tostring(L, -1));
 
   lua_pop(L, 1);
-  attroff(A_BOLD|A_REVERSE);
+  attrset(A_NORMAL);
 }
diff --git a/src/teliva.h b/src/teliva.h
index 3ae7651..c5bbc46 100644
--- a/src/teliva.h
+++ b/src/teliva.h
@@ -112,7 +112,8 @@ enum color_pair {
   COLOR_PAIR_LUA_KEYWORD = 5,
   COLOR_PAIR_LUA_CONSTANT = 6,
   COLOR_PAIR_MATCH = 7,
-  COLOR_PAIR_ERROR = 255,
+  COLOR_PAIR_MENU = 254,  // reserved for teliva; apps shouldn't use it
+  COLOR_PAIR_ERROR = 255,  // reserved for teliva; apps shouldn't use it
 };
 
 #endif