[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32154] trunk/blender/source/blender/ editors/space_console: console now stores selection internally with 0 index starting at the end of the line .

Campbell Barton ideasman42 at gmail.com
Mon Sep 27 16:01:16 CEST 2010


Revision: 32154
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32154
Author:   campbellbarton
Date:     2010-09-27 16:01:16 +0200 (Mon, 27 Sep 2010)

Log Message:
-----------
console now stores selection internally with 0 index starting at the end of the line. makes internal logic much less confusing. no functional changes.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_console/console_draw.c
    trunk/blender/source/blender/editors/space_console/console_ops.c

Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c	2010-09-27 12:24:12 UTC (rev 32153)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c	2010-09-27 14:01:16 UTC (rev 32154)
@@ -126,7 +126,7 @@
 	int ymin, ymax;
 	int *xy; // [2]
 	int *sel; // [2]
-	int *pos_pick;
+	int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. 
 	int *mval; // [2]
 	int draw;
 } ConsoleDrawContext;
@@ -138,6 +138,7 @@
 		int end = MIN2(sel[1], str_len);
 
 		/* highly confusing but draws correctly */
+#if 0
 		if(sel[0] < 0 || sel[1] > str_len) {
 			if(sel[0] > 0) {
 				end= sta;
@@ -148,6 +149,7 @@
 				end= str_len;
 			}
 		}
+#endif
 		/* end confusement */
 
 		{
@@ -157,7 +159,7 @@
 			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 			glColor4ub(255, 255, 255, 96);
 		}
-		glRecti(xy[0]+(cwidth*sta), xy[1]-2 + lheight, xy[0]+(cwidth*end), xy[1]-2);
+		glRecti(xy[0]+(cwidth*(str_len - sta)), xy[1]-2 + lheight, xy[0]+(cwidth*(str_len - end)), xy[1]-2);
 		{
 			glDisable(GL_POLYGON_STIPPLE);
 			glDisable( GL_BLEND );
@@ -184,7 +186,8 @@
 			if((cdc->mval[1] != INT_MAX) && cdc->xy[1] <= cdc->mval[1]) {
 				if((cdc->xy[1]+cdc->lheight >= cdc->mval[1])) {
 					int ofs = (int)floor(((float)cdc->mval[0] / (float)cdc->cwidth));
-					*cdc->pos_pick += MIN2(ofs, str_len);
+					CLAMP(ofs, 0, str_len);
+					*cdc->pos_pick += str_len - ofs;
 				} else
 					*cdc->pos_pick += str_len + 1;
 			}
@@ -324,7 +327,7 @@
 
 	if(sc->type==CONSOLE_TYPE_PYTHON) {
 		int prompt_len;
-
+		
 		if(sc->sel_start != sc->sel_end) {
 			sel[0]= sc->sel_start;
 			sel[1]= sc->sel_end;

Modified: trunk/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_ops.c	2010-09-27 12:24:12 UTC (rev 32153)
+++ trunk/blender/source/blender/editors/space_console/console_ops.c	2010-09-27 14:01:16 UTC (rev 32154)
@@ -695,30 +695,10 @@
 	sel[1]= offset - sc->sel_start;
 
 	for(cl= sc->scrollback.first; cl; cl= cl->next) {
-
-		int sta= MAX2(0, sel[0]);
-		int end= MIN2(cl->len, sel[1]);
-
 		if(sel[0] <= cl->len && sel[1] >= 0) {
-			int str_len= cl->len;
+			int sta= MAX2(sel[0], 0);
+			int end= MIN2(sel[1], cl->len);
 
-			/* highly confusing but draws correctly */
-			if(sel[0] < 0 || sel[1] > str_len) {
-				if(sel[0] > 0) {
-					end= sta;
-					sta= 0;
-				}
-				if (sel[1] <= str_len) {
-					sta= end;
-					end= str_len;
-				}
-			}
-			/* end confusement */
-
-			SWAP(int, sta, end);
-			end= cl->len - end;
-			sta= cl->len - sta;
-
 			if(BLI_dynstr_get_len(buf_dyn))
 				BLI_dynstr_append(buf_dyn, "\n");
 





More information about the Bf-blender-cvs mailing list