]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added keyboard shortcut for executing the focused selection
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 27 Nov 2016 04:03:52 +0000 (23:03 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 27 Nov 2016 04:03:52 +0000 (23:03 -0500)
inc/edit.h
libedit/exec.c
xedit.c

index 299d8cd99760326b095f6d5597a1fc9c9e170447..b8dced645abe78d9e5ac8240df1c39a9086bcb48 100644 (file)
@@ -181,7 +181,6 @@ typedef struct {
     int err; /* file descriptor for the child process's standard error */
 } Process;
 
-int execute(char** cmd, Process* proc);
 void detach(Process* proc);
 void terminate(Process* proc, int sig);
 char* cmdread(char** cmd);
index c6c05a143d92880b093e38b4c1838309e4a214d8..aad984268c68cb9b2f17f9eef1a878119c3f9c11 100644 (file)
@@ -8,7 +8,7 @@
 #define PIPE_READ 0
 #define PIPE_WRITE 1
 
-int execute(char** cmd, Process* proc) {
+static int execute(char** cmd, Process* proc) {
     int inpipe[2], outpipe[2], errpipe[2];
     /* create the pipes */
     if ((pipe(inpipe) < 0) || (pipe(outpipe) < 0) || (pipe(errpipe) < 0))
diff --git a/xedit.c b/xedit.c
index f56d27a82612353dbf407c219f80c200be9fcb02..ece8de7cbfbd6ac5c911cc2b4fffd50cb334e383 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -44,6 +44,7 @@ static void cut(void);
 static void copy(void);
 static void paste(void);
 static void search(void);
+static void execute(void);
 static void find(char* arg);
 
 // Tag/Cmd Execution
@@ -119,6 +120,7 @@ static KeyBinding Insert[] = {
     { KEY_CTRL_C,    copy         },
     { KEY_CTRL_V,    paste        },
     { KEY_CTRL_F,    search       },
+    { KEY_CTRL_E,    execute      },
     { 0,             NULL         }
 };
 
@@ -133,7 +135,6 @@ static char* PasteCmd[] = { "xsel", "-bo", NULL };
 #endif
 static char* ShellCmd[] = { "/bin/sh", "-c", NULL, NULL };
 
-
 /* Main Routine
  *****************************************************************************/
 int main(int argc, char** argv) {
@@ -418,6 +419,12 @@ static void search(void) {
     free(str);
 }
 
+static void execute(void) {
+    char* str = view_getstr(currview(), NULL);
+    if (str) exec(str);
+    free(str);
+}
+
 static void find(char* arg) {
     view_findstr(getview(EDIT), arg);
 }
@@ -449,6 +456,7 @@ static void cmd_exec(char* cmd) {
     char op = '\0';
     if (*cmd == '!' || *cmd == '<' || *cmd == '|' || *cmd == '>')
         op = *cmd, cmd++;
+    ShellCmd[2] = cmd;
     /* execute the command */
     char *input = NULL, *output = NULL;
     enum RegionId dest = EDIT;