]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added Send tag and middle click behavior when pty is active
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 19 Jul 2017 12:17:29 +0000 (08:17 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 19 Jul 2017 12:17:29 +0000 (08:17 -0400)
TODO.md
inc/edit.h
lib/pty.c
tide.c

diff --git a/TODO.md b/TODO.md
index 31184b022756fddd9a6bb768645f2437a72392e6..94c87102cb95cd0d4225113be11e8d07412ee61e 100644 (file)
--- 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
index b293367a34fe48124a7c87cc2fc36dbe754692fb..e7dabff55f690c50a7b34f6bc4a247a0c001f605 100644 (file)
@@ -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);
index d783d9cab753f71761965cfd2c012e47caf36333..ad95b4eb61b4e826f8ac25af2d1d1777528adbf1 100644 (file)
--- 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 325fac4ddb2bf441723b18111a20cd756a5d1aeb..a9e34cc8cb129a1ae3b91b4d6efff05117584395 100644 (file)
--- 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 },