Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-03-13 12:12:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-03-13 12:14:33 +0300
commitdf032580c170d9f5e508b34673b84a14f8808990 (patch)
treeeb50b9a1fd4580b5fdf8b4803b697411527e7d06 /source/blender/editors/space_info
parent54743dbf09323cffafb04b5c6c64d15941b63108 (diff)
Fix info showing multi-line reports reversed (upside-down)
Also, only show the icon once per report.
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r--source/blender/editors/space_info/info_draw.c32
-rw-r--r--source/blender/editors/space_info/textview.h8
2 files changed, 22 insertions, 18 deletions
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c
index 0a5ca81484c..d704e10cce9 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.c
@@ -61,7 +61,10 @@ static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
int icon_fg_id;
int icon_bg_id;
- if (report->type & RPT_ERROR_ALL) {
+ if (tvc->iter_char_begin != 0) {
+ *r_icon = ICON_NONE;
+ }
+ else if (report->type & RPT_ERROR_ALL) {
icon_fg_id = TH_INFO_ERROR_TEXT;
icon_bg_id = TH_INFO_ERROR;
*r_icon = ICON_CANCEL;
@@ -115,14 +118,13 @@ static void report_textview_init__internal(TextViewContext *tvc)
{
const 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;
+ for (int i = tvc->iter_char_end - 1; i >= 0; i -= 1) {
+ if (str[i] == '\n') {
+ tvc->iter_char_begin = i + 1;
+ return;
+ }
}
+ tvc->iter_char_begin = 0;
}
static int report_textview_skip__internal(TextViewContext *tvc)
@@ -152,7 +154,8 @@ static int report_textview_begin(TextViewContext *tvc)
tvc->iter_tmp = 0;
if (tvc->iter && report_textview_skip__internal(tvc)) {
/* init the newline iterator */
- tvc->iter_char = 0;
+ const Report *report = tvc->iter;
+ tvc->iter_char_end = report->len;
report_textview_init__internal(tvc);
return true;
@@ -172,12 +175,13 @@ static int report_textview_step(TextViewContext *tvc)
/* simple case, but no newline support */
const Report *report = tvc->iter;
- if (report->len <= tvc->iter_char_next) {
+ if (tvc->iter_char_begin <= 0) {
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 = tvc->iter;
+ tvc->iter_char_end = report->len; /* reset start */
report_textview_init__internal(tvc);
return true;
@@ -188,7 +192,7 @@ static int report_textview_step(TextViewContext *tvc)
}
else {
/* step to the next newline */
- tvc->iter_char = tvc->iter_char_next + 1;
+ tvc->iter_char_end = tvc->iter_char_begin - 1;
report_textview_init__internal(tvc);
return true;
@@ -198,8 +202,8 @@ static int report_textview_step(TextViewContext *tvc)
static void report_textview_line_get(TextViewContext *tvc, const char **r_line, int *r_len)
{
const Report *report = tvc->iter;
- *r_line = report->message + tvc->iter_char;
- *r_len = tvc->iter_char_next - tvc->iter_char;
+ *r_line = report->message + tvc->iter_char_begin;
+ *r_len = tvc->iter_char_end - tvc->iter_char_begin;
}
static void info_textview_draw_rect_calc(const ARegion *region,
diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h
index 54b7c477791..8eef4ef5d56 100644
--- a/source/blender/editors/space_info/textview.h
+++ b/source/blender/editors/space_info/textview.h
@@ -65,10 +65,10 @@ typedef struct TextViewContext {
void (*const_colors)(struct TextViewContext *tvc, unsigned char bg_sel[4]);
const void *iter;
int iter_index;
- /** Char index, used for multi-line report display. */
- int iter_char;
- /** Same as 'iter_char', next new-line. */
- int iter_char_next;
+ /** Used for internal multi-line iteration. */
+ int iter_char_begin;
+ /** The last character (not inclusive). */
+ int iter_char_end;
/** Internal iterator use. */
int iter_tmp;