]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added tags for toggling copyindent and expand tabs
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 5 Dec 2016 14:46:47 +0000 (09:46 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 5 Dec 2016 14:46:47 +0000 (09:46 -0500)
TODO.md
xedit.c

diff --git a/TODO.md b/TODO.md
index 45b4a3f8d1aac27c1d14fdaebe3478b8056e4461..771e971c9fafc7e6ef99a15e1d30ebcc5aadf96a 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,7 +1,5 @@
 # Implementation Tweaks and Bug Fixes
 
-* add tag for toggling expand tabs 
-* add tag for toggling auto indent
 * Expand tabs setting should be disabled if opened file contains tabs
 * Add tag for ctags lookup and line number jump
 * add a shortcut to autocomplete ctag
diff --git a/xedit.c b/xedit.c
index 11edeb40f7267d19c4786b6459c25cb5123dbd95..52cc99ffa67977c85c076a5438ccda8da28850e5 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -51,6 +51,8 @@ static void find(char* arg);
 static void open_file(void);
 static void pick_ctag(void);
 static void goto_ctag(void);
+static void tabs(void);
+static void indent(void);
 
 // Tag/Cmd Execution
 static Tag* tag_lookup(char* cmd);
@@ -86,15 +88,17 @@ static XConfig Config = {
 };
 
 Tag Builtins[] = {
-    { .tag = "Quit",  .action.noarg = quit  },
-    { .tag = "Save",  .action.noarg = save  },
-    { .tag = "Cut",   .action.noarg = cut   },
-    { .tag = "Copy",  .action.noarg = copy  },
-    { .tag = "Paste", .action.noarg = paste },
-    { .tag = "Undo",  .action.noarg = undo  },
-    { .tag = "Redo",  .action.noarg = redo  },
-    { .tag = "Find",  .action.arg   = find  },
-    { .tag = NULL,    .action.noarg = NULL  }
+    { .tag = "Quit",   .action.noarg = quit   },
+    { .tag = "Save",   .action.noarg = save   },
+    { .tag = "Cut",    .action.noarg = cut    },
+    { .tag = "Copy",   .action.noarg = copy   },
+    { .tag = "Paste",  .action.noarg = paste  },
+    { .tag = "Undo",   .action.noarg = undo   },
+    { .tag = "Redo",   .action.noarg = redo   },
+    { .tag = "Find",   .action.arg   = find   },
+    { .tag = "Tabs",   .action.noarg = tabs   },
+    { .tag = "Indent", .action.noarg = indent },
+    { .tag = NULL,     .action.noarg = NULL   }
 };
 
 void (*MouseActs[MOUSE_BTN_COUNT])(enum RegionId id, size_t count, size_t row, size_t col) = {
@@ -280,6 +284,8 @@ static void draw_status(int fg, size_t ncols) {
     UGlyph glyphs[ncols], *status = glyphs;
     (status++)->rune = (buf->charset == BINARY ? 'B' : 'U');
     (status++)->rune = (buf->crlf ? 'C' : 'N');
+    (status++)->rune = (buf->expand_tabs ? 'S' : 'T');
+    (status++)->rune = (buf->copy_indent ? 'I' : 'i');
     (status++)->rune = (buf->modified ? '*' : ' ');
     (status++)->rune = ' ';
     char* path = (buf->path ? buf->path : "*scratch*");
@@ -546,6 +552,18 @@ static void goto_ctag(void) {
     free(str);
 }
 
+static void tabs(void) {
+    bool enabled = !(getbuf(EDIT)->expand_tabs);
+    getbuf(EDIT)->expand_tabs = enabled;
+    getbuf(TAGS)->expand_tabs = enabled;
+}
+
+static void indent(void) {
+    bool enabled = !(getbuf(EDIT)->copy_indent);
+    getbuf(EDIT)->copy_indent = enabled;
+    getbuf(TAGS)->copy_indent = enabled;
+}
+
 /* Tag/Cmd Execution
  *****************************************************************************/
 static Tag* tag_lookup(char* cmd) {