From: Michael D. Lowis Date: Sun, 27 Nov 2016 04:03:52 +0000 (-0500) Subject: Added keyboard shortcut for executing the focused selection X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0c059c8d8b9602061073f460eef2d6f40c4e0211;p=projs%2Ftide.git Added keyboard shortcut for executing the focused selection --- diff --git a/inc/edit.h b/inc/edit.h index 299d8cd..b8dced6 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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); diff --git a/libedit/exec.c b/libedit/exec.c index c6c05a1..aad9842 100644 --- a/libedit/exec.c +++ b/libedit/exec.c @@ -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 f56d27a..ece8de7 100644 --- 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;