From a204754c259adc2e922ed3fb83bc8407d50fe416 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 19 Dec 2018 21:44:54 -0500 Subject: [PATCH] fixed bug in handling of config variables and optimized drawing logic for title --- TODO.md | 2 +- config.h | 31 +++++++++++++++++------------ src/lib/config.c | 52 ------------------------------------------------ src/lib/x11.c | 3 ++- src/tide.c | 7 ++----- 5 files changed, 23 insertions(+), 72 deletions(-) delete mode 100644 src/lib/config.c diff --git a/TODO.md b/TODO.md index 7850db7..eda4391 100644 --- 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 diff --git a/config.h b/config.h index 543597d..169cfb2 100644 --- 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 index 41f7fef..0000000 --- a/src/lib/config.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include -#include - -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 -}; diff --git a/src/lib/x11.c b/src/lib/x11.c index 1a7fe71..8bb63ba 100644 --- a/src/lib/x11.c +++ b/src/lib/x11.c @@ -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) { diff --git a/src/tide.c b/src/tide.c index d9b6843..0be9c02 100644 --- a/src/tide.c +++ b/src/tide.c @@ -5,6 +5,8 @@ #include #include #include + +#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 */ -- 2.52.0