about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/lcurses/window.c9
-rw-r--r--src/teliva.c7
-rw-r--r--src/teliva.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/src/lcurses/window.c b/src/lcurses/window.c
index 2ce418d..beaa148 100644
--- a/src/lcurses/window.c
+++ b/src/lcurses/window.c
@@ -36,6 +36,8 @@
 @classmod curses.window
 */
 
+#include <ctype.h>
+
 #include "../teliva.h"
 #include "_helpers.c"
 #include "chstr.c"
@@ -1305,6 +1307,13 @@ Wgetch(lua_State *L)
 	if (x > COLS-2) x = COLS-2; if (y > LINES-1) y = LINES-1; /* http://gnats.netbsd.org/56664 */
 	mvaddstr(y, x, "");
 	int c = wgetch(w);
+	static char buffer[1024] = {0};
+	memset(buffer, '\0', 1024);
+	if (isspace(c))
+		snprintf(buffer, 1020, "getch() => %s", character_name(c));
+	else
+		snprintf(buffer, 1020, "getch() => %c", c);
+	append_to_audit_log(L, buffer);
 
 	if (c == ERR)
 		return 0;
diff --git a/src/teliva.c b/src/teliva.c
index 5726428..9bd2f67 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -102,6 +102,13 @@ static void draw_menu(lua_State* L) {
   attrset(A_NORMAL);
 }
 
+const char* character_name(char c) {
+  if (c == '\n') return "ENTER";
+  if (c == '\t') return "TAB";
+  if (c == ' ') return "SPACE";
+  return "UNKNOWN";
+}
+
 static void render_permissions(lua_State* L) {
   attrset(A_NORMAL);
   mvaddstr(LINES-1, COLS-12, "");
diff --git a/src/teliva.h b/src/teliva.h
index 3489b01..3f9072b 100644
--- a/src/teliva.h
+++ b/src/teliva.h
@@ -178,6 +178,8 @@ extern void draw_string_on_menu(const char* s);
 
 extern int menu_column;
 
+extern const char* character_name(char c);
+
 /* Error reporting */
 
 extern const char* Previous_error;