From 8ddc3d148e9d8e55a5d64774e0a2a430f92bba59 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Sep 2014 01:04:07 +1000 Subject: Cleanup: simplify check to draw syntax --- source/blender/editors/space_text/text_draw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 95802be9ef9..e2351c8360f 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -373,6 +373,7 @@ static const char *txt_utf8_forward_columns(const char *str, int columns, int *p static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w, const char *format, int skip) { + const bool use_syntax = (st->showsyntax && format); FlattenString fs; int basex, lines; int i, wrap, end, max, columns, padding; /* column */ @@ -406,7 +407,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w /* Draw the visible portion of text on the overshot line */ for (a = fstart, ma = mstart; ma < mend; a++, ma += BLI_str_utf8_size_safe(str + ma)) { - if (st->showsyntax && format) { + if (use_syntax) { if (fmt_prev != format[a]) format_draw_color(fmt_prev = format[a]); } x += text_font_draw_character_utf8(st, x, y, str + ma); @@ -428,7 +429,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w /* Draw the remaining text */ for (a = fstart, ma = mstart; str[ma] && y > 0; a++, ma += BLI_str_utf8_size_safe(str + ma)) { - if (st->showsyntax && format) { + if (use_syntax) { if (fmt_prev != format[a]) format_draw_color(fmt_prev = format[a]); } @@ -442,6 +443,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w static void text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int x, int y, const char *format) { + const bool use_syntax = (st->showsyntax && format); FlattenString fs; int columns, size, n, w = 0, padding, amount = 0; const char *in = NULL; @@ -474,7 +476,7 @@ static void text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int x, x += st->cwidth * padding; - if (st->showsyntax && format) { + if (use_syntax) { int a, str_shift = 0; char fmt_prev = 0xff; -- cgit v1.2.3