]> git.mdlowis.com Git - projs/tide.git/commitdiff
added command line flags for changing settings
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 28 Mar 2018 01:30:35 +0000 (21:30 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 28 Mar 2018 01:30:35 +0000 (21:30 -0400)
inc/edit.h
lib/config.c
tide.c

index c16b6e8e3d16e7c993ccb14412d3fb704c96569c..4b8d67e0448e1a2b83253f46daa6d817fc15c33b 100644 (file)
@@ -184,14 +184,15 @@ void job_start(char** cmd, char* data, size_t ndata, View* dest);
 
 /* Configuration Data
  *****************************************************************************/
+enum { OFF = 0, ON = 1 };
+
 typedef struct { int fg, bg; } CPair;
 
-extern char TagString[], FontString[];
+extern char *TagString, *FontString;
+extern CPair Colors[28];
 extern int Palette[16];
-extern int WinWidth, WinHeight, LineSpacing, RulerPos, Timeout, TabWidth, ScrollBy,
+extern int WinWidth, WinHeight, LineSpacing, Timeout, TabWidth, ScrollBy,
     ClickTime, MaxScanDist, Syntax, CopyIndent, TrimOnSave, ExpandTabs, DosLineFeed;
-extern CPair Colors[28];
-
 enum { /* Color Variables */
     ClrScrollNor = 0, ClrGutterNor, ClrGutterSel, ClrStatusNor, ClrTagsNor,
     ClrTagsSel, ClrTagsCsr, ClrEditNor, ClrEditSel, ClrEditCsr, ClrEditRul,
index f42c8f738e4f9489fc915ae9b738736c0af81b30..a3a588cb4ce249593a25d21889eadf4d988ad4f7 100644 (file)
@@ -4,8 +4,6 @@
 #include <utf.h>
 #include <edit.h>
 
-enum { OFF = 0, ON = 1 };
-
 #ifdef __MACH__
     #define FONT "Monaco:size=10"
     #define LNSPACE 0
@@ -14,14 +12,13 @@ enum { OFF = 0, ON = 1 };
     #define LNSPACE 1
 #endif
 
-char TagString[] = "Del Put Undo Redo Find ";
-char FontString[] = FONT;
+char* TagString = "Del Put Undo Redo Find ";
+char* FontString = FONT;
 
 int /* Integer config options */
     WinWidth = 640,
     WinHeight = 480,
     LineSpacing = LNSPACE,
-    RulerPos = 80,
     Timeout = 50,
     TabWidth = 4,
     ScrollBy = 4,
diff --git a/tide.c b/tide.c
index e95c44bd873e7ec473d7c21c43a4f751092e5d44..bcdee936b52ee96f47848f6aea9f02888597755e 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -615,8 +615,38 @@ static void oninput(Rune rune) {
     view_insert(win_view(FOCUSED), true, rune);
 }
 
+
+char* ARGV0;
+static void usage(void) {
+    printf(
+        "Usage: %s [FLAGS] [FILE]\n"
+        "\n    -S 0,1  Enable/disable syntax highlighting"
+        "\n    -I 0,1  Enable/disable automatic indenting"
+        "\n    -W 0,1  Enable/disable trimming whitespace on save"
+        "\n    -E 0,1  Enable/disable expanding tabs to spaces"
+        "\n    -N 0,1  Enable/disable dos line ending style"
+        "\n    -F str  Set the font to use"
+        "\n    -T str  String to use for the tags region"
+        "\n    -C str  Set the shell to use for command execution\n",
+        ARGV0);
+    exit(1);
+}
+
 #ifndef TEST
 int main(int argc, char** argv) {
+    #define BOOLARG() (EOPTARG(usage()), optarg_[0] == '0' ? 0 : 1)
+    #define STRARG()  (EOPTARG(usage()))
+    OPTBEGIN {
+        case 'S': Syntax      = BOOLARG(); break;
+        case 'I': CopyIndent  = BOOLARG(); break;
+        case 'W': TrimOnSave  = BOOLARG(); break;
+        case 'E': ExpandTabs  = BOOLARG(); break;
+        case 'N': DosLineFeed = BOOLARG(); break;
+        case 'F': FontString  = STRARG();  break;
+        case 'T': TagString   = STRARG();  break;
+        case 'C': ShellCmd[0] = STRARG();  break;
+    } OPTEND;
+
     /* setup the shell */
     if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL");
     if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh";
@@ -625,10 +655,6 @@ int main(int argc, char** argv) {
     win_init(ondiagmsg);
     x11_window("tide", WinWidth, WinHeight);
 
-    /* open all but the last file in new instances */
-    for (argc--, argv++; argc > 1; argc--, argv++)
-        cmd_execwitharg(CMD_TIDE, *argv);
-
     /* if we still have args left we're going to open it in this instance */
     if (*argv) view_init(win_view(EDIT), *argv, ondiagmsg);