Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-02 04:47:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-02 04:47:27 +0400
commit26cbf331a858db0ac49e2de8b60ae7710a8c7c66 (patch)
tree474cf2531643215c547dd740c40f1839b8517dd1 /source/blender/blenkernel/intern/text.c
parent75a2b5ee3574a5c7654270cf5d55cee96251933d (diff)
text editor cursor motion (left/right arrows) with selected text typically jumps to either side of the selection previously the cursor would move and loose the selection too.
text button fields already did this.
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r--source/blender/blenkernel/intern/text.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index f0c01e25598..750f328e7e7 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1151,17 +1151,26 @@ void txt_pop_sel(Text *text)
text->selc = text->curc;
}
-void txt_order_cursors(Text *text)
+void txt_order_cursors(Text *text, const bool reverse)
{
if (!text) return;
if (!text->curl) return;
if (!text->sell) return;
- /* Flip so text->curl is before text->sell */
- if ((txt_get_span(text->curl, text->sell) < 0) ||
- (text->curl == text->sell && text->curc > text->selc))
- {
- txt_curs_swap(text);
+ /* Flip so text->curl is before/after text->sell */
+ if (reverse == false) {
+ if ((txt_get_span(text->curl, text->sell) < 0) ||
+ (text->curl == text->sell && text->curc > text->selc))
+ {
+ txt_curs_swap(text);
+ }
+ }
+ else {
+ if ((txt_get_span(text->curl, text->sell) > 0) ||
+ (text->curl == text->sell && text->curc < text->selc))
+ {
+ txt_curs_swap(text);
+ }
}
}
@@ -1181,7 +1190,7 @@ static void txt_delete_sel(Text *text)
if (!txt_has_sel(text)) return;
- txt_order_cursors(text);
+ txt_order_cursors(text, false);
if (!undoing) {
buf = txt_sel_to_buf(text);
@@ -1305,7 +1314,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
if (!text || !text->curl || !text->sell) return 0;
- txt_order_cursors(text);
+ txt_order_cursors(text, false);
tl = startl = text->sell;
@@ -2833,7 +2842,7 @@ void txt_move_lines(struct Text *text, const int direction)
if (!text || !text->curl || !text->sell) return;
- txt_order_cursors(text);
+ txt_order_cursors(text, false);
line_other = (direction == TXT_MOVE_LINE_DOWN) ? text->sell->next : text->curl->prev;