summaryrefslogtreecommitdiff
path: root/vis-motions.c
diff options
context:
space:
mode:
Diffstat (limited to 'vis-motions.c')
-rw-r--r--vis-motions.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/vis-motions.c b/vis-motions.c
index 1e9d9c5..c6fcc76 100644
--- a/vis-motions.c
+++ b/vis-motions.c
@@ -227,6 +227,18 @@ static size_t byte(Vis *vis, Text *txt, size_t pos) {
return pos <= max ? pos : max;
}
+static size_t byte_left(Vis *vis, Text *txt, size_t pos) {
+ size_t off = vis_count_get_default(vis, 1);
+ return off <= pos ? pos-off : 0;
+}
+
+static size_t byte_right(Vis *vis, Text *txt, size_t pos) {
+ size_t off = vis_count_get_default(vis, 1);
+ size_t new = pos + off;
+ size_t max = text_size(txt);
+ return new <= max && new > pos ? new : max;
+}
+
void vis_motion_type(Vis *vis, enum VisMotionType type) {
vis->action.type = type;
}
@@ -587,4 +599,12 @@ const Movement vis_motions[] = {
.vis = byte,
.type = IDEMPOTENT,
},
+ [VIS_MOVE_BYTE_LEFT] = {
+ .vis = byte_left,
+ .type = IDEMPOTENT,
+ },
+ [VIS_MOVE_BYTE_RIGHT] = {
+ .vis = byte_right,
+ .type = IDEMPOTENT,
+ },
};