From dcad1eb03ccc0782229d81cdbeaa71c035c09955 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Aug 2019 17:16:27 +1000 Subject: Cleanup: move utf8 offset conversion into BLI_string_utf8 There isn't anything specific to text data with these functions. --- source/blender/editors/space_info/textview.c | 9 ++++----- source/blender/editors/space_text/text_draw.c | 6 +++--- source/blender/editors/space_text/text_ops.c | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 108803a865f..24d3008b1e7 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -35,8 +35,6 @@ #include "GPU_immediate.h" #include "GPU_state.h" -#include "BKE_text.h" - #include "textview.h" static void console_font_begin(const int font_id, const int lheight) @@ -78,8 +76,8 @@ static void console_draw_sel(const char *str, const unsigned char bg_sel[4]) { if (sel[0] <= str_len_draw && sel[1] >= 0) { - const int sta = txt_utf8_offset_to_column(str, max_ii(sel[0], 0)); - const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); + const int sta = BLI_str_utf8_offset_to_column(str, max_ii(sel[0], 0)); + const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); GPU_blend(true); GPU_blend_set_func_separate( @@ -156,7 +154,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, } /* last part */ - ofs += txt_utf8_column_to_offset(str + ofs, (int)floor((float)cdc->mval[0] / cdc->cwidth)); + ofs += BLI_str_utf8_offset_from_column(str + ofs, + (int)floor((float)cdc->mval[0] / cdc->cwidth)); CLAMP(ofs, 0, str_len); *cdc->pos_pick += str_len - ofs; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index c03b804aa2c..9dc8dfa93b6 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -240,7 +240,7 @@ void wrap_offset( } max = wrap_width(st, ar); - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); while (linep) { start = 0; @@ -323,7 +323,7 @@ void wrap_offset_in_line( end = max; chop = 1; *offc = 0; - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size_safe(linein->line + j)) { int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab */ @@ -1400,7 +1400,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi linep = startl; c = startc; - fc = txt_utf8_offset_to_index(linep->line, startc); + fc = BLI_str_utf8_offset_to_index(linep->line, startc); endl = NULL; endc = -1; find = -b; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 7c4a403d43d..a8af9c73bf2 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1827,7 +1827,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) if (j >= oldc) { if (ch == '\0') { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); } loop = 0; break; @@ -1843,7 +1843,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) } else if (ch == ' ' || ch == '-' || ch == '\0') { if (j >= oldc) { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); loop = 0; break; } -- cgit v1.2.3