diff options
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_format_lua.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_format_osl.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_format_pov.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_format_pov_ini.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_format_py.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 17 |
6 files changed, 37 insertions, 39 deletions
diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index f7d7f9c6238..4b3ee1c15c7 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -264,7 +264,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; *fmt = FMT_TYPE_STRING; } - /* White-space (all ws. has been converted to spaces). */ + /* White-space (all white-space has been converted to spaces). */ else if (*str == ' ') { *fmt = FMT_TYPE_WHITESPACE; } @@ -287,18 +287,19 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ else if ((*str != '#') && text_check_delim(*str)) { *fmt = FMT_TYPE_SYMBOL; } - /* Identifiers and other text (no previous ws. or delims. so text continues) */ + /* Identifiers and other text (no previous white-space/delimiters so text continues). */ else if (prev == FMT_TYPE_DEFAULT) { str += BLI_str_utf8_size_safe(str) - 1; *fmt = FMT_TYPE_DEFAULT; } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + /* Not white-space, a digit, punctuation, or continuing text. + * Must be new, check for special words. */ else { - /* Keep aligned args for readability. */ + /* Keep aligned arguments for readability. */ /* clang-format off */ - /* Special vars(v) or built-in keywords(b) */ - /* keep in sync with 'txtfmt_osl_format_identifier()' */ + /* Special `vars(v)` or built-in `keywords(b)` */ + /* keep in sync with `txtfmt_osl_format_identifier()`. */ if ((i = txtfmt_lua_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL; } else if ((i = txtfmt_lua_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD; } diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index 27dc1174c49..575eadeee66 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -285,7 +285,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; *fmt = FMT_TYPE_STRING; } - /* White-space (all ws. has been converted to spaces). */ + /* White-space (all white-space has been converted to spaces). */ else if (*str == ' ') { *fmt = FMT_TYPE_WHITESPACE; } @@ -298,18 +298,19 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ else if ((*str != '#') && text_check_delim(*str)) { *fmt = FMT_TYPE_SYMBOL; } - /* Identifiers and other text (no previous ws. or delims. so text continues) */ + /* Identifiers and other text (no previous white-space or delimiters. so text continues). */ else if (prev == FMT_TYPE_DEFAULT) { str += BLI_str_utf8_size_safe(str) - 1; *fmt = FMT_TYPE_DEFAULT; } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + /* Not white-space, a digit, punctuation, or continuing text. + * Must be new, check for special words. */ else { - /* Keep aligned args for readability. */ + /* Keep aligned arguments for readability. */ /* clang-format off */ /* Special vars(v) or built-in keywords(b) */ - /* keep in sync with 'txtfmt_osl_format_identifier()' */ + /* keep in sync with `txtfmt_osl_format_identifier()`. */ if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL; } else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD; } else if ((i = txtfmt_osl_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED; diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 7c2f098f0fa..7c2c4829ad3 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -857,7 +857,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; *fmt = FMT_TYPE_STRING; } - /* White-space (all ws. has been converted to spaces). */ + /* White-space (all white-space has been converted to spaces). */ else if (*str == ' ') { *fmt = FMT_TYPE_WHITESPACE; } @@ -880,18 +880,19 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ else if (text_check_delim(*str)) { *fmt = FMT_TYPE_SYMBOL; } - /* Identifiers and other text (no previous ws. or delims. so text continues) */ + /* Identifiers and other text (no previous white-space/delimiters so text continues). */ else if (prev == FMT_TYPE_DEFAULT) { str += BLI_str_utf8_size_safe(str) - 1; *fmt = FMT_TYPE_DEFAULT; } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + /* Not white-space, a digit, punctuation, or continuing text. + * Must be new, check for special words. */ else { - /* Keep aligned args for readability. */ + /* Keep aligned arguments for readability. */ /* clang-format off */ /* Special vars(v) or built-in keywords(b) */ - /* keep in sync with 'txtfmt_pov_format_identifier()' */ + /* keep in sync with `txtfmt_pov_format_identifier()`. */ if ((i = txtfmt_pov_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL; } else if ((i = txtfmt_pov_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD; } else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) { prev = FMT_TYPE_RESERVED; diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index 6844f08cca6..dda3b7089fe 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -435,7 +435,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; *fmt = FMT_TYPE_STRING; } - /* White-space (all ws. has been converted to spaces). */ + /* White-space (all white-space has been converted to spaces). */ else if (*str == ' ') { *fmt = FMT_TYPE_WHITESPACE; } @@ -458,18 +458,19 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool else if ((*str != '#') && text_check_delim(*str)) { *fmt = FMT_TYPE_SYMBOL; } - /* Identifiers and other text (no previous ws. or delims. so text continues) */ + /* Identifiers and other text (no previous white-space/delimiters so text continues). */ else if (prev == FMT_TYPE_DEFAULT) { str += BLI_str_utf8_size_safe(str) - 1; *fmt = FMT_TYPE_DEFAULT; } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + /* Not white-space, a digit, punctuation, or continuing text. + * Must be new, check for special words */ else { - /* Keep aligned args for readability. */ + /* Keep aligned arguments for readability. */ /* clang-format off */ /* Special vars(v) or built-in keywords(b) */ - /* keep in sync with 'txtfmt_ini_format_identifier()' */ + /* keep in sync with `txtfmt_ini_format_identifier()`. */ if ((i = txtfmt_ini_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD; } else if ((i = txtfmt_ini_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED; } diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 47d0168195b..28f536ffa98 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -59,9 +59,9 @@ static int txtfmt_py_find_builtinfunc(const char *string) /* clang-format off */ if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len; - } else if (STR_LITERAL_STARTSWITH(string, "as", len)) { i = len; } else if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len; } else if (STR_LITERAL_STARTSWITH(string, "async", len)) { i = len; + } else if (STR_LITERAL_STARTSWITH(string, "as", len)) { i = len; } else if (STR_LITERAL_STARTSWITH(string, "await", len)) { i = len; } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len; } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len; @@ -425,7 +425,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n } *fmt = FMT_TYPE_STRING; } - /* White-space (all ws. has been converted to spaces). */ + /* White-space (all white-space has been converted to spaces). */ else if (*str == ' ') { *fmt = FMT_TYPE_WHITESPACE; } @@ -447,18 +447,19 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n else if ((*str != '@') && text_check_delim(*str)) { *fmt = FMT_TYPE_SYMBOL; } - /* Identifiers and other text (no previous ws. or delims. so text continues) */ + /* Identifiers and other text (no previous white-space/delimiters so text continues). */ else if (prev == FMT_TYPE_DEFAULT) { str += BLI_str_utf8_size_safe(str) - 1; *fmt = FMT_TYPE_DEFAULT; } - /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ + /* Not white-space, a digit, punctuation, or continuing text. + * Must be new, check for special words. */ else { - /* Keep aligned args for readability. */ + /* Keep aligned arguments for readability. */ /* clang-format off */ /* Special vars(v) or built-in keywords(b) */ - /* keep in sync with 'txtfmt_py_format_identifier()' */ + /* keep in sync with `txtfmt_py_format_identifier()`. */ if ((i = txtfmt_py_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL; } else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD; } else if ((i = txtfmt_py_find_decorator(str)) != -1) { prev = FMT_TYPE_DIRECTIVE; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 05d51cf6362..33219092d20 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3396,7 +3396,8 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm return OPERATOR_PASS_THROUGH; } - if (!(event->ascii >= '0' && event->ascii <= '9')) { + const char event_ascii = WM_event_utf8_to_ascii(event); + if (!(event_ascii >= '0' && event_ascii <= '9')) { return OPERATOR_PASS_THROUGH; } @@ -3406,7 +3407,7 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm } jump_to *= 10; - jump_to += (int)(event->ascii - '0'); + jump_to += (int)(event_ascii - '0'); txt_move_toline(text, jump_to - 1, 0); last_jump = time; @@ -3495,16 +3496,8 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) } char str[BLI_UTF8_MAX + 1]; - size_t len; - - if (event->utf8_buf[0]) { - len = BLI_str_utf8_size_safe(event->utf8_buf); - memcpy(str, event->utf8_buf, len); - } - else { - /* in theory, ghost can set value to extended ascii here */ - len = BLI_str_utf8_from_unicode(event->ascii, str, sizeof(str) - 1); - } + const size_t len = BLI_str_utf8_size_safe(event->utf8_buf); + memcpy(str, event->utf8_buf, len); str[len] = '\0'; RNA_string_set(op->ptr, "text", str); |