]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed bug in handling of config variables and optimized drawing logic for title
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 20 Dec 2018 02:44:54 +0000 (21:44 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 20 Dec 2018 02:44:54 +0000 (21:44 -0500)
TODO.md
config.h
src/lib/config.c [deleted file]
src/lib/x11.c
src/tide.c

diff --git a/TODO.md b/TODO.md
index 7850db76adc04c6624150e0abf5092cc330d4ea5..eda43917b1a0cdf4a6fa70d5f149c0349e291f97 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,7 +2,7 @@
 
 ## STAGING
 
-* Ctrl+D  should not pass tag name as arg when executing tag commands
+* Ctrl+D should not pass tag name as arg when executing tag commands
 * registrar doesnt match open windows when new file created and is then opened for edit or line number
 * implement a mini-sed command to standardize scripts across platforms without relying on sed
 * registrar should remove invalid windows from registry when detected
index 543597d9e4cdf311fc57a495dce9f48089066b59..169cfb2616ca09e29b5da5b5d3a7f6f16878f286 100644 (file)
--- a/config.h
+++ b/config.h
@@ -42,18 +42,23 @@ static char* Fonts[2] = {
 #endif
 };
 
-static int /* Integer config options */
-    WinWidth = 640,
-    WinHeight = 480,
-    ScrollWidth = 5,
-    Timeout = 50,
-    TabWidth = 4,
-    ScrollBy = 1,
-    ClickTime = 500,
-    CopyIndent = On,
-    TrimOnSave = On,
-    ExpandTabs = On,
-    DosLineFeed = Off;
+#ifdef INCLUDE_DEFS
+/* Integer config options */
+int WinWidth = 640;
+int WinHeight = 480;
+int ScrollWidth = 5;
+int Timeout = 50;
+int TabWidth = 4;
+int ScrollBy = 1;
+int ClickTime = 500;
+int CopyIndent = On;
+int TrimOnSave = On;
+int ExpandTabs = On;
+int DosLineFeed = Off;
+#else
+int WinWidth, WinHeight, ScrollWidth, Timeout, TabWidth, ScrollBy,
+    ClickTime, CopyIndent, TrimOnSave, ExpandTabs, DosLineFeed;
+#endif
 
 static int Palette[ClrCount] = {
     [Red]      = 0xd1160b, /* Red */
@@ -85,7 +90,7 @@ static int Palette[ClrCount] = {
     #define OPENCMD "xdg-open"
 #endif
 
-Rule* BuiltinRules[] = {
+static Rule* BuiltinRules[] = {
     (Rule[]){ /* Match URLS and open them with the browser */
         { ISSET, "BROWSER", NULL },
         { MATCHES, "data", "^(https?|ftp)://.*" },
diff --git a/src/lib/config.c b/src/lib/config.c
deleted file mode 100644 (file)
index 41f7fef..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-#include <stdc.h>
-#include <utf.h>
-#include <edit.h>
-
-char* FetchCmd[] = { "tfetch", 0, 0 };
-char* TagString = "Del Put Undo Redo | Font Tabs Eol | Find ";
-
-char* Fonts[2] = {
-    "Verdana:size=11",
-#ifdef __MACH__
-    "Monaco:size=11"
-#else
-    "Liberation Mono:size=11"
-#endif
-};
-
-int /* Integer config options */
-    WinWidth = 640,
-    WinHeight = 480,
-    ScrollWidth = 5,
-    Timeout = 50,
-    TabWidth = 4,
-    ScrollBy = 1,
-    ClickTime = 500,
-    CopyIndent = ON,
-    TrimOnSave = ON,
-    ExpandTabs = ON,
-    DosLineFeed = OFF;
-
-int Palette[ClrCount] = {
-    [Red]      = 0xd1160b, // Red
-    [Green]    = 0x1e7b3d, // Green
-    [Blue]     = 0x0c6cc0, // Blue
-    [Yellow]   = 0xfed910, // Yellow ???
-    [Purple]   = 0x7878ba, // Purple ???
-    [Aqua]     = 0x00695c, // Aqua   ???
-    [Orange]   = 0xf39812, // Orange ???
-    [EditBg]   = 0xF0F0E5, // Edit region background
-    [EditSel]  = 0xDFDF99, // Edit region selection
-    [EditFg]   = 0x000000, // Edit region text
-    [EditCsr]  = 0x000000, // Edit region cursor
-    [TagsBg]   = 0xE5F0F0, // Tags region background
-    [TagsSel]  = 0x99DFDF, // Tags region selection
-    [TagsFg]   = 0x000000, // Tags region text
-    [TagsCsr]  = 0x000000, // Tags region cursor
-    [ScrollBg] = 0x909047, // Scroll region background
-    [ScrollFg] = 0xF0F0E5, // Scroll region foreground
-    [VerBdr]   = 0x909047, // Vertical border
-    [HorBdr]   = 0x000000, // Horizontal border
-};
index 1a7fe71b86428341d008067e3d88e5fcd9d33069..8bb63baf3d5cda48a8638cfb60245e6247630d48 100644 (file)
@@ -438,6 +438,8 @@ static void xupdate(Job* job) {
             (X.eventfns[e.type])(&X, &e);
         for (int status; waitpid(-1, &status, WNOHANG) > 0;);
     }
+    /* force update the title */
+    win_title(NULL);
     /* determine the size of the regions */
     size_t maxtagrows = ((X.height/4) / X.tagfont->height);
     size_t tagrows = view_limitrows(win_view(TAGS), maxtagrows);
@@ -542,7 +544,6 @@ void win_prop_set(char* xname, char* ename, char* value) {
 
 void win_update(int ms) {
     job_poll(ms);
-    xupdate(NULL);
 }
 
 void win_loop(void) {
index d9b684393c6f25bc6aa0dd5348fe24becd6447e6..0be9c02683079cbec6850422f3afa53e7b00c5a6 100644 (file)
@@ -5,6 +5,8 @@
 #include <win.h>
 #include <ctype.h>
 #include <unistd.h>
+
+#define INCLUDE_DEFS
 #include "config.h"
 
 typedef struct {
@@ -364,19 +366,16 @@ static void goto_ctag(char* arg) {
 static void tabs(char* arg) {
     (void)arg;
     ExpandTabs = !ExpandTabs;
-    win_title(NULL); // force an update of title
 }
 
 static void indent(char* arg) {
     (void)arg;
     CopyIndent = !CopyIndent;
-    win_title(NULL); // force an update of title
 }
 
 static void eol_mode(char* arg) {
     (void)arg;
     DosLineFeed = !DosLineFeed;
-    win_title(NULL);
     View* view = win_view(EDIT);
     view_selectall(view);
     char* txt = view_getstr(view);
@@ -530,8 +529,6 @@ int main(int argc, char** argv) {
         if (line_num) view_setln(win_view(EDIT), line_num);
         win_title(path);
         win_prop_set("FILE", "file", path);
-    } else {
-        win_title("*scratch*");
     }
 
     /* now create the window and start the event loop */