Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_format_py.c
| Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
| static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_next) | static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_next) | ||||
| { | { | ||||
| FlattenString fs; | FlattenString fs; | ||||
| const char *str; | const char *str; | ||||
| char *fmt; | char *fmt; | ||||
| char cont_orig, cont, find, prev = ' '; | char cont_orig, cont, find, prev = ' '; | ||||
| int len, i; | int len, i; | ||||
| bool only_ws_before = true; | |||||
| /* Get continuation from previous line */ | /* Get continuation from previous line */ | ||||
| if (line->prev && line->prev->format != NULL) { | if (line->prev && line->prev->format != NULL) { | ||||
| fmt = line->prev->format; | fmt = line->prev->format; | ||||
| cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ | cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */ | ||||
| BLI_assert((FMT_CONT_ALL & cont) == cont); | BLI_assert((FMT_CONT_ALL & cont) == cont); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | else { | ||||
| text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i); | text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i); | ||||
| } | } | ||||
| else { | else { | ||||
| str += BLI_str_utf8_size_safe(str) - 1; | str += BLI_str_utf8_size_safe(str) - 1; | ||||
| *fmt = FMT_TYPE_DEFAULT; | *fmt = FMT_TYPE_DEFAULT; | ||||
| } | } | ||||
| } | } | ||||
| /* Punctuation */ | /* Punctuation */ | ||||
| else if ((*str != '@') && text_check_delim(*str)) { | else if (!((*str == '@') && only_ws_before) && text_check_delim(*str)) { | ||||
| *fmt = FMT_TYPE_SYMBOL; | *fmt = FMT_TYPE_SYMBOL; | ||||
| } | } | ||||
| /* Identifiers and other text (no previous ws. or delims. so text continues) */ | /* Identifiers and other text (no previous ws. or delims. so text continues) */ | ||||
| else if (prev == FMT_TYPE_DEFAULT) { | else if (prev == FMT_TYPE_DEFAULT) { | ||||
| str += BLI_str_utf8_size_safe(str) - 1; | str += BLI_str_utf8_size_safe(str) - 1; | ||||
| *fmt = FMT_TYPE_DEFAULT; | *fmt = FMT_TYPE_DEFAULT; | ||||
| } | } | ||||
| /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ | /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ | ||||
| Show All 14 Lines | else { | ||||
| } | } | ||||
| else { | else { | ||||
| str += BLI_str_utf8_size_safe(str) - 1; | str += BLI_str_utf8_size_safe(str) - 1; | ||||
| *fmt = FMT_TYPE_DEFAULT; | *fmt = FMT_TYPE_DEFAULT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| prev = *fmt; fmt++; str++; | prev = *fmt; fmt++; str++; | ||||
| only_ws_before &= (prev == FMT_TYPE_WHITESPACE); | |||||
| } | } | ||||
| /* Terminate and add continuation char */ | /* Terminate and add continuation char */ | ||||
| *fmt = '\0'; fmt++; | *fmt = '\0'; fmt++; | ||||
| *fmt = cont; | *fmt = cont; | ||||
| /* If continuation has changed and we're allowed, process the next line */ | /* If continuation has changed and we're allowed, process the next line */ | ||||
| if (cont != cont_orig && do_next && line->next) { | if (cont != cont_orig && do_next && line->next) { | ||||
| Show All 17 Lines | |||||