aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2018-02-27 16:17:55 +0100
committerMarc André Tanner <mat@brain-dump.org>2018-02-27 18:57:40 +0100
commit0a3a82cd7d90abd206ce2cf9151d3cbed01a20af (patch)
treed8cddd0bc0389bec1a602b6eed83ee53da144b71
parentc0832d6fc7eace1c6da9867d8b327bf62c968098 (diff)
downloadvis-0a3a82cd7d90abd206ce2cf9151d3cbed01a20af.tar.gz
vis-0a3a82cd7d90abd206ce2cf9151d3cbed01a20af.tar.xz
vis: implement normal/outer paragraph text object
-rw-r--r--config.def.h2
-rw-r--r--main.c6
m---------test10
-rw-r--r--text-objects.c6
-rw-r--r--text-objects.h1
-rw-r--r--vis-text-objects.c3
-rw-r--r--vis.h1
7 files changed, 23 insertions, 6 deletions
diff --git a/config.def.h b/config.def.h
index 2cb06b0..74031c0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -106,7 +106,7 @@ static const KeyBinding bindings_textobjects[] = {
{ "aB", ALIAS("a{") },
{ "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
{ "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
- { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
+ { "ap", ACTION(TEXT_OBJECT_PARAGRAPH_OUTER) },
{ "as", ACTION(TEXT_OBJECT_SENTENCE) },
{ "a<Tab>", ACTION(TEXT_OBJECT_INDENTATION) },
{ "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
diff --git a/main.c b/main.c
index c810ed4..75ac070 100644
--- a/main.c
+++ b/main.c
@@ -304,6 +304,7 @@ enum {
VIS_ACTION_TEXT_OBJECT_LONGWORD_INNER,
VIS_ACTION_TEXT_OBJECT_SENTENCE,
VIS_ACTION_TEXT_OBJECT_PARAGRAPH,
+ VIS_ACTION_TEXT_OBJECT_PARAGRAPH_OUTER,
VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_OUTER,
VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_INNER,
VIS_ACTION_TEXT_OBJECT_PARANTHESE_OUTER,
@@ -1118,6 +1119,11 @@ static const KeyAction vis_action[] = {
VIS_HELP("A paragraph")
textobj, { .i = VIS_TEXTOBJECT_PARAGRAPH }
},
+ [VIS_ACTION_TEXT_OBJECT_PARAGRAPH_OUTER] = {
+ "vis-textobject-paragraph-outer",
+ VIS_HELP("A paragraph (outer variant)")
+ textobj, { .i = VIS_TEXTOBJECT_PARAGRAPH_OUTER }
+ },
[VIS_ACTION_TEXT_OBJECT_SQUARE_BRACKET_OUTER] = {
"vis-textobject-square-bracket-outer",
VIS_HELP("[] block (outer variant)")
diff --git a/test b/test
-Subproject 4ae17e980dba66ef1b47a64cd4c90bded34d3e7
+Subproject e5db37e513d4090bae356f8b91fdc5e84cff4a6
diff --git a/text-objects.c b/text-objects.c
index 27553b8..1f44222 100644
--- a/text-objects.c
+++ b/text-objects.c
@@ -205,6 +205,12 @@ Filerange text_object_paragraph(Text *txt, size_t pos) {
return r;
}
+Filerange text_object_paragraph_outer(Text *txt, size_t pos) {
+ Filerange p1 = text_object_paragraph(txt, pos);
+ Filerange p2 = text_object_paragraph(txt, p1.end);
+ return text_range_union(&p1, &p2);
+}
+
static Filerange text_object_bracket(Text *txt, size_t pos, char type) {
char c, open, close;
int opened = 1, closed = 1;
diff --git a/text-objects.h b/text-objects.h
index 384de5f..5be783b 100644
--- a/text-objects.h
+++ b/text-objects.h
@@ -29,6 +29,7 @@ Filerange text_object_line(Text*, size_t pos);
Filerange text_object_line_inner(Text*, size_t pos);
Filerange text_object_sentence(Text*, size_t pos);
Filerange text_object_paragraph(Text*, size_t pos);
+Filerange text_object_paragraph_outer(Text*, size_t pos);
/* these are inner text objects i.e. the delimiters themself are not
* included in the range */
diff --git a/vis-text-objects.c b/vis-text-objects.c
index 446ac6d..43679f0 100644
--- a/vis-text-objects.c
+++ b/vis-text-objects.c
@@ -114,6 +114,9 @@ const TextObject vis_textobjects[] = {
[VIS_TEXTOBJECT_PARAGRAPH] = {
.txt = text_object_paragraph,
},
+ [VIS_TEXTOBJECT_PARAGRAPH_OUTER] = {
+ .txt = text_object_paragraph_outer,
+ },
[VIS_TEXTOBJECT_OUTER_SQUARE_BRACKET] = {
.txt = text_object_square_bracket,
.type = TEXTOBJECT_DELIMITED_OUTER,
diff --git a/vis.h b/vis.h
index a89819b..9abf716 100644
--- a/vis.h
+++ b/vis.h
@@ -610,6 +610,7 @@ enum VisTextObject {
VIS_TEXTOBJECT_OUTER_LONGWORD,
VIS_TEXTOBJECT_SENTENCE,
VIS_TEXTOBJECT_PARAGRAPH,
+ VIS_TEXTOBJECT_PARAGRAPH_OUTER,
VIS_TEXTOBJECT_OUTER_SQUARE_BRACKET,
VIS_TEXTOBJECT_INNER_SQUARE_BRACKET,
VIS_TEXTOBJECT_OUTER_CURLY_BRACKET,