diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-04-21 11:31:35 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-04-21 11:31:35 +0200 |
| commit | 5ccaa5d32524f18636fca6f194cfbfc91ad5c1c3 (patch) | |
| tree | ca2160795f3f19adf1aa4e1dd76274fd697209a6 | |
| parent | d941d9cbc8891c745c11edfd6211c3bb69626991 (diff) | |
| download | vis-5ccaa5d32524f18636fca6f194cfbfc91ad5c1c3.tar.gz vis-5ccaa5d32524f18636fca6f194cfbfc91ad5c1c3.tar.xz | |
Cleanup implmentation of line and column movements
| -rw-r--r-- | vis.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -155,9 +155,9 @@ static size_t to_left(const Arg *arg); /* goto to position after next occurence of action.key to the left */ static size_t till_left(const Arg *arg); /* goto line number action.count */ -static size_t line(const Arg *arg); +static size_t line(Text *txt, size_t pos); /* goto to byte action.count on current line */ -static size_t column(const Arg *arg); +static size_t column(Text *txt, size_t pos); /* goto the action.count-th line from top of the focused window */ static size_t window_lines_top(const Arg *arg); /* goto the start of middle line of the focused window */ @@ -180,8 +180,8 @@ static Movement moves[] = { [MOVE_LINE_LASTCHAR] = { .txt = text_line_lastchar, .type = LINEWISE|INCLUSIVE }, [MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE }, [MOVE_LINE_NEXT] = { .txt = text_line_next, .type = LINEWISE }, - [MOVE_LINE] = { .cmd = line, .type = LINEWISE|IDEMPOTENT|JUMP}, - [MOVE_COLUMN] = { .cmd = column, .type = CHARWISE|IDEMPOTENT}, + [MOVE_LINE] = { .txt = line, .type = LINEWISE|IDEMPOTENT|JUMP}, + [MOVE_COLUMN] = { .txt = column, .type = CHARWISE|IDEMPOTENT}, [MOVE_CHAR_PREV] = { .win = window_char_prev }, [MOVE_CHAR_NEXT] = { .win = window_char_next }, [MOVE_WORD_START_PREV] = { .txt = text_word_start_prev, .type = CHARWISE }, @@ -690,13 +690,12 @@ static size_t till_left(const Arg *arg) { return pos; } -static size_t line(const Arg *arg) { - return text_pos_by_lineno(vis->win->text->data, vis->action.count); +static size_t line(Text *txt, size_t pos) { + return text_pos_by_lineno(txt, vis->action.count); } -static size_t column(const Arg *arg) { - size_t pos = window_cursor_get(vis->win->win); - return text_line_offset(vis->win->text->data, pos, vis->action.count); +static size_t column(Text *txt, size_t pos) { + return text_line_offset(txt, pos, vis->action.count); } static size_t window_lines_top(const Arg *arg) { |
