[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33400] trunk/blender/source/blender/ editors/space_console: minor console changes.

Campbell Barton ideasman42 at gmail.com
Tue Nov 30 23:39:41 CET 2010


Revision: 33400
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33400
Author:   campbellbarton
Date:     2010-11-30 23:39:41 +0100 (Tue, 30 Nov 2010)

Log Message:
-----------
minor console changes.
- remove report argument from console functions.
- don't update the scroll area while drawing, do this within operators instead.
- dont redraw while selecting text unless selection changes.

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_console/console_ops.c
    trunk/blender/source/blender/editors/space_console/space_console.c

Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c	2010-11-30 21:51:03 UTC (rev 33399)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c	2010-11-30 22:39:41 UTC (rev 33400)
@@ -187,7 +187,7 @@
 }
 
 
-static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, ReportList *UNUSED(reports), int draw, int mval[2], void **mouse_pick, int *pos_pick)
+static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick)
 {
 	ConsoleLine cl_dummy= {0};
 	int ret= 0;
@@ -195,6 +195,7 @@
 	View2D *v2d= &ar->v2d;
 
 	TextViewContext tvc= {0};
+
 	tvc.begin= console_textview_begin;
 	tvc.end= console_textview_end;
 
@@ -221,19 +222,19 @@
 }
 
 
-void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports)
+void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar)
 {
 	int mval[2] = {INT_MAX, INT_MAX};
-	console_textview_main__internal(sc, ar, reports, 1,  mval, NULL, NULL);
+	console_textview_main__internal(sc, ar, 1,  mval, NULL, NULL);
 }
 
-int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports)
+int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar)
 {
 	int mval[2] = {INT_MAX, INT_MAX};
-	return console_textview_main__internal(sc, ar, reports, 0,  mval, NULL, NULL);
+	return console_textview_main__internal(sc, ar, 0,  mval, NULL, NULL);
 }
 
-void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mouse_y)
+void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, int mouse_y)
 {
 	void *mouse_pick= NULL;
 	int mval[2];
@@ -241,11 +242,11 @@
 	mval[0]= 0;
 	mval[1]= mouse_y;
 
-	console_textview_main__internal(sc, ar, reports, 0, mval, &mouse_pick, NULL);
+	console_textview_main__internal(sc, ar, 0, mval, &mouse_pick, NULL);
 	return (void *)mouse_pick;
 }
 
-int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mval[2])
+int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2])
 {
 	int pos_pick= 0;
 	void *mouse_pick= NULL;
@@ -254,6 +255,6 @@
 	mval_clamp[0]= CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx-(CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN));
 	mval_clamp[1]= CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy-CONSOLE_DRAW_MARGIN);
 
-	console_textview_main__internal(sc, ar, reports, 0, mval_clamp, &mouse_pick, &pos_pick);
+	console_textview_main__internal(sc, ar, 0, mval_clamp, &mouse_pick, &pos_pick);
 	return pos_pick;
 }

Modified: trunk/blender/source/blender/editors/space_console/console_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_intern.h	2010-11-30 21:51:03 UTC (rev 33399)
+++ trunk/blender/source/blender/editors/space_console/console_intern.h	2010-11-30 22:39:41 UTC (rev 33400)
@@ -32,10 +32,10 @@
 struct bContext;
 
 /* console_draw.c */
-void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports);
-int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); /* needed to calculate the scrollbar */
-void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports, int mouse_y); /* needed for selection */
-int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mval[2]);
+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 */
+void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, int mouse_y); /* needed for selection */
+int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, 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_console/console_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_ops.c	2010-11-30 21:51:03 UTC (rev 33399)
+++ trunk/blender/source/blender/editors/space_console/console_ops.c	2010-11-30 22:39:41 UTC (rev 33400)
@@ -40,6 +40,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "UI_view2d.h"
 #include "ED_screen.h"
 
 #include "RNA_access.h"
@@ -47,6 +48,13 @@
 
 #include "console_intern.h"
 
+static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar)
+{
+	View2D *v2d= &ar->v2d;
+
+	UI_view2d_totRect_set(v2d, ar->winx-1, console_textview_height(sc, ar));
+}
+
 static void console_select_offset(SpaceConsole *sc, const int offset)
 {
 	sc->sel_start += offset;
@@ -349,6 +357,8 @@
 #define TAB_LENGTH 4
 static int insert_exec(bContext *C, wmOperator *op)
 {
+	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
 	ConsoleLine *ci= console_history_verify(C);
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
 	int len;
@@ -373,7 +383,8 @@
 		SpaceConsole *sc= CTX_wm_space_console(C);
 		console_select_offset(sc, len);
 	}
-		
+
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 	
 	return OPERATOR_FINISHED;
@@ -424,13 +435,12 @@
 
 static int delete_exec(bContext *C, wmOperator *op)
 {
-	
+	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
 	ConsoleLine *ci= console_history_verify(C);
-	
-	
+
+	const short type= RNA_enum_get(op->ptr, "type");
 	int done = 0;
-
-	int type= RNA_enum_get(op->ptr, "type");
 	
 	if(ci->len==0) {
 		return OPERATOR_CANCELLED;
@@ -461,7 +471,8 @@
 		SpaceConsole *sc= CTX_wm_space_console(C);
 		console_select_offset(sc, -1);
 	}
-	
+
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 	
 	return OPERATOR_FINISHED;
@@ -488,6 +499,7 @@
 static int clear_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
 	
 	short scrollback= RNA_boolean_get(op->ptr, "scrollback");
 	short history= RNA_boolean_get(op->ptr, "history");
@@ -503,9 +515,10 @@
 		while(sc->history.first)
 			console_history_free(sc, sc->history.first);
 	}
-	
+
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
-	
+
 	return OPERATOR_FINISHED;
 }
 
@@ -531,6 +544,8 @@
 static int history_cycle_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
+
 	ConsoleLine *ci= console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */
 	short reverse= RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */
 	int prev_len= ci->len;
@@ -566,6 +581,8 @@
 	ci= sc->history.last;
 	console_select_offset(sc, ci->len - prev_len);
 
+	/* could be wrapped so update scroll rect */
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 
 	return OPERATOR_FINISHED;
@@ -591,6 +608,7 @@
 static int history_append_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ScrArea *sa= CTX_wm_area(C);
 	ConsoleLine *ci= console_history_verify(C);
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
 	int cursor= RNA_int_get(op->ptr, "current_character");
@@ -613,9 +631,9 @@
 	ci= console_history_add_str(sc, str, 1); /* own the string */
 	console_select_offset(sc, ci->len - prev_len);
 	console_line_cursor_set(ci, cursor);
-	
-	ED_area_tag_redraw(CTX_wm_area(C));
-	
+
+	ED_area_tag_redraw(sa);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -641,6 +659,8 @@
 static int scrollback_append_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
+
 	ConsoleLine *ci= console_history_verify(C);
 	
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
@@ -650,7 +670,8 @@
 	ci->type= type;
 	
 	console_scrollback_limit(sc);
-	
+
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 	
 	return OPERATOR_FINISHED;
@@ -765,6 +786,7 @@
 static int paste_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
 	ConsoleLine *ci= console_history_verify(C);
 
 	char *buf_str= WM_clipboard_text_get(0);
@@ -793,6 +815,7 @@
 
 	MEM_freeN(buf_str);
 
+	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 
 	return OPERATOR_FINISHED;
@@ -821,7 +844,7 @@
 static void set_cursor_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleCursor *scu, int mval[2], int UNUSED(sel))
 {
 	int pos;
-	pos= console_char_pick(sc, ar, NULL, mval);
+	pos= console_char_pick(sc, ar, mval);
 
 	if(scu->sel_init == INT_MAX) {
 		scu->sel_init= pos;
@@ -848,12 +871,20 @@
 	ARegion *ar= CTX_wm_region(C);
 	SetConsoleCursor *scu= op->customdata;
 	int mval[2];
+	int sel_prev[2];
 
 	mval[0]= event->mval[0];
 	mval[1]= event->mval[1];
 
+	sel_prev[0]= sc->sel_start;
+	sel_prev[1]= sc->sel_end;
+	
 	set_cursor_to_pos(sc, ar, scu, mval, TRUE);
-	ED_area_tag_redraw(CTX_wm_area(C));
+
+	/* only redraw if the selection changed */
+	if(sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) {
+		ED_area_tag_redraw(CTX_wm_area(C));
+	}
 }
 
 static void set_cursor_exit(bContext *UNUSED(C), wmOperator *op)

Modified: trunk/blender/source/blender/editors/space_console/space_console.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/space_console.c	2010-11-30 21:51:03 UTC (rev 33399)
+++ trunk/blender/source/blender/editors/space_console/space_console.c	2010-11-30 22:39:41 UTC (rev 33400)
@@ -53,14 +53,6 @@
 
 #include "console_intern.h"	// own include
 
-static void console_textview_update_rect(const bContext *C, ARegion *ar)
-{
-	SpaceConsole *sc= CTX_wm_space_console(C);
-	View2D *v2d= &ar->v2d;
-
-	UI_view2d_totRect_set(v2d, ar->winx-1, console_textview_height(sc, ar, CTX_wm_reports(C)));
-}
-
 /* ******************** default callbacks for console space ***************** */
 
 static SpaceLink *console_new(const bContext *UNUSED(C))

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list