]> git.mdlowis.com Git - projs/tide.git/commitdiff
minor refactoring and tweak line handling code to ignore jumps to line 0
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Jan 2019 03:34:05 +0000 (22:34 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 2 Jan 2019 03:34:05 +0000 (22:34 -0500)
src/fetch.c
src/lib/view.c
src/tide.c

index 931e45d0522f5bbdec57ceb319fb99bcd75af75f..4a218684a1d3525fddf344b386fc291b391765b4 100644 (file)
@@ -8,7 +8,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-char* ARGV0;
 
 typedef struct {
     enum {
@@ -19,6 +18,7 @@ typedef struct {
     char* arg2;
 } Rule;
 
+char* ARGV0;
 char* Matches[10];
 
 #define FETCH_RULES
index f87ac82732baf156aa8f3249f211c0395285a97a..7eb3edcbd77b1d77bf89ce897257262e95abb736 100644 (file)
@@ -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);
index fae2364b878aa47fb37da8255f32902996cdfe60..c1db3a03be502705a48c59205c25ea169dc6867e 100644 (file)
@@ -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);
     }