[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33431] trunk/blender/source/blender/ editors/space_info: fix [#24586] Report mode of console does not show proper cariage returns.

Campbell Barton ideasman42 at gmail.com
Thu Dec 2 22:48:46 CET 2010


Revision: 33431
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33431
Author:   campbellbarton
Date:     2010-12-02 22:48:46 +0100 (Thu, 02 Dec 2010)

Log Message:
-----------
fix [#24586] Report mode of console does not show proper cariage returns.
use the line iterator to split up newlines.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_info/info_draw.c
    trunk/blender/source/blender/editors/space_info/info_intern.h
    trunk/blender/source/blender/editors/space_info/info_report.c
    trunk/blender/source/blender/editors/space_info/textview.h

Modified: trunk/blender/source/blender/editors/space_info/info_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/info_draw.c	2010-12-02 21:40:39 UTC (rev 33430)
+++ trunk/blender/source/blender/editors/space_info/info_draw.c	2010-12-02 21:48:46 UTC (rev 33431)
@@ -54,8 +54,12 @@
 
 #include "UI_resources.h"
 
+#include "info_intern.h"
 #include "../space_info/textview.h"
 
+/* complicates things a bit, so leaving in old simple code */
+#define USE_INFO_NEWLINE
+
 static void info_report_color(unsigned char *fg, unsigned char *bg, Report *report, int bool)
 {
 	/*
@@ -89,8 +93,34 @@
 	}
 }
 
+/* reports! */
+#ifdef USE_INFO_NEWLINE
+static void report_textview_init__internal(TextViewContext *tvc)
+{
+	Report *report= (Report *)tvc->iter;
+	const char *str= report->message;
+	const char *next_str= strchr(str + tvc->iter_char, '\n');
 
-/* reports! */
+	if(next_str) {
+		tvc->iter_char_next= (int)(next_str - str);
+	}
+	else {
+		tvc->iter_char_next= report->len;
+	}
+}
+
+static int report_textview_skip__internal(TextViewContext *tvc)
+{
+	SpaceInfo *sinfo= (SpaceInfo *)tvc->arg1;
+	const int report_mask= info_report_mask(sinfo);
+	while (tvc->iter && (((Report *)tvc->iter)->type & report_mask)==0) {
+		tvc->iter= (void *)((Link *)tvc->iter)->prev;
+	}
+	return (tvc->iter != NULL);
+}
+
+#endif // USE_INFO_NEWLINE
+
 static int report_textview_begin(TextViewContext *tvc)
 {
 	// SpaceConsole *sc= (SpaceConsole *)tvc->arg1;
@@ -106,7 +136,21 @@
 	glClearColor(120.0/255.0, 120.0/255.0, 120.0/255.0, 1.0);
 	glClear(GL_COLOR_BUFFER_BIT);
 
+#ifdef USE_INFO_NEWLINE
+	tvc->iter_tmp= 0;
+	if(tvc->iter && report_textview_skip__internal(tvc)) {
+		/* init the newline iterator */
+		tvc->iter_char= 0;
+		report_textview_init__internal(tvc);
+
+		return TRUE;
+	}
+	else {
+		return FALSE;
+	}
+#else
 	return (tvc->iter != NULL);
+#endif
 }
 
 static void report_textview_end(TextViewContext *UNUSED(tvc))
@@ -114,14 +158,67 @@
 	/* pass */
 }
 
+#ifdef USE_INFO_NEWLINE
 static int report_textview_step(TextViewContext *tvc)
 {
-	return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL);
+	/* simple case, but no newline support */
+	Report *report= (Report *)tvc->iter;
+
+	if(report->len <= tvc->iter_char_next) {
+		tvc->iter= (void *)((Link *)tvc->iter)->prev;
+		if(tvc->iter && report_textview_skip__internal(tvc)) {
+			tvc->iter_tmp++;
+
+			tvc->iter_char= 0; /* reset start */
+			report_textview_init__internal(tvc);
+
+			return TRUE;
+		}
+		else {
+			return FALSE;
+		}
+	}
+	else {
+		/* step to the next newline */
+		tvc->iter_char= tvc->iter_char_next + 1;
+		report_textview_init__internal(tvc);
+
+		return TRUE;
+	}
 }
 
 static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len)
 {
 	Report *report= (Report *)tvc->iter;
+	*line= report->message + tvc->iter_char;
+	*len= tvc->iter_char_next - tvc->iter_char;
+	return 1;
+}
+
+static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3])
+{
+	Report *report= (Report *)tvc->iter;
+	info_report_color(fg, bg, report, tvc->iter_tmp % 2);
+	return TVC_LINE_FG | TVC_LINE_BG;
+}
+
+
+#else // USE_INFO_NEWLINE
+
+static int report_textview_step(TextViewContext *tvc)
+{
+	SpaceInfo *sinfo= (SpaceInfo *)tvc->arg1;
+	const int report_mask= info_report_mask(sinfo);
+	do {
+		tvc->iter= (void *)((Link *)tvc->iter)->prev;
+	} while (tvc->iter && (((Report *)tvc->iter)->type & report_mask)==0);
+
+	return (tvc->iter != NULL);
+}
+
+static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len)
+{
+	Report *report= (Report *)tvc->iter;
 	*line= report->message;
 	*len= report->len;
 
@@ -131,11 +228,14 @@
 static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3])
 {
 	Report *report= (Report *)tvc->iter;
-	info_report_color(fg, bg, report, tvc->iter_index % 2);
+	info_report_color(fg, bg, report, tvc->iter_tmp % 2);
 	return TVC_LINE_FG | TVC_LINE_BG;
 }
 
+#endif // USE_INFO_NEWLINE
 
+#undef USE_INFO_NEWLINE
+
 static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick)
 {
 	int ret= 0;

Modified: trunk/blender/source/blender/editors/space_info/info_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_info/info_intern.h	2010-12-02 21:40:39 UTC (rev 33430)
+++ trunk/blender/source/blender/editors/space_info/info_intern.h	2010-12-02 21:48:46 UTC (rev 33431)
@@ -49,7 +49,7 @@
 void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports);
 
 /* info_report.c */
-/* console_report.c */
+int info_report_mask(struct SpaceInfo *sinfo);
 void INFO_OT_select_pick(struct wmOperatorType *ot); /* report selection */
 void INFO_OT_select_all_toggle(struct wmOperatorType *ot);
 void INFO_OT_select_border(struct wmOperatorType *ot);

Modified: trunk/blender/source/blender/editors/space_info/info_report.c
===================================================================
--- trunk/blender/source/blender/editors/space_info/info_report.c	2010-12-02 21:40:39 UTC (rev 33430)
+++ trunk/blender/source/blender/editors/space_info/info_report.c	2010-12-02 21:48:46 UTC (rev 33431)
@@ -45,8 +45,9 @@
 
 #include "info_intern.h"
 
-int info_report_mask(SpaceInfo *sinfo)
+int info_report_mask(SpaceInfo *UNUSED(sinfo))
 {
+#if 0
 	int report_mask = 0;
 
 	if(sinfo->rpt_mask & INFO_RPT_DEBUG)	report_mask |= RPT_DEBUG_ALL;
@@ -56,6 +57,9 @@
 	if(sinfo->rpt_mask & INFO_RPT_ERR)		report_mask |= RPT_ERROR_ALL;
 
 	return report_mask;
+#endif
+
+	return RPT_DEBUG_ALL|RPT_INFO_ALL|RPT_OPERATOR_ALL|RPT_WARNING_ALL|RPT_ERROR_ALL;
 }
 
 // TODO, get this working again!

Modified: trunk/blender/source/blender/editors/space_info/textview.h
===================================================================
--- trunk/blender/source/blender/editors/space_info/textview.h	2010-12-02 21:40:39 UTC (rev 33430)
+++ trunk/blender/source/blender/editors/space_info/textview.h	2010-12-02 21:48:46 UTC (rev 33431)
@@ -45,6 +45,9 @@
 	int (*line_color)(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]);
 	void *iter;
 	int iter_index;
+	int iter_char;		/* char intex, used for multi-line report display */
+	int iter_char_next;	/* same as above, next \n */
+	int iter_tmp;		/* internal iterator use */
 
 } TextViewContext;
 





More information about the Bf-blender-cvs mailing list