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:
Diffstat (limited to 'source/blender/editors/space_text/text_draw.c')
-rw-r--r--source/blender/editors/space_text/text_draw.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 95802be9ef9..af827d6dc5a 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -373,9 +373,11 @@ 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 */
+ /* warning, only valid when 'use_syntax' is set */
int a, fstart, fpos; /* utf8 chars */
int mi, ma, mstart, mend; /* mem */
char fmt_prev = 0xff;
@@ -397,8 +399,11 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
/* skip hidden part of line */
if (skip) {
skip--;
- fstart = fpos = end;
- mstart = mend;
+ if (use_syntax) {
+ /* currently fpos only used when formatting */
+ fpos += BLI_strnlen_utf8(str + mstart, mend - mstart);
+ }
+ fstart = fpos; mstart = mend;
mend = txt_utf8_forward_columns(str + mend, max, &padding) - str;
end = (wrap += max - padding);
continue;
@@ -406,7 +411,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 +433,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 +447,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 +480,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;