aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-12-28 14:40:26 +0100
committerMarc André Tanner <mat@brain-dump.org>2020-12-28 14:51:59 +0100
commit0b082239bc60f0a6a3cb743b38a63684652ae649 (patch)
tree0195fad9b9f4588601fd4980e4c11c1acf14064e
parent41b235584feeb492d082cdc7bbb735cc49b08180 (diff)
downloadvis-0b082239bc60f0a6a3cb743b38a63684652ae649.tar.gz
vis-0b082239bc60f0a6a3cb743b38a63684652ae649.tar.xz
vis: rename to/till motion internals
This renames the functions and constants implementing the to/till motions. The new names should indicate that matches are only returned within the current line (not globally). Apart from the changed virtual key/command name this contains no functional changes.
-rw-r--r--config.def.h8
-rw-r--r--main.c48
-rw-r--r--vis-motions.c52
-rw-r--r--vis.h8
4 files changed, 58 insertions, 58 deletions
diff --git a/config.def.h b/config.def.h
index 61b97b3..ad2ac33 100644
--- a/config.def.h
+++ b/config.def.h
@@ -49,8 +49,8 @@ static const KeyBinding bindings_motions[] = {
{ "b", ACTION(CURSOR_WORD_START_PREV) },
{ "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
{ "e", ACTION(CURSOR_WORD_END_NEXT) },
- { "F", ACTION(TO_LEFT) },
- { "f", ACTION(TO_RIGHT) },
+ { "F", ACTION(TO_LINE_LEFT) },
+ { "f", ACTION(TO_LINE_RIGHT) },
{ "go", ACTION(CURSOR_BYTE) },
{ "gH", ACTION(CURSOR_BYTE_LEFT) },
{ "gL", ACTION(CURSOR_BYTE_RIGHT) },
@@ -75,8 +75,8 @@ static const KeyBinding bindings_motions[] = {
{ "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
{ "n", ACTION(CURSOR_SEARCH_REPEAT_FORWARD) },
{ "N", ACTION(CURSOR_SEARCH_REPEAT_BACKWARD) },
- { "T", ACTION(TILL_LEFT) },
- { "t", ACTION(TILL_RIGHT) },
+ { "T", ACTION(TILL_LINE_LEFT) },
+ { "t", ACTION(TILL_LINE_RIGHT) },
{ "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
{ "w", ACTION(CURSOR_WORD_START_NEXT) },
{ 0 /* empty last element, array terminator */ },
diff --git a/main.c b/main.c
index a6212b2..9719640 100644
--- a/main.c
+++ b/main.c
@@ -94,7 +94,7 @@ static const char *gotoline(Vis*, const char *keys, const Arg *arg);
/* make the current action use the operator indicated by arg->i */
static const char *operator(Vis*, const char *keys, const Arg *arg);
/* blocks to read a key and performs movement indicated by arg->i which
- * should be one of VIS_MOVE_{RIGHT,LEFT}_{TO,TILL} */
+ * should be one of VIS_MOVE_{TO,TILL}_LINE_{RIGHT,LEFT}*/
static const char *movement_key(Vis*, const char *keys, const Arg *arg);
/* perform the movement as indicated by arg->i */
static const char *movement(Vis*, const char *keys, const Arg *arg);
@@ -220,10 +220,10 @@ enum {
VIS_ACTION_TOTILL_REVERSE,
VIS_ACTION_PROMPT_SEARCH_FORWARD,
VIS_ACTION_PROMPT_SEARCH_BACKWARD,
- VIS_ACTION_TILL_LEFT,
- VIS_ACTION_TILL_RIGHT,
- VIS_ACTION_TO_LEFT,
- VIS_ACTION_TO_RIGHT,
+ VIS_ACTION_TILL_LINE_LEFT,
+ VIS_ACTION_TILL_LINE_RIGHT,
+ VIS_ACTION_TO_LINE_LEFT,
+ VIS_ACTION_TO_LINE_RIGHT,
VIS_ACTION_REGISTER,
VIS_ACTION_OPERATOR_CHANGE,
VIS_ACTION_OPERATOR_DELETE,
@@ -718,25 +718,25 @@ static const KeyAction vis_action[] = {
VIS_HELP("Search backward")
prompt_show, { .s = "?" }
},
- [VIS_ACTION_TILL_LEFT] = {
- "vis-motion-till-left",
- VIS_HELP("Till after the occurrence of character to the left")
- movement_key, { .i = VIS_MOVE_LEFT_TILL }
- },
- [VIS_ACTION_TILL_RIGHT] = {
- "vis-motion-till-right",
- VIS_HELP("Till before the occurrence of character to the right")
- movement_key, { .i = VIS_MOVE_RIGHT_TILL }
- },
- [VIS_ACTION_TO_LEFT] = {
- "vis-motion-to-left",
- VIS_HELP("To the first occurrence of character to the left")
- movement_key, { .i = VIS_MOVE_LEFT_TO }
- },
- [VIS_ACTION_TO_RIGHT] = {
- "vis-motion-to-right",
- VIS_HELP("To the first occurrence of character to the right")
- movement_key, { .i = VIS_MOVE_RIGHT_TO }
+ [VIS_ACTION_TILL_LINE_LEFT] = {
+ "vis-motion-till-line-left",
+ VIS_HELP("Till after the occurrence of character to the left on the current line")
+ movement_key, { .i = VIS_MOVE_TILL_LINE_LEFT }
+ },
+ [VIS_ACTION_TILL_LINE_RIGHT] = {
+ "vis-motion-till-line-right",
+ VIS_HELP("Till before the occurrence of character to the right on the current line")
+ movement_key, { .i = VIS_MOVE_TILL_LINE_RIGHT }
+ },
+ [VIS_ACTION_TO_LINE_LEFT] = {
+ "vis-motion-to-line-left",
+ VIS_HELP("To the first occurrence of character to the left on the current line")
+ movement_key, { .i = VIS_MOVE_TO_LINE_LEFT }
+ },
+ [VIS_ACTION_TO_LINE_RIGHT] = {
+ "vis-motion-to-line-right",
+ VIS_HELP("To the first occurrence of character to the right on the current line")
+ movement_key, { .i = VIS_MOVE_TO_LINE_RIGHT }
},
[VIS_ACTION_REGISTER] = {
"vis-register",
diff --git a/vis-motions.c b/vis-motions.c
index 3702efa..9658f9f 100644
--- a/vis-motions.c
+++ b/vis-motions.c
@@ -112,7 +112,7 @@ static size_t longword_next(Vis *vis, Text *txt, size_t pos) {
VIS_MOVE_LONGWORD_END_NEXT, isspace);
}
-static size_t to(Vis *vis, Text *txt, size_t pos) {
+static size_t to_line_right(Vis *vis, Text *txt, size_t pos) {
char c;
if (pos == text_line_end(txt, pos))
return pos;
@@ -122,8 +122,8 @@ static size_t to(Vis *vis, Text *txt, size_t pos) {
return hit;
}
-static size_t till(Vis *vis, Text *txt, size_t pos) {
- size_t hit = to(vis, txt, pos+1);
+static size_t till_line_right(Vis *vis, Text *txt, size_t pos) {
+ size_t hit = to_line_right(vis, txt, pos+1);
if (pos == text_line_end(txt, pos))
return pos;
if (hit != pos)
@@ -131,14 +131,14 @@ static size_t till(Vis *vis, Text *txt, size_t pos) {
return pos;
}
-static size_t to_left(Vis *vis, Text *txt, size_t pos) {
+static size_t to_line_left(Vis *vis, Text *txt, size_t pos) {
return text_line_find_prev(txt, pos, vis->search_char);
}
-static size_t till_left(Vis *vis, Text *txt, size_t pos) {
+static size_t till_line_left(Vis *vis, Text *txt, size_t pos) {
if (pos == text_line_begin(txt, pos))
return pos;
- size_t hit = to_left(vis, txt, pos-1);
+ size_t hit = to_line_left(vis, txt, pos-1);
if (hit != pos-1)
return text_char_next(txt, hit);
return pos;
@@ -294,10 +294,10 @@ bool vis_motion(Vis *vis, enum VisMotion motion, ...) {
}
break;
}
- case VIS_MOVE_RIGHT_TO:
- case VIS_MOVE_LEFT_TO:
- case VIS_MOVE_RIGHT_TILL:
- case VIS_MOVE_LEFT_TILL:
+ case VIS_MOVE_TO_LINE_RIGHT:
+ case VIS_MOVE_TO_LINE_LEFT:
+ case VIS_MOVE_TILL_LINE_RIGHT:
+ case VIS_MOVE_TILL_LINE_LEFT:
{
const char *key = va_arg(ap, char*);
if (!key)
@@ -314,17 +314,17 @@ bool vis_motion(Vis *vis, enum VisMotion motion, ...) {
break;
case VIS_MOVE_TOTILL_REVERSE:
switch (vis->last_totill) {
- case VIS_MOVE_RIGHT_TO:
- motion = VIS_MOVE_LEFT_TO;
+ case VIS_MOVE_TO_LINE_RIGHT:
+ motion = VIS_MOVE_TO_LINE_LEFT;
break;
- case VIS_MOVE_LEFT_TO:
- motion = VIS_MOVE_RIGHT_TO;
+ case VIS_MOVE_TO_LINE_LEFT:
+ motion = VIS_MOVE_TO_LINE_RIGHT;
break;
- case VIS_MOVE_RIGHT_TILL:
- motion = VIS_MOVE_LEFT_TILL;
+ case VIS_MOVE_TILL_LINE_RIGHT:
+ motion = VIS_MOVE_TILL_LINE_LEFT;
break;
- case VIS_MOVE_LEFT_TILL:
- motion = VIS_MOVE_RIGHT_TILL;
+ case VIS_MOVE_TILL_LINE_LEFT:
+ motion = VIS_MOVE_TILL_LINE_RIGHT;
break;
default:
goto err;
@@ -515,20 +515,20 @@ const Movement vis_motions[] = {
.txt = lastline,
.type = LINEWISE|LINEWISE_INCLUSIVE|JUMP|IDEMPOTENT,
},
- [VIS_MOVE_LEFT_TO] = {
- .vis = to_left,
+ [VIS_MOVE_TO_LINE_LEFT] = {
+ .vis = to_line_left,
.type = COUNT_EXACT,
},
- [VIS_MOVE_RIGHT_TO] = {
- .vis = to,
+ [VIS_MOVE_TO_LINE_RIGHT] = {
+ .vis = to_line_right,
.type = INCLUSIVE|COUNT_EXACT,
},
- [VIS_MOVE_LEFT_TILL] = {
- .vis = till_left,
+ [VIS_MOVE_TILL_LINE_LEFT] = {
+ .vis = till_line_left,
.type = COUNT_EXACT,
},
- [VIS_MOVE_RIGHT_TILL] = {
- .vis = till,
+ [VIS_MOVE_TILL_LINE_RIGHT] = {
+ .vis = till_line_right,
.type = INCLUSIVE|COUNT_EXACT,
},
[VIS_MOVE_SEARCH_WORD_FORWARD] = {
diff --git a/vis.h b/vis.h
index c76baaf..41fe6ae 100644
--- a/vis.h
+++ b/vis.h
@@ -491,10 +491,10 @@ enum VisMotion {
VIS_MOVE_PARENTHESIS_START,
VIS_MOVE_PARENTHESIS_END,
VIS_MOVE_BRACKET_MATCH,
- VIS_MOVE_LEFT_TO,
- VIS_MOVE_RIGHT_TO,
- VIS_MOVE_LEFT_TILL,
- VIS_MOVE_RIGHT_TILL,
+ VIS_MOVE_TO_LINE_LEFT,
+ VIS_MOVE_TO_LINE_RIGHT,
+ VIS_MOVE_TILL_LINE_LEFT,
+ VIS_MOVE_TILL_LINE_RIGHT,
VIS_MOVE_FILE_BEGIN,
VIS_MOVE_FILE_END,
VIS_MOVE_SEARCH_WORD_FORWARD,