]> git.mdlowis.com Git - projs/tide.git/commitdiff
added scroll toggling tag
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 30 Nov 2019 03:28:43 +0000 (22:28 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 30 Nov 2019 03:28:43 +0000 (22:28 -0500)
TODO.md
inc/xpty.h
src/lib/xpty.c
src/tide.c

diff --git a/TODO.md b/TODO.md
index 5a160d59022ffb1f614365aa95b097ce615af641..73b3e220388e6023ca4b18cde6bfd6a1f0a9b358 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -4,7 +4,6 @@
 
 ## STAGING
 
-* tide: implement hold mode and tag to enable/disable autoscroll
 * tide: point should be added to editlog to ensure undo/redo behave appropriately
 * tide: tab in point does fcomplete maybe?
 * fetch: don't exit on rulesets with no launch or exec rules
index c70315f3757c15d3e7d9dcf97512ad83f88b3663..af691c5c23af8659cffe5f6ef97f012bd2bbc50f 100644 (file)
@@ -1,4 +1,5 @@
 bool xpty_active(void);
+void xpty_togglescroll(void);
 int xpty_run(View* view, char** cmd);
 void xpty_send(char* cmd);
 void xpty_rawsend(char* cmd);
index b7dc217e92de9fba36870902579b4a1bcda0441b..a7df1d7f3cf0386cc8f16c03f197cf3272ddb8f8 100644 (file)
@@ -13,6 +13,7 @@
 
 static View* EditView = NULL;
 static int Pty_Fd = -1;
+static bool DoScroll = 1;
 static char ReadBuf[BUFFERSZ+1] = {0};
 static char ArgsBuf[BUFFERSZ+1] = {0};
 static char InputBuf[BUFFERSZ+1] = {0};
@@ -151,7 +152,10 @@ static void writedata(char* buf, long n)
         Handlers[State](buf[i]);
     }
     view_putraw(EditView, InputBuf);
-    EditView->sync_flags |= CURSOR;
+    if (DoScroll)
+    {
+        EditView->sync_flags |= CURSOR;
+    }
 }
 
 static void xpty_read(Job* job)
@@ -203,6 +207,11 @@ bool xpty_active(void)
     return (Pty_Fd >= 0);
 }
 
+void xpty_togglescroll(void)
+{
+    DoScroll = !DoScroll;
+}
+
 int xpty_run(View* view, char** cmd)
 {
     (void)view;
index 6718d7b8037455bb72f3ba3a794f504983ebab2d..3135f47ab2bd3c4d8d3d4166f297762fabc45f05 100644 (file)
@@ -607,6 +607,12 @@ static void tag_line(char* cmd)
     view_paste(win_view(TAGS), buf);
 }
 
+static void do_scroll(char* arg)
+{
+    (void)arg;
+    xpty_togglescroll();
+}
+
 /* Main Routine
  ******************************************************************************/
 Tag* Builtins = (Tag[]){
@@ -627,6 +633,7 @@ Tag* Builtins = (Tag[]){
     { .tag = "Font",   .action = win_font  },
     { .tag = "Kill",   .action = tag_kill  },
     { .tag = "Line",   .action = tag_line  },
+    { .tag = "Scroll", .action = do_scroll },
     { .tag = NULL,     .action = NULL      }
 };