diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-21 12:25:58 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-21 12:54:31 +0100 |
| commit | 559ab349a05d5201b666eddb22d921c40b131bd5 (patch) | |
| tree | 107c95f6ddc10bec2837ed452aa97410a572b9cc /vis-motions.c | |
| parent | 0109dfc0d4e65751571a86aa91ae3c9947182ba0 (diff) | |
| download | vis-559ab349a05d5201b666eddb22d921c40b131bd5.tar.gz vis-559ab349a05d5201b666eddb22d921c40b131bd5.tar.xz | |
vis: implement `go` to move to absolute byte position
Diffstat (limited to 'vis-motions.c')
| -rw-r--r-- | vis-motions.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vis-motions.c b/vis-motions.c index a9c354c..1e9d9c5 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -221,6 +221,12 @@ static size_t percent(Vis *vis, Text *txt, size_t pos) { return text_size(txt) * ratio / 100; } +static size_t byte(Vis *vis, Text *txt, size_t pos) { + pos = vis_count_get_default(vis, 0); + size_t max = text_size(txt); + return pos <= max ? pos : max; +} + void vis_motion_type(Vis *vis, enum VisMotionType type) { vis->action.type = type; } @@ -577,4 +583,8 @@ const Movement vis_motions[] = { .vis = percent, .type = IDEMPOTENT, }, + [VIS_MOVE_BYTE] = { + .vis = byte, + .type = IDEMPOTENT, + }, }; |
