From: Michael D. Lowis Date: Wed, 2 Jan 2019 03:34:05 +0000 (-0500) Subject: minor refactoring and tweak line handling code to ignore jumps to line 0 X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=527a556e76252cb160c2248aa4dcb698d5412276;p=projs%2Ftide.git minor refactoring and tweak line handling code to ignore jumps to line 0 --- diff --git a/src/fetch.c b/src/fetch.c index 931e45d..4a21868 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -8,7 +8,6 @@ #include #include -char* ARGV0; typedef struct { enum { @@ -19,6 +18,7 @@ typedef struct { char* arg2; } Rule; +char* ARGV0; char* Matches[10]; #define FETCH_RULES diff --git a/src/lib/view.c b/src/lib/view.c index f87ac82..7eb3edc 100644 --- a/src/lib/view.c +++ b/src/lib/view.c @@ -315,6 +315,7 @@ void view_eof(View* view, bool extsel) { } void view_setln(View* view, size_t line) { + if (!line) return; buf_setln(BUF, line); view->sync_flags |= CENTER; buf_selln(BUF); diff --git a/src/tide.c b/src/tide.c index fae2364..c1db3a0 100644 --- a/src/tide.c +++ b/src/tide.c @@ -426,19 +426,14 @@ void win_prop_set(char* xname, char* ename, char* value) { if (ename) setenv(ename, value, 1); } -void win_update(int ms) { - if (job_poll(ms)) - xupdate(NULL); -} - void win_loop(void) { X.running = True; XMapWindow(X.display, X.self); tide_send("ADD"); job_spawn(ConnectionNumber(X.display), xupdate, 0, 0); - while (X.running) { - win_update(Timeout); - } + while (X.running) + if (job_poll(Timeout)) + xupdate(NULL); } void win_quit(void) { @@ -983,7 +978,7 @@ int main(int argc, char** argv) { char* path = realpath(*argv, NULL); if (!path) path = *argv; /* if file doesnt exist, use the original name */ view_init(win_view(EDIT), path); - if (line_num) view_setln(win_view(EDIT), line_num); + view_setln(win_view(EDIT), line_num); win_title(path); win_prop_set("FILE", "file", path); }