diff options
| -rw-r--r-- | config.def.h | 28 | ||||
| -rw-r--r-- | text-motions.c | 8 | ||||
| -rw-r--r-- | text-motions.h | 8 | ||||
| -rw-r--r-- | text-objects.c | 26 | ||||
| -rw-r--r-- | text-objects.h | 2 | ||||
| -rw-r--r-- | vis.c | 22 |
6 files changed, 47 insertions, 47 deletions
diff --git a/config.def.h b/config.def.h index 876e4a4..6b70da1 100644 --- a/config.def.h +++ b/config.def.h @@ -93,9 +93,9 @@ static bool vis_keypress(Key *key) { static KeyBinding basic_movement[] = { { { KEY(LEFT) }, movement, { .i = MOVE_CHAR_PREV } }, - { { KEY(SLEFT) }, movement, { .i = MOVE_WORD_START_PREV } }, + { { KEY(SLEFT) }, movement, { .i = MOVE_LONGWORD_START_PREV } }, { { KEY(RIGHT) }, movement, { .i = MOVE_CHAR_NEXT } }, - { { KEY(SRIGHT) }, movement, { .i = MOVE_WORD_START_NEXT } }, + { { KEY(SRIGHT) }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, { { KEY(UP) }, movement, { .i = MOVE_SCREEN_LINE_UP } }, { { KEY(DOWN) }, movement, { .i = MOVE_SCREEN_LINE_DOWN } }, { { KEY(PPAGE) }, wscroll, { .i = -PAGE } }, @@ -120,13 +120,13 @@ static KeyBinding vis_movements[] = { { { NONE('g'), NONE('_') }, movement, { .i = MOVE_LINE_FINISH } }, { { NONE('$') }, movement, { .i = MOVE_LINE_LASTCHAR } }, { { NONE('%') }, movement, { .i = MOVE_BRACKET_MATCH } }, - { { NONE('b') }, movement, { .i = MOVE_WORD_START_PREV } }, - { { NONE('B') }, movement, { .i = MOVE_WORD_START_PREV } }, - { { NONE('w') }, movement, { .i = MOVE_WORD_START_NEXT } }, - { { NONE('W') }, movement, { .i = MOVE_WORD_START_NEXT } }, - { { NONE('g'), NONE('e') }, movement, { .i = MOVE_WORD_END_PREV } }, - { { NONE('e') }, movement, { .i = MOVE_WORD_END_NEXT } }, - { { NONE('E') }, movement, { .i = MOVE_WORD_END_NEXT } }, + { { NONE('b') }, movement, { .i = MOVE_LONGWORD_START_PREV } }, + { { NONE('B') }, movement, { .i = MOVE_LONGWORD_START_PREV } }, + { { NONE('w') }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, + { { NONE('W') }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, + { { NONE('g'), NONE('e') }, movement, { .i = MOVE_LONGWORD_END_PREV } }, + { { NONE('e') }, movement, { .i = MOVE_LONGWORD_END_NEXT } }, + { { NONE('E') }, movement, { .i = MOVE_LONGWORD_END_NEXT } }, { { NONE('{') }, movement, { .i = MOVE_PARAGRAPH_PREV } }, { { NONE('}') }, movement, { .i = MOVE_PARAGRAPH_NEXT } }, { { NONE('(') }, movement, { .i = MOVE_SENTENCE_PREV } }, @@ -153,7 +153,7 @@ static KeyBinding vis_movements[] = { }; static KeyBinding vis_textobjs[] = { - { { NONE('a'), NONE('w') }, textobj, { .i = TEXT_OBJ_WORD } }, + { { NONE('a'), NONE('w') }, textobj, { .i = TEXT_OBJ_LONGWORD } }, { { NONE('a'), NONE('s') }, textobj, { .i = TEXT_OBJ_SENTENCE } }, { { NONE('a'), NONE('p') }, textobj, { .i = TEXT_OBJ_PARAGRAPH } }, { { NONE('a'), NONE('[') }, textobj, { .i = TEXT_OBJ_OUTER_SQUARE_BRACKET } }, @@ -173,7 +173,7 @@ static KeyBinding vis_textobjs[] = { }; static KeyBinding vis_inner_textobjs[] = { - { { NONE('i'), NONE('w') }, textobj, { .i = TEXT_OBJ_WORD } }, + { { NONE('i'), NONE('w') }, textobj, { .i = TEXT_OBJ_LONGWORD } }, { { NONE('i'), NONE('s') }, textobj, { .i = TEXT_OBJ_SENTENCE } }, { { NONE('i'), NONE('p') }, textobj, { .i = TEXT_OBJ_PARAGRAPH } }, { { NONE('i'), NONE('[') }, textobj, { .i = TEXT_OBJ_INNER_SQUARE_BRACKET } }, @@ -450,7 +450,7 @@ static KeyBinding vis_mode_readline[] = { { { CONTROL('c') }, switchmode, { .i = VIS_MODE_NORMAL } }, BACKSPACE( call, f, editor_backspace_key ), { { CONTROL('D') }, call, { .f = editor_delete_key } }, - { { CONTROL('W') }, delete, { .i = MOVE_WORD_START_PREV } }, + { { CONTROL('W') }, delete, { .i = MOVE_LONGWORD_START_PREV } }, { { CONTROL('U') }, delete, { .i = MOVE_LINE_BEGIN } }, { /* empty last element, array terminator */ }, }; @@ -742,9 +742,9 @@ static KeyBinding nano_keys[] = { { { KEY(F(8)) }, wscroll, { .i = +PAGE } }, #if 0 // CONTROL(' ') == 0 which signals the end of array - { { CONTROL(' ') }, movement, { .i = MOVE_WORD_START_NEXT } }, + { { CONTROL(' ') }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, #endif - { { META(' ') }, movement, { .i = MOVE_WORD_START_PREV } }, + { { META(' ') }, movement, { .i = MOVE_LONGWORD_START_PREV } }, { { CONTROL('A') }, movement, { .i = MOVE_LINE_START } }, { { CONTROL('E') }, movement, { .i = MOVE_LINE_END } }, { { META(']') }, movement, { .i = MOVE_BRACKET_MATCH } }, diff --git a/text-motions.c b/text-motions.c index 85deab8..bee4a34 100644 --- a/text-motions.c +++ b/text-motions.c @@ -186,19 +186,19 @@ size_t text_word_boundry_end_prev(Text *txt, size_t pos, int (*isboundry)(int)) return it.pos; } -size_t text_word_end_next(Text *txt, size_t pos) { +size_t text_longword_end_next(Text *txt, size_t pos) { return text_word_boundry_end_next(txt, pos, isspace); } -size_t text_word_end_prev(Text *txt, size_t pos) { +size_t text_longword_end_prev(Text *txt, size_t pos) { return text_word_boundry_end_prev(txt, pos, isspace); } -size_t text_word_start_next(Text *txt, size_t pos) { +size_t text_longword_start_next(Text *txt, size_t pos) { return text_word_boundry_start_next(txt, pos, isspace); } -size_t text_word_start_prev(Text *txt, size_t pos) { +size_t text_longword_start_prev(Text *txt, size_t pos) { return text_word_boundry_start_prev(txt, pos, isspace); } diff --git a/text-motions.h b/text-motions.h index 4afa56b..e182e2e 100644 --- a/text-motions.h +++ b/text-motions.h @@ -39,10 +39,10 @@ size_t text_line_next(Text*, size_t pos); * space. TODO?: An empty line is also considered to be a word. * This is equivalant to a WORD in vim terminology. */ -size_t text_word_end_next(Text*, size_t pos); -size_t text_word_end_prev(Text*, size_t pos); -size_t text_word_start_next(Text*, size_t pos); -size_t text_word_start_prev(Text*, size_t pos); +size_t text_longword_end_next(Text*, size_t pos); +size_t text_longword_end_prev(Text*, size_t pos); +size_t text_longword_start_next(Text*, size_t pos); +size_t text_longword_start_prev(Text*, size_t pos); /* * These are variants of the above with the additional possibility to implement * a custom word detection logic. Can be used to implment the equivalent of a diff --git a/text-objects.c b/text-objects.c index 0c819ac..c37c233 100644 --- a/text-objects.c +++ b/text-objects.c @@ -29,29 +29,29 @@ Filerange text_object_word(Text *txt, size_t pos) { text_iterator_byte_next(&it, &next); if (isspace(c)) { /* middle of two words, include leading white space */ - r.start = text_char_next(txt, text_word_end_prev(txt, pos)); - r.end = text_char_next(txt, text_word_end_next(txt, pos)); + r.start = text_char_next(txt, text_longword_end_prev(txt, pos)); + r.end = text_char_next(txt, text_longword_end_next(txt, pos)); } else if (isspace(prev) && isspace(next)) { /* on a single character */ r.start = pos; - r.end = text_word_start_next(txt, pos); + r.end = text_longword_start_next(txt, pos); } else if (isspace(prev)) { /* at start of a word */ r.start = pos; - r.end = text_word_start_next(txt, text_word_end_next(txt, pos)); + r.end = text_longword_start_next(txt, text_longword_end_next(txt, pos)); } else if (isspace(next)) { /* at end of a word */ - r.start = text_word_start_prev(txt, pos); - r.end = text_word_start_next(txt, pos); + r.start = text_longword_start_prev(txt, pos); + r.end = text_longword_start_next(txt, pos); } else { /* in the middle of a word */ - r.start = text_word_start_prev(txt, pos); - r.end = text_word_start_next(txt, text_word_end_next(txt, pos)); + r.start = text_longword_start_prev(txt, pos); + r.end = text_longword_start_next(txt, text_longword_end_next(txt, pos)); } return r; } -Filerange text_object_word_raw(Text *txt, size_t pos) { +Filerange text_object_longword_raw(Text *txt, size_t pos) { char c, prev = '0', next = '0'; Filerange r = text_range_empty(); Iterator it = text_iterator_get(txt, pos); @@ -69,15 +69,15 @@ Filerange text_object_word_raw(Text *txt, size_t pos) { } else if (isspace(prev)) { /* at start of a word */ r.start = pos; - r.end = text_char_next(txt, text_word_end_next(txt, pos)); + r.end = text_char_next(txt, text_longword_end_next(txt, pos)); } else if (isspace(next)) { /* at end of a word */ - r.start = text_word_start_prev(txt, pos); + r.start = text_longword_start_prev(txt, pos); r.end = text_char_next(txt, pos); } else { /* in the middle of a word */ - r.start = text_word_start_prev(txt, pos); - r.end = text_char_next(txt, text_word_end_next(txt, pos)); + r.start = text_longword_start_prev(txt, pos); + r.end = text_char_next(txt, text_longword_end_next(txt, pos)); } return r; diff --git a/text-objects.h b/text-objects.h index 105860a..2a37090 100644 --- a/text-objects.h +++ b/text-objects.h @@ -15,7 +15,7 @@ Filerange text_object_word(Text*, size_t pos); /* word which happens to be at pos, _not_ including any white spaces. if pos * is not part of a word, an empty range is returned */ -Filerange text_object_word_raw(Text*, size_t pos); +Filerange text_object_longword_raw(Text*, size_t pos); Filerange text_object_line(Text*, size_t pos); Filerange text_object_sentence(Text*, size_t pos); Filerange text_object_paragraph(Text*, size_t pos); @@ -203,10 +203,10 @@ enum { MOVE_COLUMN, MOVE_CHAR_PREV, MOVE_CHAR_NEXT, - MOVE_WORD_START_PREV, - MOVE_WORD_START_NEXT, - MOVE_WORD_END_PREV, - MOVE_WORD_END_NEXT, + MOVE_LONGWORD_START_PREV, + MOVE_LONGWORD_START_NEXT, + MOVE_LONGWORD_END_PREV, + MOVE_LONGWORD_END_NEXT, MOVE_SENTENCE_PREV, MOVE_SENTENCE_NEXT, MOVE_PARAGRAPH_PREV, @@ -274,10 +274,10 @@ static Movement moves[] = { [MOVE_COLUMN] = { .cmd = 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 }, - [MOVE_WORD_START_NEXT] = { .txt = text_word_start_next, .type = CHARWISE }, - [MOVE_WORD_END_PREV] = { .txt = text_word_end_prev, .type = CHARWISE|INCLUSIVE }, - [MOVE_WORD_END_NEXT] = { .txt = text_word_end_next, .type = CHARWISE|INCLUSIVE }, + [MOVE_LONGWORD_START_PREV] = { .txt = text_longword_start_prev, .type = CHARWISE }, + [MOVE_LONGWORD_START_NEXT] = { .txt = text_longword_start_next, .type = CHARWISE }, + [MOVE_LONGWORD_END_PREV] = { .txt = text_longword_end_prev, .type = CHARWISE|INCLUSIVE }, + [MOVE_LONGWORD_END_NEXT] = { .txt = text_longword_end_next, .type = CHARWISE|INCLUSIVE }, [MOVE_SENTENCE_PREV] = { .txt = text_sentence_prev, .type = LINEWISE }, [MOVE_SENTENCE_NEXT] = { .txt = text_sentence_next, .type = LINEWISE }, [MOVE_PARAGRAPH_PREV] = { .txt = text_paragraph_prev, .type = LINEWISE }, @@ -301,7 +301,7 @@ static Movement moves[] = { /* these can be passed as int argument to textobj(&(const Arg){ .i = TEXT_OBJ_* }) */ enum { - TEXT_OBJ_WORD, + TEXT_OBJ_LONGWORD, TEXT_OBJ_LINE_UP, TEXT_OBJ_LINE_DOWN, TEXT_OBJ_SENTENCE, @@ -323,7 +323,7 @@ enum { }; static TextObject textobjs[] = { - [TEXT_OBJ_WORD] = { text_object_word }, + [TEXT_OBJ_LONGWORD] = { text_object_word }, [TEXT_OBJ_LINE_UP] = { text_object_line }, [TEXT_OBJ_LINE_DOWN] = { text_object_line }, [TEXT_OBJ_SENTENCE] = { text_object_sentence }, @@ -604,7 +604,7 @@ static size_t search_word(const Arg *arg) { size_t pos = window_cursor_get(vis->win->win); /* TODO: to make this useful the other variant breaking on special symbols * should be used here */ - Filerange word = text_object_word_raw(vis->win->text, pos); + Filerange word = text_object_longword_raw(vis->win->text, pos); if (!text_range_valid(&word)) return pos; size_t len = word.end - word.start; |
