diff --git a/cmd.c b/cmd.c index d646911..274d121 100644 --- a/cmd.c +++ b/cmd.c @@ -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; } diff --git a/cursor.c b/cursor.c index 659580e..03a0741 100644 --- a/cursor.c +++ b/cursor.c @@ -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); } diff --git a/editor.c b/editor.c index a0656fc..a540aa1 100644 --- a/editor.c +++ b/editor.c @@ -1535,6 +1535,7 @@ 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"), @@ -1542,6 +1543,7 @@ static void _editor_init_kmaps(editor_t *editor) { 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"), @@ -1549,6 +1551,7 @@ static void _editor_init_kmaps(editor_t *editor) { 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"), diff --git a/tests/func/test_cursor.sh b/tests/func/test_cursor.sh index ce812f2..1b2c425 100755 --- a/tests/func/test_cursor.sh +++ b/tests/func/test_cursor.sh @@ -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'