aboutsummaryrefslogtreecommitdiff
path: root/vis-operators.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-27 07:23:36 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-27 07:23:36 +0100
commit7ce4e0cc1423bb55f798031014462fd192d23fc3 (patch)
treef0eb89dbf2b92c92eba0458f5344fc0a3f6eb68b /vis-operators.c
parente063464c7cdeb41796282d0efe13cc907928f3f8 (diff)
downloadvis-7ce4e0cc1423bb55f798031014462fd192d23fc3.tar.gz
vis-7ce4e0cc1423bb55f798031014462fd192d23fc3.tar.xz
vis: implement filter operator !
It currently works by switching to visual mode and then opening the command prompt with a default range which refers to the currently active selection.
Diffstat (limited to 'vis-operators.c')
-rw-r--r--vis-operators.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/vis-operators.c b/vis-operators.c
index 981922b..e93f946 100644
--- a/vis-operators.c
+++ b/vis-operators.c
@@ -204,6 +204,11 @@ static size_t op_replace(Vis *vis, Text *txt, OperatorContext *c) {
return c->newpos != EPOS ? c->newpos : c->pos;
}
+static size_t op_filter(Vis *vis, Text *txt, OperatorContext *c) {
+ macro_operator_record(vis);
+ return text_size(txt) + 1; /* do not change cursor position, would destroy selection */
+}
+
Operator ops[] = {
[VIS_OP_DELETE] = { op_delete },
[VIS_OP_CHANGE] = { op_change },
@@ -216,4 +221,5 @@ Operator ops[] = {
[VIS_OP_INSERT] = { op_insert },
[VIS_OP_REPLACE] = { op_replace },
[VIS_OP_CURSOR_SOL] = { op_cursor },
+ [VIS_OP_FILTER] = { op_filter },
};