[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59724] trunk/blender/source/blender: 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 .

Campbell Barton ideasman42 at gmail.com
Mon Sep 2 02:47:28 CEST 2013


Revision: 59724
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59724
Author:   campbellbarton
Date:     2013-09-02 00:47:27 +0000 (Mon, 02 Sep 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_text.h
    trunk/blender/source/blender/blenkernel/intern/text.c
    trunk/blender/source/blender/editors/space_text/text_ops.c

Modified: trunk/blender/source/blender/blenkernel/BKE_text.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_text.h	2013-09-01 22:47:44 UTC (rev 59723)
+++ trunk/blender/source/blender/blenkernel/BKE_text.h	2013-09-02 00:47:27 UTC (rev 59724)
@@ -58,7 +58,7 @@
 
 char   *txt_to_buf			(struct Text *text);
 void	txt_clean_text		(struct Text *text);
-void	txt_order_cursors	(struct Text *text);
+void	txt_order_cursors	(struct Text *text, const bool reverse);
 int		txt_find_string		(struct Text *text, const char *findstr, int wrap, int match_case);
 int		txt_has_sel			(struct Text *text);
 int		txt_get_span		(struct TextLine *from, struct TextLine *to);

Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c	2013-09-01 22:47:44 UTC (rev 59723)
+++ trunk/blender/source/blender/blenkernel/intern/text.c	2013-09-02 00:47:27 UTC (rev 59724)
@@ -1151,18 +1151,27 @@
 	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);
+		}
+	}
 }
 
 int txt_has_sel(Text *text)
@@ -1181,7 +1190,7 @@
 
 	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 @@
 
 	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 @@
 
 	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;
 	

Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c	2013-09-01 22:47:44 UTC (rev 59723)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c	2013-09-02 00:47:27 UTC (rev 59724)
@@ -949,7 +949,7 @@
 	text_drawcache_tag_update(CTX_wm_space_text(C), 0);
 
 	if (txt_has_sel(text)) {
-		txt_order_cursors(text);
+		txt_order_cursors(text, false);
 		txt_indent(text);
 	}
 	else
@@ -983,7 +983,7 @@
 
 	text_drawcache_tag_update(CTX_wm_space_text(C), 0);
 
-	txt_order_cursors(text);
+	txt_order_cursors(text, false);
 	txt_unindent(text);
 
 	text_update_edited(text);
@@ -1063,7 +1063,7 @@
 	if (txt_has_sel(text)) {
 		text_drawcache_tag_update(CTX_wm_space_text(C), 0);
 
-		txt_order_cursors(text);
+		txt_order_cursors(text, false);
 		txt_comment(text);
 		text_update_edited(text);
 
@@ -1096,7 +1096,7 @@
 	if (txt_has_sel(text)) {
 		text_drawcache_tag_update(CTX_wm_space_text(C), 0);
 
-		txt_order_cursors(text);
+		txt_order_cursors(text, false);
 		txt_uncomment(text);
 		text_update_edited(text);
 
@@ -1861,11 +1861,23 @@
 			break;
 
 		case PREV_CHAR:
-			txt_move_left(text, select);
+			if (txt_has_sel(text)) {
+				txt_order_cursors(text, false);
+				txt_pop_sel(text);
+			}
+			else {
+				txt_move_left(text, select);
+			}
 			break;
 
 		case NEXT_CHAR:
-			txt_move_right(text, select);
+			if (txt_has_sel(text)) {
+				txt_order_cursors(text, true);
+				txt_pop_sel(text);
+			}
+			else {
+				txt_move_right(text, select);
+			}
 			break;
 
 		case PREV_LINE:




More information about the Bf-blender-cvs mailing list