From f47ecc3518e243ffb19b2628f5f9eb1e31fa27d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 3 Apr 2016 15:36:51 +0200 Subject: sam: implement ! command --- sam.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sam.c') 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); -- cgit v1.2.3