From: Michael D. Lowis Date: Mon, 19 Jun 2017 17:23:51 +0000 (-0400) Subject: moved contents of config.h to config.c and provided a sample XResources file detailin... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6dc123a15676657ef83cc9b235d88cd2030e073e;p=projs%2Ftide.git moved contents of config.h to config.c and provided a sample XResources file detailing all of the config options --- diff --git a/TODO.md b/TODO.md index ace4a9f..6e9c2ee 100644 --- 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 index 0000000..6785d38 --- /dev/null +++ b/XResources @@ -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 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 diff --git a/inc/edit.h b/inc/edit.h index 1ff0a5e..4853ab3 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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, diff --git a/lib/buf.c b/lib/buf.c index d0d39f4..d5b8df1 100644 --- a/lib/buf.c +++ b/lib/buf.c @@ -4,7 +4,6 @@ #include #include #include -#include 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; diff --git a/lib/colors.c b/lib/colors.c index 1e4585d..ab5aaff 100644 --- a/lib/colors.c +++ b/lib/colors.c @@ -1,7 +1,6 @@ #include #include #include -#include static bool matches(Buf* buf, size_t* off, char* str); static SyntaxSpan* mkspan(size_t beg, size_t end, size_t clr, SyntaxSpan* span); diff --git a/lib/config.c b/lib/config.c index 5e9d981..36dcf68 100644 --- a/lib/config.c +++ b/lib/config.c @@ -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 } }, diff --git a/lib/utf8.c b/lib/utf8.c index 23806b7..e4fddab 100644 --- a/lib/utf8.c +++ b/lib/utf8.c @@ -1,7 +1,6 @@ #include #include #include -#include #define __USE_XOPEN #include #include diff --git a/lib/view.c b/lib/view.c index 101a248..b8b7586 100644 --- a/lib/view.c +++ b/lib/view.c @@ -2,7 +2,6 @@ #include #include #include -#include 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); } diff --git a/lib/win.c b/lib/win.c index e9731a6..4d5baad 100644 --- a/lib/win.c +++ b/lib/win.c @@ -4,7 +4,6 @@ #include #include #include -#include static void onredraw(int height, int width); static void oninput(int mods, Rune key); diff --git a/lib/x11.c b/lib/x11.c index 381ca02..9393aa9 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -5,11 +5,12 @@ #include #include #include -#include #include #include #include +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 004bea6..ee5e183 100644 --- a/pick.c +++ b/pick.c @@ -7,9 +7,6 @@ #include #include -#define INCLUDE_DEFS -#include "config.h" - typedef struct { float score; char* string; diff --git a/term.c b/term.c index b6b523a..f2aca6e 100644 --- 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 74bca95..de95bed 100644 --- a/tide.c +++ b/tide.c @@ -7,9 +7,6 @@ #include #include -#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) {