From: Michael D. Lowis Date: Sat, 30 Nov 2019 03:28:43 +0000 (-0500) Subject: added scroll toggling tag X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=226d6161618ab88f66fb3dd806359bcf51887c2f;p=projs%2Ftide.git added scroll toggling tag --- diff --git a/TODO.md b/TODO.md index 5a160d5..73b3e22 100644 --- 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 diff --git a/inc/xpty.h b/inc/xpty.h index c70315f..af691c5 100644 --- a/inc/xpty.h +++ b/inc/xpty.h @@ -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); diff --git a/src/lib/xpty.c b/src/lib/xpty.c index b7dc217..a7df1d7 100644 --- a/src/lib/xpty.c +++ b/src/lib/xpty.c @@ -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; diff --git a/src/tide.c b/src/tide.c index 6718d7b..3135f47 100644 --- a/src/tide.c +++ b/src/tide.c @@ -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 } };