diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_text.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 4f77e4f5a23..1e79eaa8431 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -85,6 +85,7 @@ void txt_delete_char (struct Text *text); void txt_delete_word (struct Text *text); void txt_delete_selected (struct Text *text); void txt_sel_all (struct Text *text); +void txt_sel_clear (struct Text *text); void txt_sel_line (struct Text *text); char *txt_sel_to_buf (struct Text *text); void txt_insert_buf (struct Text *text, const char *in_buffer); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 47b615c2573..4cd85fb342e 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1286,6 +1286,19 @@ void txt_sel_all(Text *text) text->selc = text->sell->len; } +/** + * Reverse of #txt_pop_sel + * Clears the selection and ensures the cursor is located + * at the selection (where the cursor is visually while editing). + */ +void txt_sel_clear(Text *text) +{ + if (text->sell) { + text->curl = text->sell; + text->curc = text->selc; + } +} + void txt_sel_line(Text *text) { if (!text) return; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index fcd6fb3c179..2e3d8d056e8 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1825,11 +1825,17 @@ static int text_move_cursor(bContext *C, int type, bool select) switch (type) { case LINE_BEGIN: + if (!select) { + txt_sel_clear(text); + } if (st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select); else txt_move_bol(text, select); break; case LINE_END: + if (!select) { + txt_sel_clear(text); + } if (st && st->wordwrap && ar) txt_wrap_move_eol(st, ar, select); else txt_move_eol(text, select); break; |