aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-03 15:36:51 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-03 21:38:05 +0200
commitf47ecc3518e243ffb19b2628f5f9eb1e31fa27d8 (patch)
treebe5bd5236e5ae9de926f40a16cf0ab1d32c756dc /sam.c
parent217126c9872dc5a6e867603ad618bb85ceaa3c47 (diff)
downloadvis-f47ecc3518e243ffb19b2628f5f9eb1e31fa27d8.tar.gz
vis-f47ecc3518e243ffb19b2628f5f9eb1e31fa27d8.tar.xz
sam: implement ! command
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sam.c b/sam.c
index 7f21ad5..cc28404 100644
--- a/sam.c
+++ b/sam.c
@@ -81,6 +81,7 @@ static bool cmd_files(Vis*, Win*, Command*, const char *argv[], Cursor*, Fileran
static bool cmd_pipein(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
static bool cmd_pipeout(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
static bool cmd_filter(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
+static bool cmd_launch(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
static bool cmd_substitute(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
static bool cmd_write(Vis*, Win*, Command*,const char *argv[], Cursor*, Filerange*);
static bool cmd_read(Vis*, Win*, Command*, const char *argv[], Cursor*, Filerange*);
@@ -123,6 +124,7 @@ static const CommandDef cmds[] = {
{ { ">" }, CMD_SHELL, NULL, cmd_pipeout },
{ { "<" }, CMD_SHELL, NULL, cmd_pipein },
{ { "|" }, CMD_SHELL, NULL, cmd_filter },
+ { { "!" }, CMD_SHELL, NULL, cmd_launch },
{ { "w" }, CMD_ARGV|CMD_FORCE, NULL, cmd_write },
{ { "r" }, CMD_FILE, NULL, cmd_read },
{ { "{" }, 0, NULL, NULL },
@@ -1088,6 +1090,11 @@ static bool cmd_filter(Vis *vis, Win *win, Command *cmd, const char *argv[], Cur
return !vis->cancel_filter && status == 0;
}
+static bool cmd_launch(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) {
+ Filerange empty = text_range_new(range->start, EPOS);
+ return cmd_filter(vis, win, cmd, argv, cur, &empty);
+}
+
static bool cmd_pipein(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) {
Filerange filter_range = text_range_new(range->end, range->end);
bool ret = cmd_filter(vis, win, cmd, (const char*[]){ argv[0], argv[1], NULL }, cur, &filter_range);