From: Michael D. Lowis Date: Wed, 19 Jul 2017 12:17:29 +0000 (-0400) Subject: Added Send tag and middle click behavior when pty is active X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=40807a3ddd6b8317889ebca3a20b208389f15c12;p=projs%2Ftide.git Added Send tag and middle click behavior when pty is active --- diff --git a/TODO.md b/TODO.md index 31184b0..94c8710 100644 --- a/TODO.md +++ b/TODO.md @@ -2,43 +2,42 @@ Up Next: +* B2+B1 click executes command with selection as argument +* right click to fetch file or line +* Run commands in the background and don't block the main thread. +* ignore the menu key or map it to control +* Add a separate config option for pty tags +* update man pages with new functionality + * moving from tags to the gutter does not transfer focus to edit region * implement transaction control in buf.c -* highlight all matches of search term -* highlight classes of identifiers * Add a way to CD using a builtin (buffers will track original dir) * shortcut to jump to previous edit * add command line flags to toggle options (Tabs, Indent, etc..) * move by words is inconsistent. Example: var infoId = 'readerinfo'+reader.id; -* ignore the menu key or map it to control The Future: -* Ctrl+/ shortcut to comment/uncomment based on syntax * Case insensitive search * Ctrl+Up,Down requires two undos to revert. * Ctrl+Up,Down with non line selection should track column -* Scrolling line offset * Ctrl+Shift+Enter copies indent of wrong line -* Make Fn keys execute nth command in the tags buffers -* jump to previous or next line with less indent * use transaction ids to only mark buffer dirty when it really is * refactor selection handling to buf.c to prepare for multiple selections. * 100% coverage with unit and unit-integration tests -* right click to fetch file or line * tab inserts dont coalesce like one would expect -* Run commands in the background and don't block the main thread. -* shortcut to repeat previous operation * implement command diffing logic to optimize the undo/redo log * Status line should omit characters from beginning of path to make file path fit * pickfile directory traversal when no tags file Possible Shortcuts: +* Ctrl+/ - to comment/uncomment based on syntax * Ctrl+{,} - Move to start or end brace of block * Ctrl+(,) - Move to start or end of paragraph * Ctrl+' - Move to matching brace, bracket, or paren +* Ctrl+. - repeat previous operation Maybe think about addressing these later: @@ -76,6 +75,15 @@ Operators: {n,m} From n to m matches | Alternative +# tcmd Tags + +build +fetch +ls +cat +cd + + # Syntax Highlighting Label, Conditional, Repeat, Character, Number, PreProc, Float, Operator, Structure diff --git a/inc/edit.h b/inc/edit.h index b293367..e7dabff 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -232,7 +232,7 @@ int exec_spawn(char** cmd, int* in, int* out); *****************************************************************************/ bool pty_active(void); void pty_spawn(char** argv); -void pty_send(char* cmd); +void pty_send(char* cmd, char* arg); void pty_send_rune(Rune rune); void pty_send_intr(void); void pty_send_eof(void); diff --git a/lib/pty.c b/lib/pty.c index d783d9c..ad95b4e 100644 --- a/lib/pty.c +++ b/lib/pty.c @@ -50,19 +50,26 @@ void pty_spawn(char** argv) { event_watchfd(PtyFD, INPUT, update, NULL); } -void pty_send(char* str) { - if (!str) return; - view_eof(win_view(EDIT), false); +void send_string(char* str) { size_t sz = strlen(str); - bool has_eol = (str[sz-1] == '\n'); + if (str[sz-1] == '\n') str[sz-1] = '\0'; while (*str) { Rune rune = 0; size_t length = 0; while (!utf8decode(&rune, &length, *str++)); pty_send_rune(rune); } - if (!has_eol) - pty_send_rune('\n'); +} + +void pty_send(char* cmd, char* arg) { + if (!cmd) return; + view_eof(win_view(EDIT), false); + send_string(cmd); + if (arg) { + pty_send_rune(' '); + send_string(arg); + } + pty_send_rune('\n'); } void pty_send_rune(Rune rune) { diff --git a/tide.c b/tide.c index 325fac4..a9e34cc 100644 --- a/tide.c +++ b/tide.c @@ -94,7 +94,10 @@ static void exec(char* cmd) { while (*cmd && !isspace(*cmd++)); tag_exec(tag, (*cmd ? stringdup(cmd) : NULL)); } else if (pty_active()) { - pty_send(cmd); + char* arg = view_getstr(win_view(TAGS), NULL); + if (!arg) arg = view_getstr(win_view(EDIT), NULL); + pty_send(cmd, arg); + free(arg); } else { cmd_exec(cmd); } @@ -401,6 +404,10 @@ static void jumpmark(void) { view_jumpto(win_view(FOCUSED), false, Marks[mark]); } +static void tag_send(char* cmd) { + pty_send(cmd, NULL); +} + /* Main Routine ******************************************************************************/ static Tag Builtins[] = { @@ -417,7 +424,7 @@ static Tag Builtins[] = { { .tag = "Reload", .action.noarg = reload }, { .tag = "Save", .action.noarg = save }, { .tag = "SaveAs", .action.arg = saveas }, - { .tag = "Send", .action.arg = pty_send }, + { .tag = "Send", .action.arg = tag_send }, { .tag = "Tabs", .action.noarg = tabs }, { .tag = "Undo", .action.noarg = tag_undo }, { .tag = "LineNums", .action.noarg = tag_lnnum },