From 4fdda31b28ff756a350fbee68d82f9f50e3d6f5e Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 26 Nov 2019 22:38:18 -0500 Subject: [PATCH] tweaked xpty input to only send input on newline at end of point --- TODO.md | 2 -- src/lib/xpty.c | 14 ++++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 6ca1f29..5a160d5 100644 --- a/TODO.md +++ b/TODO.md @@ -5,10 +5,8 @@ ## STAGING * tide: implement hold mode and tag to enable/disable autoscroll -* tide: only newline at end of point should send to subprocess * 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 * picktag: reimplement in C using binary search * fetch: add option to capture output of command diff --git a/src/lib/xpty.c b/src/lib/xpty.c index f0141a7..8efac44 100644 --- a/src/lib/xpty.c +++ b/src/lib/xpty.c @@ -13,13 +13,11 @@ static View* EditView = NULL; static int Pty_Fd = -1; - -char ReadBuf[BUFFERSZ+1] = {0}; -char ArgsBuf[BUFFERSZ+1] = {0}; -char InputBuf[BUFFERSZ+1] = {0}; -ssize_t ArgsPos = 0; -ssize_t InputPos = 0; - +static char ReadBuf[BUFFERSZ+1] = {0}; +static char ArgsBuf[BUFFERSZ+1] = {0}; +static char InputBuf[BUFFERSZ+1] = {0}; +static ssize_t ArgsPos = 0; +static ssize_t InputPos = 0; static enum { READ_CHAR = 0, READ_ESC, @@ -114,7 +112,7 @@ static void putb(int byte) read(Pty_Fd, &b, 1); } } - else if (byte == '\n' && buf_inpoint(&(EditView->buffer), EditView->buffer.selection.end-1)) + else if (byte == '\n' && (EditView->buffer.selection.end == EditView->buffer.point.end)) { /* get the input string and update the point */ char* str = buf_getsat(&(EditView->buffer), EditView->buffer.point.beg, EditView->buffer.point.end); -- 2.52.0