From 2464b3fc39fe08e4db92aef33f601ca1a487413d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 11 Nov 2019 16:35:45 -0500 Subject: [PATCH] added cmd_exec hook for running programs interactively in preparation for implementing terminal mode --- .gitignore | 1 + src/lib/utf8.c | 2 +- src/tide.c | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fb65b6b..c229b42 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ bin/tframe bin/anvil .rscons* build/ +bin/fetchsel diff --git a/src/lib/utf8.c b/src/lib/utf8.c index 7305ed4..622dc67 100644 --- a/src/lib/utf8.c +++ b/src/lib/utf8.c @@ -119,7 +119,7 @@ bool risword(Rune r) bool rissigil(Rune r) { - return (r == ':' || r == '!' || r == '|' || r == '>' || r == '<'); + return (r == ':' || r == '!' || r == '&' || r == '|' || r == '>' || r == '<'); } bool risfile(Rune r) diff --git a/src/tide.c b/src/tide.c index 938e75d..d9ee15d 100644 --- a/src/tide.c +++ b/src/tide.c @@ -445,20 +445,38 @@ static void cmd_exec(char* cmd) /* get the selection that the command will operate on */ if (op && op != '<' && op != '!' && !view_selsize(win_view(EDIT))) + { view_selectall(win_view(EDIT)); + } char* input = view_getstr(win_view(EDIT)); size_t len = (input ? strlen(input) : 0); View *tags = win_view(TAGS), *edit = win_view(EDIT), *curr = win_view(FOCUSED); /* execute the job */ - if (op == '!') - free(input), job_start(execcmd, NULL, 0, NULL); + if (op == '!' || op == '&') + { + free(input); + if (op == '&') + { +// xpty_init(win_view(EDIT), execcmd); + } + else + { + job_start(execcmd, NULL, 0, NULL); + } + } else if (op == '>') + { job_start(execcmd, input, len, tags); + } else if (op == '|' || op == ':') + { job_start(execcmd, input, len, edit); + } else + { job_start(execcmd, input, len, (op != '<' ? curr : edit)); + } } static void exec(char* cmd, char* arg) -- 2.52.0