]> git.mdlowis.com Git - projs/tide.git/commitdiff
moved contents of config.h to config.c and provided a sample XResources file detailin...
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Jun 2017 17:23:51 +0000 (13:23 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 19 Jun 2017 17:23:51 +0000 (13:23 -0400)
14 files changed:
TODO.md
XResources [new file with mode: 0644]
config.h [deleted file]
inc/edit.h
lib/buf.c
lib/colors.c
lib/config.c
lib/utf8.c
lib/view.c
lib/win.c
lib/x11.c
pick.c
term.c
tide.c

diff --git a/TODO.md b/TODO.md
index ace4a9f73e7e64a951d873f9ac888583552212fe..6e9c2ee1f684bec0480cffa6e020d4cf97219243 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,26 +2,24 @@
 
 Up Next:
 
-* add a cap to the distance from last span to first char on screen
-* Ctrl+/ shortcut to comment/uncomment based on syntax
-* ignore the menu key or map it to control
-* implement transaction control in buf.c
-* implement X resources config file
+* highlight all matches of search term
 * highlight classes of identifiers
+* implement transaction control in buf.c
 * Add a way to CD using a builtin (buffers will track original dir)
 * shortcut to jump to previous edit
 * add command line flags to toggle options (Tabs, Indent, etc..)
 * move by words is inconsistent. Example:
     var infoId = 'readerinfo'+reader.id;
+* ignore the menu key or map it to control
 
 The Future:
 
+* Ctrl+/ shortcut to comment/uncomment based on syntax
 * Case insensitive search
 * Ctrl+Up,Down requires two undos to revert.
 * Ctrl+Up,Down with non line selection should track column
 * Scrolling line offset
 * Ctrl+Shift+Enter copies indent of wrong line
-* highlight all matches of search term
 * Make Fn keys execute nth command in the tags buffers
 * jump to previous or next line with less indent
 * use transaction ids to only mark buffer dirty when it really is
diff --git a/XResources b/XResources
new file mode 100644 (file)
index 0000000..6785d38
--- /dev/null
@@ -0,0 +1,70 @@
+! UI Settings
+tide.ui.font:         Liberation Mono:pixelsize=14:antialias=true:autohint=true
+tide.ui.tags:         'Quit Save Undo Redo Cut Copy Paste | Find '
+tide.ui.width:        640
+tide.ui.height:       480
+tide.ui.line_spacing: 2
+tide.ui.line_numbers: true
+tide.ui.ruler_column: 80
+tide.ui.timeout:      50
+
+! Input and Behavior Settings
+tide.input.copy_indent:   true
+tide.input.trim_on_save:  true
+tide.input.expand_tabs:   true
+tide.input.tab_width:     4
+tide.input.scroll_lines:  4
+tide.input.click_time:    500
+tide.input.max_scan_dist: 8192
+
+! Color Palette Definition
+tide.palette.00: 0xff002b36
+tide.palette.01: 0xff073642
+tide.palette.02: 0xff586e75
+tide.palette.03: 0xff657b83
+tide.palette.04: 0xff839496
+tide.palette.05: 0xff93a1a1
+tide.palette.06: 0xffeee8d5
+tide.palette.07: 0xfffdf6e3
+tide.palette.08: 0xffb58900
+tide.palette.09: 0xffcb4b16
+tide.palette.10: 0xffdc322f
+tide.palette.11: 0xffd33682
+tide.palette.12: 0xff6c71c4
+tide.palette.13: 0xff268bd2
+tide.palette.14: 0xff2aa198
+tide.palette.15: 0xff859900
+
+! Background and UI Colors
+tide.colors.ruler:      0x01
+tide.colors.gutter:     0x01
+tide.colors.bkg_tags:   0x01
+tide.colors.bkg_edit:   0x00
+tide.colors.bkg_scroll: 0x03
+tide.colors.bkg_thumb:  0x00
+tide.colors.border:     0x03
+
+! Base Text Colors
+tide.colors.text.cursor:   0x0007
+tide.colors.text.normal:   0x0004
+tide.colors.text.selected: 0x0400
+tide.colors.text.gutter:   0x0003
+tide.colors.text.currline: 0x0D07
+
+! Syntax Colors
+tide.colors.syntax.normal:       0x0004
+tide.colors.syntax.comment:      0x0002
+tide.colors.syntax.constant:     0x000E
+tide.colors.syntax.string:       0x000E
+tide.colors.syntax.character:    0x000E
+tide.colors.syntax.number:       0x000E
+tide.colors.syntax.booleean:     0x000E
+tide.colors.syntax.float:        0x000E
+tide.colors.syntax.variable:     0x000F
+tide.colors.syntax.function:     0x000E
+tide.colors.syntax.keyword:      0x000E
+tide.colors.syntax.operator:     0x000E
+tide.colors.syntax.preprocessor: 0x000D
+tide.colors.syntax.type:         0x0009
+tide.colors.syntax.statement:    0x000E
+tide.colors.syntax.special:      0x000A
diff --git a/config.h b/config.h
deleted file mode 100644 (file)
index 64531e9..0000000
--- a/config.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* extern the config variables */
-extern char *ShellCmd[], *SedCmd[], *PickFileCmd[], *PickTagCmd[], *OpenCmd[];
-
-/* OS-Specific Config
- ******************************************************************************/
-#ifdef __MACH__
-    #define FONT    "Monaco:size=10:antialias=true:autohint=true"
-    #define LNSPACE 0
-#else
-    #define FONT    "Liberation Mono:pixelsize=14:antialias=true:autohint=true"
-    #define LNSPACE 2
-#endif
-
-/* General Config
- ******************************************************************************/
-enum {
-    BufSize         = 8192,  /* default buffer size */
-    FontCacheSize   = 16,    /* Maximum number of fonts allowed in the font cache */
-    DefaultCRLF     = 0,     /* Default to Unix line endings */
-    DefaultCharset  = UTF_8, /* We assume UTF-8 because nothing else matters */
-    MaxScanDistance = 16384, /* Maximum distance to scan before visible lines for syntax higlighting */
-};
-
-#ifdef INCLUDE_DEFS
-
-/* The shell: Filled in with $SHELL. Used to execute commands */
-char* ShellCmd[] = { NULL, "-c", NULL, NULL };
-
-/* Sed command used to execute commands marked with ':' sigil */
-char* SedCmd[] = { "sed", "-e", NULL, NULL };
-
-/* Fuzzy Picker for files in the current directory and subdirectories */
-char* PickFileCmd[] = { "pickfile", ".", NULL };
-
-/* Fuzzy picker for tags in a ctags database. */
-char* PickTagCmd[] = { "picktag", NULL, "tags", NULL, NULL };
-
-/* Open a new instance of the editor */
-char* OpenCmd[] = { "tide", NULL, NULL };
-
-#undef INCLUDE_DEFS
-#endif
index 1ff0a5e5b4b7ef29142978bf4f3a04ba41c267c8..4853ab3242d35707aa1b2455a03eac912263175f 100644 (file)
@@ -239,7 +239,7 @@ char* cmdwriteread(char** cmd, char* text, char** err);
 enum {
     FontString = 0, TagString, WinWidth, WinHeight, LineSpacing, LineNumbers,
     RulerColumn, EventTimeout, CopyIndent, TrimOnSave, ExpandTabs, TabWidth,
-    ScrollLines, DblClickTime,
+    ScrollLines, DblClickTime, MaxScanDist,
     Color00, Color01, Color02, Color03, Color04, Color05, Color06, Color07,
     Color08, Color09, Color10, Color11, Color12, Color13, Color14, Color15,
     BkgRuler, BkgGutter, BkgTags, BkgEdit, BkgScroll, BkgThumb, BkgBorder,
index d0d39f4d11bdcc157591b66f65b08c7416060158..d5b8df1e73e4927a8a2e14d114993af27b555107 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -4,7 +4,6 @@
 #include <edit.h>
 #include <ctype.h>
 #include <unistd.h>
-#include <config.h>
 
 size_t buf_setln(Buf* buf, size_t line);
 size_t buf_getcol(Buf* buf, size_t pos);
@@ -35,9 +34,9 @@ void buf_init(Buf* buf, void (*errfn)(char*)) {
     buf->modified    = false;
     buf->expand_tabs = config_get_bool(ExpandTabs);
     buf->copy_indent = config_get_bool(CopyIndent);
-    buf->charset     = DefaultCharset;
-    buf->crlf        = DefaultCRLF;
-    buf->bufsize     = BufSize;
+    buf->charset     = UTF_8;
+    buf->crlf        = 0;
+    buf->bufsize     = 8192;
     buf->bufstart    = (Rune*)malloc(buf->bufsize * sizeof(Rune));
     buf->bufend      = buf->bufstart + buf->bufsize;
     buf->gapstart    = buf->bufstart;
index 1e4585d6072b45f66a556fb107559f796b06de4b..ab5aaffefda8ae811edff1a3eeee9c2975bda3b6 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdc.h>
 #include <utf.h>
 #include <edit.h>
-#include <config.h>
 
 static bool matches(Buf* buf, size_t* off, char* str);
 static SyntaxSpan* mkspan(size_t beg, size_t end, size_t clr, SyntaxSpan* span);
index 5e9d981961ac87c6513e0afa06434eea2a4c1b3b..36dcf68ca6563f1d6eec24505dffbf90eb7a1b84 100644 (file)
@@ -28,12 +28,13 @@ struct {
     [EventTimeout] = { "tide.ui.timeout",      INTEGER, { .num = 50   } },
 
     /* input related options */
-    [CopyIndent]   = { "tide.input.copy_indent",  BOOLEAN, { .opt = true  } },
-    [TrimOnSave]   = { "tide.input.trim_on_save", BOOLEAN, { .opt = false } },
-    [ExpandTabs]   = { "tide.input.expand_tabs",  BOOLEAN, { .opt = true  } },
-    [TabWidth]     = { "tide.input.tab_width",    INTEGER, { .num = 4     } },
-    [ScrollLines]  = { "tide.input.scroll_lines", INTEGER, { .num = 4     } },
-    [DblClickTime] = { "tide.input.click_time",   INTEGER, { .num = 500   } },
+    [CopyIndent]   = { "tide.input.copy_indent",   BOOLEAN, { .opt = true  } },
+    [TrimOnSave]   = { "tide.input.trim_on_save",  BOOLEAN, { .opt = false } },
+    [ExpandTabs]   = { "tide.input.expand_tabs",   BOOLEAN, { .opt = true  } },
+    [TabWidth]     = { "tide.input.tab_width",     INTEGER, { .num = 4     } },
+    [ScrollLines]  = { "tide.input.scroll_lines",  INTEGER, { .num = 4     } },
+    [DblClickTime] = { "tide.input.click_time",    INTEGER, { .num = 500   } },
+    [MaxScanDist]  = { "tide.input.max_scan_dist", INTEGER, { .num = 8192  } },
 
     /* default color palette definition */
     [Color00] = { "tide.palette.00", INTEGER, { .num = 0xff002b36 } },
index 23806b7210acb06e6113fccfac7e9ca442fb7618..e4fddabaf1c4b2e0f3ccabb5f61909b131ab6459 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdc.h>
 #include <utf.h>
 #include <edit.h>
-#include <config.h>
 #define __USE_XOPEN
 #include <wchar.h>
 #include <ctype.h>
index 101a24894622258ae8e82a2ee62d808a4983a9af..b8b7586de6376729fc95b47047de3780c52712a4 100644 (file)
@@ -2,7 +2,6 @@
 #include <utf.h>
 #include <edit.h>
 #include <ctype.h>
-#include <config.h>
 
 typedef size_t (*movefn_t)(Buf* buf, size_t pos, int count);
 
@@ -108,8 +107,8 @@ void view_update(View* view, size_t* csrx, size_t* csry) {
            last  = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen;
     view->spans = colors_rewind(view->spans, first);
     size_t start = (view->spans ? view->spans->end : 0);
-    if (first-start > MaxScanDistance)
-        start = first - MaxScanDistance;
+    if (first-start > config_get_int(MaxScanDist))
+        start = first - config_get_int(MaxScanDist);
     view->spans = colors_scan(view->syntax, view->spans, &(view->buffer), first, last+1);
     apply_colors(view);
 }
index e9731a60d907657b8e4e479ef80d4563cf7e4bd3..4d5baadcde71b8b43ef7a9bace83a361f0101dfc 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -4,7 +4,6 @@
 #include <x11.h>
 #include <win.h>
 #include <ctype.h>
-#include <config.h>
 
 static void onredraw(int height, int width);
 static void oninput(int mods, Rune key);
index 381ca02a8a5976f65bfe0ce24a1640fb9d368e22..9393aa9768ecb1a9525a3582ff72709ea5662c8d 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -5,11 +5,12 @@
 #include <x11.h>
 #include <utf.h>
 #include <edit.h>
-#include <config.h>
 #include <locale.h>
 #include <sys/time.h>
 #include <sys/types.h>
 
+enum { FontCacheSize = 16 };
+
 static struct XSel* selfetch(Atom atom);
 static void selclear(XEvent* evnt);
 static void selnotify(XEvent* evnt);
diff --git a/pick.c b/pick.c
index 004bea65b82c3fa1726c094128e93046f818eb43..ee5e183ea976087f59b0fe768f3c94e474186fed 100644 (file)
--- a/pick.c
+++ b/pick.c
@@ -7,9 +7,6 @@
 #include <ctype.h>
 #include <shortcuts.h>
 
-#define INCLUDE_DEFS
-#include "config.h"
-
 typedef struct {
     float score;
     char* string;
diff --git a/term.c b/term.c
index b6b523a89ff5db5a0dc84f79707574d926f11059..f2aca6eff7118e523a1f40592d772a4d20e553a5 100644 (file)
--- a/term.c
+++ b/term.c
@@ -7,9 +7,6 @@
 
 static int ShellFD;
 
-#define INCLUDE_DEFS
-#include "config.h"
-
 void onmouseleft(WinRegion id, bool pressed, size_t row, size_t col) {
 }
 
diff --git a/tide.c b/tide.c
index 74bca951d8fa6b416e067c528e5fe72b6fadf30b..de95bed11a97c4716f8064b83bbe284a4790977c 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -7,9 +7,6 @@
 #include <shortcuts.h>
 #include <unistd.h>
 
-#define INCLUDE_DEFS
-#include "config.h"
-
 typedef struct {
     char* tag;
     union {
@@ -23,6 +20,21 @@ static int SearchDir = DOWN;
 static char* SearchTerm = NULL;
 static size_t Marks[10] = {0};
 
+/* The shell: Filled in with $SHELL. Used to execute commands */
+char* ShellCmd[] = { NULL, "-c", NULL, NULL };
+
+/* Sed command used to execute commands marked with ':' sigil */
+char* SedCmd[] = { "sed", "-e", NULL, NULL };
+
+/* Fuzzy Picker for files in the current directory and subdirectories */
+char* PickFileCmd[] = { "pickfile", ".", NULL };
+
+/* Fuzzy picker for tags in a ctags database. */
+char* PickTagCmd[] = { "picktag", NULL, "tags", NULL, NULL };
+
+/* Open a new instance of the editor */
+char* OpenCmd[] = { "tide", NULL, NULL };
+
 /* Tag/Cmd Execution
  ******************************************************************************/
 static Tag* tag_lookup(char* cmd) {