diff options
| -rw-r--r-- | config.def.h | 12 | ||||
| -rw-r--r-- | main.c | 10 | ||||
| -rw-r--r-- | vis.c | 6 | ||||
| -rw-r--r-- | vis.h | 1 |
4 files changed, 11 insertions, 18 deletions
diff --git a/config.def.h b/config.def.h index 190b1b4..1a5c3e3 100644 --- a/config.def.h +++ b/config.def.h @@ -92,6 +92,14 @@ static size_t till_left(const Arg *arg) { return text_char_next(vis->win->text, to_left(arg)); } +static size_t line(const Arg *arg) { + if (action.count == 0) + return text_size(vis->win->text); + size_t pos = text_pos_by_lineno(vis->win->text, action.count); + action.count = 0; + return pos; +} + static Operator ops[] = { [OP_DELETE] = { op_delete, false }, [OP_CHANGE] = { op_change, false }, @@ -106,6 +114,7 @@ enum { MOVE_LINE_START, MOVE_LINE_FINISH, MOVE_LINE_END, + MOVE_LINE, MOVE_CHAR_PREV, MOVE_CHAR_NEXT, MOVE_WORD_START_PREV, @@ -134,6 +143,7 @@ static Movement moves[] = { [MOVE_LINE_START] = { .txt = text_line_start, .type = LINEWISE }, [MOVE_LINE_FINISH] = { .txt = text_line_finish, .type = LINEWISE }, [MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE }, + [MOVE_LINE] = { .cmd = line, .type = LINEWISE }, [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 }, @@ -454,7 +464,7 @@ static KeyBinding vis_movements[] = { { { NONE('(') }, movement, { .i = MOVE_SENTENCE_PREV } }, { { NONE(')') }, movement, { .i = MOVE_SENTENCE_NEXT } }, { { NONE('g'), NONE('g') }, movement, { .i = MOVE_FILE_BEGIN } }, - { { NONE('G') }, movement, { .i = MOVE_FILE_END } }, + { { NONE('G') }, movement, { .i = MOVE_LINE } }, { { NONE('f') }, movement_key, { .i = MOVE_RIGHT_TO } }, { { NONE('F') }, movement_key, { .i = MOVE_LEFT_TO } }, { { NONE('t') }, movement_key, { .i = MOVE_RIGHT_TILL } }, @@ -21,8 +21,6 @@ int ESCDELAY; static Key getkey(void); static void cursor(const Arg *arg); static void call(const Arg *arg); -static void insert(const Arg *arg); -static void line(const Arg *arg); static void find_forward(const Arg *arg); static void find_backward(const Arg *arg); @@ -38,10 +36,6 @@ static void call(const Arg *arg) { arg->f(vis); } -static void line(const Arg *arg) { - vis_line_goto(vis, arg->i); -} - static void find_forward(const Arg *arg) { vis_search(vis, arg->s, 1); } @@ -50,10 +44,6 @@ static void find_backward(const Arg *arg) { vis_search(vis, arg->s, -1); } -static void insert(const Arg *arg) { - //vis_insert(vis, arg->s, strlen(arg->s)); -} - typedef struct Screen Screen; static struct Screen { int w, h; @@ -42,12 +42,6 @@ void vis_statusbar_set(Vis *vis, vis_statusbar_t statusbar) { vis->statusbar = statusbar; } -size_t vis_line_goto(Vis *vis, size_t lineno) { - size_t pos = text_pos_by_lineno(vis->win->text, lineno); - window_cursor_to(vis->win->win, pos); - return pos; -} - static void vis_search_forward(Vis *vis, Regex *regex) { VisWin *win = vis->win; int pos = window_cursor_get(win->win) + 1; @@ -175,7 +175,6 @@ bool vis_syntax_load(Vis*, Syntax *syntaxes, Color *colors); void vis_syntax_unload(Vis*); void vis_search(Vis *ed, const char *regex, int direction); -size_t vis_line_goto(Vis *vis, size_t lineno); bool vis_window_new(Vis *vis, const char *filename); void vis_window_split(Vis *ed, const char *filename); |
