about summary refs log tree commit diff stats
path: root/src/lcurses
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-02-01 21:19:51 -0800
committerKartik K. Agaram <vc@akkartik.com>2022-02-01 21:19:51 -0800
commit664b94f414da6dbdf6c956f5378f0094eadb8444 (patch)
tree3ac0b2332376b37de47df7969cf4f142e4683fa9 /src/lcurses
parent7968134246b203fcef53794155ac5333b826fc60 (diff)
downloadteliva-664b94f414da6dbdf6c956f5378f0094eadb8444.tar.gz
include keys typed into audit log
This will help people cross-correlate when the app performs specific
calls.
Diffstat (limited to 'src/lcurses')
-rw-r--r--src/lcurses/window.c9
1 files changed, 9 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;