about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/kilo.c7
-rw-r--r--src/teliva.c11
2 files changed, 17 insertions, 1 deletions
diff --git a/src/kilo.c b/src/kilo.c
index 1ed700f..fe4b9bf 100644
--- a/src/kilo.c
+++ b/src/kilo.c
@@ -1338,6 +1338,7 @@ void editNonCode(char* filename) {
 
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 
+void print_file_permission_suggestions(int row);
 void editFilePermissions(char* filename) {
     Quit = 0;
     Back_to_big_picture = 0;
@@ -1354,7 +1355,11 @@ void editFilePermissions(char* filename) {
         int y, x;
         getyx(stdscr, y, x);
         mvaddstr(0, 0, "function file_operation_permitted(filename, is_write)");
-        mvaddstr(MIN(E.startrow + E.numrows, E.endrow), 0, "end");
+        int past_end_row = MIN(E.startrow + E.numrows, E.endrow);
+        mvaddstr(past_end_row, 0, "end");
+        attrset(COLOR_PAIR(COLOR_PAIR_LUA_COMMENT));
+        print_file_permission_suggestions(past_end_row+2);
+        attrset(A_NORMAL);
         mvaddstr(y, x, "");
         int c = getch();
         editorProcessKeypress2(c);
diff --git a/src/teliva.c b/src/teliva.c
index 4ad530e..35c9964 100644
--- a/src/teliva.c
+++ b/src/teliva.c
@@ -1563,6 +1563,17 @@ static void edit_file_operations_predicate_body() {
   }
 }
 
+void print_file_permission_suggestions(int row) {
+  mvaddstr(row++, 0, "-- Some ideas:");
+  mvaddstr(row++, 0, "--  * restrict access to a single file: return filename == 'foo'");
+  mvaddstr(row++, 0, "--  * restrict to reading only: return is_write == false");
+  mvaddstr(row++, 0, "--  * restrict to files with a fixed prefix: return string.find(filename, 'foo') == 1");
+  mvaddstr(row++, 0, "--  * restrict to files with a fixed extension: return filename:sub(-4) == '.txt'");
+  mvaddstr(row++, 0, "--  * restrict to files under some directory: return string.find(filename, 'foo/') == 1");
+  mvaddstr(row++, 0, "--");
+  mvaddstr(row++, 0, "-- Each of these has benefits and drawbacks.");
+}
+
 static void permissions_view() {
   while (true) {
     render_permissions_screen();