diff options
-rw-r--r-- | source/blender/editors/space_info/info_draw.c | 106 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_info/info_report.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_info/textview.h | 3 |
4 files changed, 112 insertions, 5 deletions
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index fe2c0efe44d..cc5e02c6266 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -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 @@ static void info_report_color(unsigned char *fg, unsigned char *bg, Report *repo } } - /* 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'); + + 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 @@ static int report_textview_begin(TextViewContext *tvc) 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,9 +158,62 @@ static void report_textview_end(TextViewContext *UNUSED(tvc)) /* pass */ } +#ifdef USE_INFO_NEWLINE +static int report_textview_step(TextViewContext *tvc) +{ + /* 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) { - return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); + 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) @@ -131,10 +228,13 @@ static int report_textview_line_get(struct TextViewContext *tvc, const char **li 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) { diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 4953bc1b4be..abbe37a4fe1 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -49,7 +49,7 @@ int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, struct Rep 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); diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 0fc8e157d92..8ae9c1293eb 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -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 @@ int info_report_mask(SpaceInfo *sinfo) 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! diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h index 390f9f5ed7c..aeea12827be 100644 --- a/source/blender/editors/space_info/textview.h +++ b/source/blender/editors/space_info/textview.h @@ -45,6 +45,9 @@ typedef struct TextViewContext { 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; |