about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-12-25 15:20:42 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-12-25 16:08:31 -0800
commita36edb74f022a76d14e9615b5c4eae685f48d717 (patch)
tree0621f591c0a63589bcdc2bbf8a9f66ebde725afb
parent2b5559d8eb957d447daec919e8975dc0c5ca6810 (diff)
downloadteliva-a36edb74f022a76d14e9615b5c4eae685f48d717.tar.gz
mock sandbox status and some initial colors
Current plan:
  - two booleans to gate file and network access, respectively
  - false shows as green, true shows as orange
  - if _both_ booleans are true, then both show as red to indicate that
    there are no protections.
-rw-r--r--src/teliva.c19
-rw-r--r--src/teliva.h12
2 files changed, 30 insertions, 1 deletions
diff --git a/src/teliva.c b/src/teliva.c
index c195211..1661c90 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -53,14 +53,31 @@ static void draw_menu(lua_State* L) {
       lua_pop(L, 3);
     }
   }
-
   lua_pop(L, 1);
+
+  /* render app permissions on the right */
+  attrset(A_NORMAL);
+  mvaddstr(LINES-1, COLS-12, "");
+  attron(COLOR_PAIR(COLOR_PAIR_RISK));
+  addstr("file ");
+  attron(A_REVERSE);
+  addstr(" ");
+  attroff(COLOR_PAIR(COLOR_PAIR_RISK));
+  attron(COLOR_PAIR(COLOR_PAIR_RISK));
+  addstr(" ");
+  attroff(A_REVERSE);
+  addstr(" net");
+  attroff(COLOR_PAIR(COLOR_PAIR_RISK));
+
   attrset(A_NORMAL);
 }
 
 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);
+  init_pair(COLOR_PAIR_SAFE, COLOR_SAFE, COLOR_FOREGROUND);
+  init_pair(COLOR_PAIR_WARN, COLOR_WARN, COLOR_FOREGROUND);
+  init_pair(COLOR_PAIR_RISK, COLOR_RISK, COLOR_FOREGROUND);
   draw_menu(L);
 }
 
diff --git a/src/teliva.h b/src/teliva.h
index 6c93653..d018223 100644
--- a/src/teliva.h
+++ b/src/teliva.h
@@ -64,6 +64,9 @@ enum color {
   COLOR_SELECTABLE_BACKGROUND = 250,
   COLOR_ERROR_FOREGROUND = COLOR_BACKGROUND,
   COLOR_ERROR_BACKGROUND = 124,               /* deep red */
+  COLOR_WARN = 172,                           /* orange */
+  COLOR_SAFE = 28,                            /* green */
+  COLOR_RISK = 196,                           /* red */
   COLOR_LUA_COMMENT = 27,                     /* blue */
   COLOR_LUA_KEYWORD = 172,                    /* orange */
   COLOR_LUA_CONSTANT = 31,                    /* cyan */
@@ -81,6 +84,9 @@ enum color {
   COLOR_SELECTABLE_BACKGROUND = 250,
   COLOR_ERROR_FOREGROUND = COLOR_FOREGROUND,
   COLOR_ERROR_BACKGROUND = 124,               /* deep red */
+  COLOR_WARN = 172,                           /* orange */
+  COLOR_SAFE = 46,                            /* green */
+  COLOR_RISK = 196,                           /* red */
   COLOR_LUA_COMMENT = 39,                     /* blue */
   COLOR_LUA_KEYWORD = 172,                    /* orange */
   COLOR_LUA_CONSTANT = 37,                    /* cyan */
@@ -98,6 +104,9 @@ enum color {
   COLOR_SELECTABLE_BACKGROUND = 31,
   COLOR_ERROR_FOREGROUND = 250,
   COLOR_ERROR_BACKGROUND = 124,               /* deep red */
+  COLOR_WARN = 130,                           /* orange */
+  COLOR_SAFE = 28,                            /* green */
+  COLOR_RISK = 196,                           /* red */
   COLOR_LUA_COMMENT = 45,                     /* light blue */
   COLOR_LUA_KEYWORD = 172,                    /* orange */
   COLOR_LUA_CONSTANT = 37,                    /* cyan */
@@ -115,6 +124,9 @@ enum color_pair {
   COLOR_PAIR_LUA_KEYWORD = 5,
   COLOR_PAIR_LUA_CONSTANT = 6,
   COLOR_PAIR_MATCH = 7,
+  COLOR_PAIR_SAFE = 251,  /* reserved for teliva; apps shouldn't use it */
+  COLOR_PAIR_WARN = 252,  /* reserved for teliva; apps shouldn't use it */
+  COLOR_PAIR_RISK = 253,  /* reserved for teliva; apps shouldn't use it */
   COLOR_PAIR_MENU = 254,  /* reserved for teliva; apps shouldn't use it */
   COLOR_PAIR_ERROR = 255,  /* reserved for teliva; apps shouldn't use it */
 };