[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52990] trunk/blender/source/blender/ editors: code cleanup: minor edits to the console.

Campbell Barton ideasman42 at gmail.com
Fri Dec 14 06:28:01 CET 2012


Revision: 52990
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52990
Author:   campbellbarton
Date:     2012-12-14 05:27:53 +0000 (Fri, 14 Dec 2012)
Log Message:
-----------
code cleanup: minor edits to the console.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_console/console_draw.c
    trunk/blender/source/blender/editors/space_console/console_intern.h
    trunk/blender/source/blender/editors/space_info/textview.c
    trunk/blender/source/blender/editors/space_info/textview.h

Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c	2012-12-14 04:57:26 UTC (rev 52989)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c	2012-12-14 05:27:53 UTC (rev 52990)
@@ -196,7 +196,8 @@
 }
 
 
-static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick)
+static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, int draw,
+                                           int mval[2], void **mouse_pick, int *pos_pick)
 {
 	ConsoleLine cl_dummy = {NULL};
 	int ret = 0;
@@ -243,7 +244,7 @@
 	return console_textview_main__internal(sc, ar, 0,  mval, NULL, NULL);
 }
 
-int console_char_pick(struct SpaceConsole *sc, ARegion *ar, int mval[2])
+int console_char_pick(struct SpaceConsole *sc, ARegion *ar, const int mval[2])
 {
 	int pos_pick = 0;
 	void *mouse_pick = NULL;

Modified: trunk/blender/source/blender/editors/space_console/console_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_intern.h	2012-12-14 04:57:26 UTC (rev 52989)
+++ trunk/blender/source/blender/editors/space_console/console_intern.h	2012-12-14 05:27:53 UTC (rev 52990)
@@ -37,7 +37,7 @@
 /* console_draw.c */
 void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar);
 int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar); /* needed to calculate the scrollbar */
-int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2]);
+int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, const int mval[2]);
 
 void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
 void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy);

Modified: trunk/blender/source/blender/editors/space_info/textview.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.c	2012-12-14 04:57:26 UTC (rev 52989)
+++ trunk/blender/source/blender/editors/space_info/textview.c	2012-12-14 05:27:53 UTC (rev 52990)
@@ -62,8 +62,14 @@
 	int draw;
 } ConsoleDrawContext;
 
-static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight)
+BLI_INLINE void console_step_sel(ConsoleDrawContext *cdc, const int step)
 {
+	cdc->sel[0] += step;
+	cdc->sel[1] += step;
+}
+
+static void console_draw_sel(const int sel[2], const int xy[2], const int str_len_draw, int cwidth, int lheight)
+{
 	if (sel[0] <= str_len_draw && sel[1] >= 0) {
 		int sta = max_ii(sel[0], 0);
 		int end = min_ii(sel[1], str_len_draw);
@@ -85,9 +91,9 @@
 /* return 0 if the last line is off the screen
  * should be able to use this for any string type */
 
-static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str_len, unsigned char *fg, unsigned char *bg)
+static int console_draw_string(ConsoleDrawContext *cdc, const char *str, const int str_len,
+                               const unsigned char *fg, const unsigned char *bg)
 {
-#define STEP_SEL(value) cdc->sel[0] += (value); cdc->sel[1] += (value)
 	int rct_ofs = cdc->lheight / 4;
 	int tot_lines = (str_len / cdc->console_width) + 1; /* total number of lines for wrapping */
 	int y_next = (str_len > cdc->console_width) ? cdc->xy[1] + cdc->lheight * tot_lines : cdc->xy[1] + cdc->lheight;
@@ -121,7 +127,7 @@
 
 		/* adjust selection even if not drawing */
 		if (cdc->sel[0] != cdc->sel[1]) {
-			STEP_SEL(-(str_len + 1));
+			console_step_sel(cdc, -(str_len + 1));
 		}
 
 		return 1;
@@ -150,10 +156,10 @@
 		BLF_draw(mono, line_stride, str_len - initial_offset);
 
 		if (cdc->sel[0] != cdc->sel[1]) {
-			STEP_SEL(-initial_offset);
+			console_step_sel(cdc, -initial_offset);
 			// glColor4ub(255, 0, 0, 96); // debug
 			console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight);
-			STEP_SEL(cdc->console_width);
+			console_step_sel(cdc, cdc->console_width);
 			glColor3ubv(fg);
 		}
 
@@ -168,7 +174,7 @@
 			if (cdc->sel[0] != cdc->sel[1]) {
 				// glColor4ub(0, 255, 0, 96); // debug
 				console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight);
-				STEP_SEL(cdc->console_width);
+				console_step_sel(cdc, cdc->console_width);
 				glColor3ubv(fg);
 			}
 
@@ -180,7 +186,7 @@
 		}
 
 		copy_v2_v2_int(cdc->sel, sel_orig);
-		STEP_SEL(-(str_len + 1));
+		console_step_sel(cdc, -(str_len + 1));
 	}
 	else { /* simple, no wrap */
 
@@ -202,7 +208,7 @@
 
 			// glColor4ub(255, 255, 0, 96); // debug
 			console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight);
-			STEP_SEL(-(str_len + 1));
+			console_step_sel(cdc, -(str_len + 1));
 		}
 
 		cdc->xy[1] += cdc->lheight;
@@ -212,13 +218,12 @@
 	}
 
 	return 1;
-#undef STEP_SEL
 }
 
 #define CONSOLE_DRAW_MARGIN 4
 #define CONSOLE_DRAW_SCROLL 16
 
-int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick, int *pos_pick)
+int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mouse_pick, int *pos_pick)
 {
 	ConsoleDrawContext cdc = {0};
 

Modified: trunk/blender/source/blender/editors/space_info/textview.h
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.h	2012-12-14 04:57:26 UTC (rev 52989)
+++ trunk/blender/source/blender/editors/space_info/textview.h	2012-12-14 05:27:53 UTC (rev 52990)
@@ -54,7 +54,7 @@
 
 } TextViewContext;
 
-int textview_draw(struct TextViewContext *tvc, int draw, int mval[2], void **mouse_pick, int *pos_pick);
+int textview_draw(struct TextViewContext *tvc, const int draw, int mval[2], void **mouse_pick, int *pos_pick);
 
 #define TVC_LINE_FG	(1<<0)
 #define TVC_LINE_BG	(1<<1)




More information about the Bf-blender-cvs mailing list