Skip to content

Commit

Permalink
add cursor_select_by "all"
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Mar 14, 2020
1 parent dd040b4 commit 2d11ddb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ int cmd_anchor_by(cmd_context_t *ctx) {
MLE_MULTI_CURSOR_CODE(ctx->cursor,
cursor_select_by(cursor, ctx->static_param, 1);
);
bview_rectify_viewport(ctx->bview);
return MLE_OK;
}

Expand Down
4 changes: 4 additions & 0 deletions cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ int cursor_select_by(cursor_t *cursor, const char *strat, int use_srules) {
mark_move_bol(cursor->anchor);
} else if (strcmp(strat, "string") == 0) {
return cursor_select_by_string(cursor, use_srules);
} else if (strcmp(strat, "all") == 0) {
mark_move_beginning(cursor->mark);
cursor_toggle_anchor(cursor, use_srules);
mark_move_end(cursor->mark);
} else {
MLE_RETURN_ERR(cursor->bview->editor, "Unrecognized cursor_select_by strat '%s'", strat);
}
Expand Down
3 changes: 3 additions & 0 deletions editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,20 +1535,23 @@ static void _editor_init_kmaps(editor_t *editor) {
MLE_KBINDING_DEF_EX("cmd_copy_by", "C-c a", "bol"),
MLE_KBINDING_DEF_EX("cmd_copy_by", "C-c e", "eol"),
MLE_KBINDING_DEF_EX("cmd_copy_by", "C-c c", "string"),
MLE_KBINDING_DEF_EX("cmd_copy_by", "C-c q", "all"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d d", "bracket"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d w", "word"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d s", "word_back"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d f", "word_forward"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d a", "bol"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d e", "eol"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d c", "string"),
MLE_KBINDING_DEF_EX("cmd_cut_by", "C-d q", "all"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 d", "bracket"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 w", "word"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 s", "word_back"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 f", "word_forward"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 a", "bol"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 e", "eol"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 c", "string"),
MLE_KBINDING_DEF_EX("cmd_anchor_by", "C-2 q", "all"),
MLE_KBINDING_DEF("cmd_delete_word_before", "C-w"),
MLE_KBINDING_DEF("cmd_delete_word_after", "M-d"),
MLE_KBINDING_DEF("cmd_toggle_anchor", "M-a"),
Expand Down
16 changes: 12 additions & 4 deletions tests/func/test_cursor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

macro='b e g i n space { enter l i n e 1 enter l i n e 2 enter } enter C-f l i n e 1 enter C-2 d'
declare -A expected
expected[cursor_mark_line]='.mark.line_index=0$'
expected[cursor_mark_col]='.mark.col=7$'
expected[cursor_anchor_line]='.anchor.line_index=3$'
expected[cursor_anchor_col]='.anchor.col=0$'
expected[sel_bracket_mark_line]='.mark.line_index=0$'
expected[sel_bracket_mark_col]='.mark.col=7$'
expected[sel_bracket_anchor_line]='.anchor.line_index=3$'
expected[sel_bracket_anchor_col]='.anchor.col=0$'
source 'test.sh'

macro='a b c enter l i n e 2 enter l i n e 3 C-2 q'
declare -A expected
expected[sel_all_mark_line]='.mark.line_index=2$'
expected[sel_all_mark_col]='.mark.col=5$'
expected[sel_all_anchor_line]='.anchor.line_index=0$'
expected[sel_all_anchor_col]='.anchor.col=0$'
source 'test.sh'

0 comments on commit 2d11ddb

Please sign in to comment.