[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21639] branches/blender2.5/blender: - Scrollbars for the console (use View2D functions)

Campbell Barton ideasman42 at gmail.com
Fri Jul 17 00:47:27 CEST 2009


Revision: 21639
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21639
Author:   campbellbarton
Date:     2009-07-17 00:47:27 +0200 (Fri, 17 Jul 2009)

Log Message:
-----------
- Scrollbars for the console (use View2D functions)
- Set View2D operators not to register, got in the way a lot with the console.
- Made autocomplete Ctrl+Enter so Tab can be used.
- Should work with python 2.5 now. (patch from Vilda)
- Moved report struct definitions into DNA_windowmanager_types.h, could also have DNA_report_types.h however the reports are not saved, its just needed so the report list can be used in the wmWindowManager struct. Fixes a crash reported by ZanQdo.
- Store the report message length in the report so calculating the total height including word wrap is not so slow.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_console.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_report.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/context.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/report.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
    branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c
    branches/blender2.5/blender/source/blender/editors/space_console/console_intern.h
    branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c
    branches/blender2.5/blender/source/blender/editors/space_console/space_console.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c

Modified: branches/blender2.5/blender/release/ui/space_console.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_console.py	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/release/ui/space_console.py	2009-07-16 22:47:27 UTC (rev 21639)
@@ -50,7 +50,7 @@
 	
 	console_id can be any hashable type
 	'''
-	import sys, code, io
+	import sys, code
 	
 	try:	consoles = get_console.consoles
 	except:consoles = get_console.consoles = {}
@@ -72,9 +72,11 @@
 		console = code.InteractiveConsole(namespace)
 		
 		if sys.version.startswith('2'):
-			stdout = io.BytesIO()  # Py2x support
-			stderr = io.BytesIO()
+			import cStringIO
+			stdout = cStringIO.BytesIO()  # Py2x support
+			stderr = cStringIO.BytesIO()
 		else:
+			import io
 			stdout = io.StringIO()
 			stderr = io.StringIO()
 	

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_report.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_report.h	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_report.h	2009-07-16 22:47:27 UTC (rev 21639)
@@ -32,49 +32,15 @@
 extern "C" {
 #endif
 
-#include "DNA_listBase.h"
+#include "DNA_windowmanager_types.h"
 
 /* Reporting Information and Errors
  *
  * These functions also accept NULL in case no error reporting
  * is needed. */
 
-typedef enum ReportType {
-	RPT_DEBUG					= 1<<0,
-	RPT_INFO					= 1<<1,
-	RPT_OPERATOR				= 1<<2,
-	RPT_WARNING					= 1<<3,
-	RPT_ERROR					= 1<<4,
-	RPT_ERROR_INVALID_INPUT		= 1<<5,
-	RPT_ERROR_INVALID_CONTEXT	= 1<<6,
-	RPT_ERROR_OUT_OF_MEMORY		= 1<<7
-} ReportType;
+/* report structures are stored in DNA */
 
-#define RPT_DEBUG_ALL		(RPT_DEBUG)
-#define RPT_INFO_ALL		(RPT_INFO)
-#define RPT_OPERATOR_ALL	(RPT_OPERATOR)
-#define RPT_WARNING_ALL		(RPT_WARNING)
-#define RPT_ERROR_ALL		(RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
-
-enum ReportListFlags {
-	RPT_PRINT = 1,
-	RPT_STORE = 2,
-};
-
-typedef struct Report {
-	struct Report *next, *prev;
-	ReportType type;
-	char *typestr;
-	char *message;
-} Report;
-
-typedef struct ReportList {
-	ListBase list;
-	ReportType printlevel;
-	ReportType storelevel;
-	int flag;
-} ReportList;
-
 void BKE_reports_init(ReportList *reports, int flag);
 void BKE_reports_clear(ReportList *reports);
 

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/context.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/context.c	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/context.c	2009-07-16 22:47:27 UTC (rev 21639)
@@ -206,7 +206,7 @@
 
 struct ReportList *CTX_wm_reports(const bContext *C)
 {
-	return C->wm.manager->reports;
+	return &(C->wm.manager->reports);
 }
 
 View3D *CTX_wm_view3d(const bContext *C)

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/report.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/report.c	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/report.c	2009-07-16 22:47:27 UTC (rev 21639)
@@ -102,7 +102,7 @@
 		len= strlen(message);
 		report->message= MEM_callocN(sizeof(char)*(len+1), "ReportMessage");
 		memcpy(report->message, message, sizeof(char)*(len+1));
-		
+		report->len= len;
 		BLI_addtail(&reports->list, report);
 	}
 }
@@ -129,7 +129,7 @@
 		va_end(args);
 
 		report->message= BLI_dynstr_get_cstring(ds);
-
+		report->len= BLI_dynstr_get_len(ds);
 		BLI_dynstr_free(ds);
 
 		report->type= type;
@@ -155,6 +155,7 @@
 		MEM_freeN(report->message);
 
 		report->message= BLI_dynstr_get_cstring(ds);
+		report->len= BLI_dynstr_get_len(ds);
 
 		BLI_dynstr_free(ds);
 	}
@@ -179,6 +180,7 @@
 		MEM_freeN(report->message);
 
 		report->message= BLI_dynstr_get_cstring(ds);
+		report->len= BLI_dynstr_get_len(ds);
 
 		BLI_dynstr_free(ds);
 	}

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-07-16 22:47:27 UTC (rev 21639)
@@ -4221,7 +4221,8 @@
 	wm->keymaps.first= wm->keymaps.last= NULL;
 	wm->paintcursors.first= wm->paintcursors.last= NULL;
 	wm->queue.first= wm->queue.last= NULL;
-	wm->reports= NULL;
+	BKE_reports_init(&wm->reports, RPT_STORE);
+
 	wm->jobs.first= wm->jobs.last= NULL;
 	
 	wm->windrawable= NULL;

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c	2009-07-16 22:47:27 UTC (rev 21639)
@@ -257,7 +257,7 @@
 	ot->modal= view_pan_modal;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING;
+	ot->flag= OPTYPE_BLOCKING;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -303,7 +303,7 @@
 	ot->exec= view_scrollright_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -349,7 +349,7 @@
 	ot->exec= view_scrollleft_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -394,7 +394,7 @@
 	ot->exec= view_scrolldown_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -440,7 +440,7 @@
 	ot->exec= view_scrollup_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -550,7 +550,7 @@
 	ot->exec= view_zoomin_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
@@ -586,7 +586,7 @@
 	ot->exec= view_zoomout_exec;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER;
+	// ot->flag= OPTYPE_REGISTER;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_float(ot->srna, "zoomfacx", 0, -FLT_MAX, FLT_MAX, "Zoom Factor X", "", -FLT_MAX, FLT_MAX);
@@ -832,7 +832,7 @@
 	ot->modal= view_zoomdrag_modal;
 	
 	/* operator is repeatable */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING;
+	// ot->flag= OPTYPE_REGISTER|OPTYPE_BLOCKING;
 	
 	/* rna - must keep these in sync with the other operators */
 	RNA_def_float(ot->srna, "deltax", 0, -FLT_MAX, FLT_MAX, "Delta X", "", -FLT_MAX, FLT_MAX);

Modified: branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c	2009-07-16 22:23:01 UTC (rev 21638)
+++ branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c	2009-07-16 22:47:27 UTC (rev 21639)
@@ -68,7 +68,7 @@
 	BLF_set(mono);
 	BLF_aspect(1.0);
 
-	BLF_size(sc->lheight, 72);
+	BLF_size(sc->lheight-2, 72);
 }
 
 static void console_line_color(unsigned char *fg, int type)
@@ -106,12 +106,24 @@
 
 /* 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(char *str, int str_len, int console_width, int lheight, unsigned char *fg, unsigned char *bg, int winx, int winy, int *x, int *y)
+static int console_draw_string(	char *str, int str_len,
+									int console_width, int lheight,
+									unsigned char *fg, unsigned char *bg,
+									int winx, int winy,
+									int *x, int *y, int draw)
 {	
 	int rct_ofs= lheight/4;
+	int tot_lines = (str_len/console_width)+1;							/* total number of lines for wrapping */
 
+	/* just advance the height */
+	if(draw==0) {
+		if(str_len > console_width)	(*y) += tot_lines * lheight;
+		else						(*y) += lheight;
+
+		return 1;
+	}
+
 	if(str_len > console_width) { /* wrap? */
-		int tot_lines = (str_len/console_width)+1;							/* total number of lines for wrapping */
 		char *line_stride= str + ((tot_lines-1) * console_width);	/* advance to the last line and draw it first */
 		char eol;															/* baclup the end of wrapping */
 		
@@ -160,11 +172,13 @@
 	return 1;
 }
 
-#define CONSOLE_DRAW_MARGIN 8
-#define CONSOLE_LINE_MARGIN 6
+#define CONSOLE_DRAW_MARGIN 4
+#define CONSOLE_DRAW_SCROLL 16
 
-void console_text_main(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports)
+static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int draw)
 {
+	View2D *v2d= &ar->v2d;
+
 	ConsoleLine *cl= sc->history.last;
 	
 	int x_orig=CONSOLE_DRAW_MARGIN, y_orig=CONSOLE_DRAW_MARGIN;
@@ -176,41 +190,54 @@
 	console_font_begin(sc);
 	cwidth = BLF_fixed_width();
 	
-	console_width= (ar->winx - CONSOLE_DRAW_MARGIN*2)/cwidth;
+	console_width= (ar->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN*2) )/cwidth;
 	if (console_width < 8) console_width= 8;
 	
 	x= x_orig; y= y_orig;
 	
 	if(sc->type==CONSOLE_TYPE_PYTHON) {
-		int prompt_len= strlen(sc->prompt);
+		int prompt_len;
 		
 		/* text */
-		console_line_color(fg, CONSOLE_LINE_INPUT);
-		glColor3ub(fg[0], fg[1], fg[2]);
-		
-		/* command line */
-		if(prompt_len) {
-			BLF_position(x, y, 0); x += cwidth * prompt_len;
-			BLF_draw(sc->prompt);	
+		if(draw) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list