]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added an Eol tag which toggles the line ending mode between CRLF and LF
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 16 Dec 2016 17:48:25 +0000 (12:48 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 16 Dec 2016 17:48:25 +0000 (12:48 -0500)
xedit.c

diff --git a/xedit.c b/xedit.c
index 01aba140debc9d9323a973f8797c3853dbe43047..8b06e84bc1a25aa2d0bf5d74b3f4afa9ff2d41ac 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -62,6 +62,7 @@ static void tabs(void);
 static void indent(void);
 static void del_indent(void);
 static void add_indent(void);
+static void eol_mode(void);
 static void debug_dump(void);
 
 // Tag/Cmd Execution
@@ -100,17 +101,18 @@ 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 = "Tabs",   .action.noarg = tabs   },
-    { .tag = "Indent", .action.noarg = indent },
-    { .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 = "Eol",    .action.noarg = eol_mode },
+    { .tag = NULL,     .action.noarg = NULL     }
 };
 
 void (*MouseActs[MOUSE_BTN_COUNT])(enum RegionId id, size_t count, size_t row, size_t col) = {
@@ -612,6 +614,14 @@ static void add_indent(void) {
     view_indent(currview(), RIGHT);
 }
 
+static void eol_mode(void) {
+    int crlf = getbuf(EDIT)->crlf;
+    printf("%d %d\n", crlf, !crlf);
+    getbuf(EDIT)->crlf = !crlf;
+    getbuf(TAGS)->crlf = !crlf;
+    exec(crlf ? "|dos2unix" : "|unix2dos");
+}
+
 #if 0
 static void dump_log(Log* log) {
     for (; log != NULL; log = log->next) {