vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit a1ad84e30b57f34c8cdfbc02e5846669d2f17985
parent 57da12a57e88235cd1cc1e6f45252ee71c2e263c
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun,  3 Apr 2016 15:36:51 +0200

sam: implement ! command

Diffstat:
Msam.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git 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);