]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed a bug in edit_relative function, added a cursor summoning shortcut fixed linkin...
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 30 May 2017 15:07:29 +0000 (11:07 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 30 May 2017 15:07:29 +0000 (11:07 -0400)
TODO.md
config.mk
inc/edit.h
inc/shortcuts.h
lib/utils.c
lib/view.c
term.c
tide.c

diff --git a/TODO.md b/TODO.md
index 416a49d1319b6e7986ca157234a5b3c006abef86..45560d30925d50af04be206e57ce43b6b374c3f9 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -5,7 +5,7 @@ Up Next:
 * move by words is inconsistent. Example:
     var infoId = 'readerinfo'+reader.id;
 * Add a way to CD using a builtin (buffers will track original dir)
-* selection of 1 and arrow keys moves wrong direction
+* selection of size 1 and arrow keys moves wrong direction
 * cd to root in xcpd
 * Ctrl+; Shortcut to warp cursor to middle of current screen.
 * shortcut to jump to previous edit
@@ -33,6 +33,7 @@ Maybe think about addressing these later:
 * Shift+Insert should insert primary selection
 * Find shortcut should select previous word if current char is newline
 * diagnostic messages can stack up if deselected and not resolved
+* mouse click and hold on scroll bar should continually scroll
 
 # Auxillary Programs
 
index 583123a3e7cf72da1c8220cb20d106ee3c3e7e15..f2e2dcef6a80f5b330d4b2d000b068cd289f5a7b 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -18,7 +18,7 @@ CFLAGS = --std=c99 -MMD $(INCS)
 
 # Linker Setup
 LD = $(CC)
-LDFLAGS = $(LIBS) -lX11 -lXft -lfontconfig
+LDFLAGS = $(LIBS) -lX11 -lXft -lfontconfig -lutil
 
 # Archive Setup
 AR = ar
index af2e8ba9fe060032a92192bd81f7b8fb3268485e..d5497d31982476a9e3bca68437732869cf1548ae 100644 (file)
@@ -176,6 +176,7 @@ char* view_getcmd(View* view);
 char* view_getctx(View* view);
 void view_selctx(View* view);
 void view_scroll(View* view, int move);
+void view_csrsummon(View* view);
 void view_scrollpage(View* view, int move);
 void view_setln(View* view, size_t line);
 void view_indent(View* view, int dir);
index a3a6258e570f0be608dc202f0ba538fbafe4840b..9835c610c0bc884f86240ad1ab666247e2efc554 100644 (file)
@@ -148,6 +148,10 @@ static void cursor_right(void) {
         view_byrune(win_view(FOCUSED), RIGHT, extsel);
 }
 
+static void cursor_warp(void) {
+    view_csrsummon(win_view(FOCUSED));
+}
+
 static void page_up(void) {
     view_scrollpage(win_view(FOCUSED), UP);
 }
index ceebd3ec7ee56e6c27f1bf37ec32e5f6f4f8832b..f94eb87dae8fea055360d49371d64195afa69a89 100644 (file)
@@ -137,8 +137,8 @@ char* strconcat(char* dest, ...) {
     va_list args;
     char* curr = dest;
     va_start(args, dest);
-    for (char* s; (s = va_arg(args, char*));)
-        while (*s) *(curr++) = *(s++);
+    for (char* s = NULL; (s = va_arg(args, char*));)
+        while (s && *s) *(curr++) = *(s++);
     va_end(args);
     *curr = '\0';
     return dest;
index 66d20b8c49022d257136ae474acf1f00129270ea..6d330ace895dfb1108579f808ef03231c7d1b15d 100644 (file)
@@ -567,37 +567,25 @@ void view_scroll(View* view, int move) {
     }
 }
 
-void view_scrollpage(View* view, int move) {
+void view_csrsummon(View* view) {
     size_t col = SIZE_MAX, row = SIZE_MAX;
     find_cursor(view, &col, &row);
-    move = (move < 0 ? -1 : 1) * view->nrows;
-    view_scroll(view, move);
-    size_t off    = view->rows[view->nrows/2]->off;
-
-//    size_t scrbeg = view->rows[0]->off;
-//    size_t scrend = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen - 1;
-//    if (scrbeg == 0)
-//        off = 0;
-//    else if (scrend >= buf_end(&(view->buffer)))
-//        off = view->rows[view->nrows-1]->off;
-
-//    size_t off = (move == UP ? view->rows[0]->off : view->rows[view->nrows/2]->off);
-//    if (row != SIZE_MAX && col != SIZE_MAX) {
-//        off = view->rows[row]->off + col;
-//        if (col >= view->rows[row]->rlen)
-//            off = view->rows[row]->off + view->rows[row]->rlen - 1;
-//    }
-
+    size_t off = view->rows[view->nrows/2]->off;
     if (row != SIZE_MAX && col != SIZE_MAX)
         if (col >= view->rows[view->nrows/2]->rlen)
             off = view->rows[view->nrows/2]->off + view->rows[view->nrows/2]->rlen - 1;
         else
             off += col;
-
     view_jumpto(view, false, off);
     view->sync_needed = false;
 }
 
+void view_scrollpage(View* view, int move) {
+    move = (move < 0 ? -1 : 1) * view->nrows;
+    view_scroll(view, move);
+    view_csrsummon(view);
+}
+
 void view_indent(View* view, int dir) {
     Buf* buf = &(view->buffer);
     unsigned indoff = (buf->expand_tabs ? TabWidth : 1);
diff --git a/term.c b/term.c
index 14b8c3e8e059b20275126645df4f3778010f5a4b..b6b523a89ff5db5a0dc84f79707574d926f11059 100644 (file)
--- a/term.c
+++ b/term.c
@@ -40,8 +40,12 @@ void onerror(char* msg) {
 
 #ifndef TEST
 #include <unistd.h>
-#include <util.h>
 #include <sys/ioctl.h>
+#ifdef __MACH__
+#include <util.h>
+#else
+#include <pty.h>
+#endif
 
 void spawn_shell(int master, int slave) {
        static char* shell[] = { "/bin/sh", "-l", NULL };
diff --git a/tide.c b/tide.c
index ad45db00942be2c8d9e132356ec67d45c7c3f55c..4441a24fcc3c2909dd8b4311eda345a21b2516b0 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -417,12 +417,13 @@ static Tag Builtins[] = {
 
 static KeyBinding Bindings[] = {
     /* Cursor Movements */
-    { ModAny, KEY_HOME,  cursor_home  },
-    { ModAny, KEY_END,   cursor_end   },
-    { ModAny, KEY_UP,    cursor_up    },
-    { ModAny, KEY_DOWN,  cursor_dn    },
-    { ModAny, KEY_LEFT,  cursor_left  },
-    { ModAny, KEY_RIGHT, cursor_right },
+    { ModAny,  KEY_HOME,  cursor_home  },
+    { ModAny,  KEY_END,   cursor_end   },
+    { ModAny,  KEY_UP,    cursor_up    },
+    { ModAny,  KEY_DOWN,  cursor_dn    },
+    { ModAny,  KEY_LEFT,  cursor_left  },
+    { ModAny,  KEY_RIGHT, cursor_right },
+    { ModCtrl, ';',       cursor_warp  },
 
     /* Standard Unix Shortcuts */
     { ModCtrl, 'u', del_to_bol  },
@@ -534,9 +535,10 @@ void edit_relative(char* path) {
 
     /* search for a ctags index file indicating the project root */
     if (try_chdir(path)) {
-        currdir  = getcurrdir();
-        currpath = calloc(strlen(currdir) + strlen("/tags") + 1, 1);
-        relpath  = calloc(strlen(currdir) + strlen("/tags") + 1, 1);
+        currdir   = getcurrdir();
+        size_t sz = strlen(currdir) + strlen(path) + strlen("/tags") + 1;
+        currpath  = calloc(sz, 1);
+        relpath   = calloc(sz, 1);
         while (true) {
             /* figure out the current path to check */
             strconcat(currpath, currdir, "/tags", 0);
@@ -559,7 +561,7 @@ void edit_relative(char* path) {
     if (currdir && *currdir) {
         char* fname = strrchr(path, '/')+1;
         if (*relpath)
-            strconcat(currpath, relpath+1, "/", fname, 0);
+            strconcat(currpath, (*relpath == '/' ? relpath+1 : relpath), "/", fname, 0);
         else
             strconcat(currpath, fname, 0);
         chdir(currdir);