diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-11 19:35:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-11 19:35:11 +0400 |
commit | 66134ea38166742444720a4fe2f8d95effd8866a (patch) | |
tree | 3282fd6536cbf98d3173270c5a5c0fb154bccf7c /source/blender | |
parent | a0a99e4a4d90ea4226b29d97ee83b02e4e439156 (diff) |
patch [#22570] Text editor syntax coloring update
from Jacob F (raccoon)
This does two things to the text editor:
1) Adds coloring (same color as numbers) for True and False.
2) Fixes [#22551] Syntax coloring offset does not update when using real tabs and changing tab width
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 26 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 2 |
3 files changed, 28 insertions, 4 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 3a23cd32629..96b38f2e78d 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -118,15 +118,13 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_TEXT: - if(!wmn->reference || wmn->reference == st->text) { + if(!wmn->reference || wmn->reference == st->text || wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) { ED_area_tag_redraw(sa); if(wmn->action == NA_EDITED) if(st->text) text_update_edited(st->text); } - else if(wmn->data == ND_DISPLAY) - ED_area_tag_redraw(sa); break; case NC_SPACE: diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 7ae432e3d6f..3a891a66107 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -224,6 +224,21 @@ static int find_specialvar(char *string) return i; } +static int find_bool(char *string) +{ + int i = 0; + /* Check for "False" */ + if(string[0]=='F' && string[1]=='a' && string[2]=='l' && string[3]=='s' && string[4]=='e') + i = 5; + /* Check for "True" */ + else if(string[0]=='T' && string[1]=='r' && string[2]=='u' && string[3]=='e') + i = 4; + /* If next source char is an identifier (eg. 'i' in "definate") no match */ + if(i==0 || text_check_identifier(string[i])) + return -1; + return i; +} + /* Ensures the format string for the given line is long enough, reallocating as needed. Allocation is done here, alone, to ensure consistency. */ int text_check_format_len(TextLine *line, unsigned int len) @@ -335,6 +350,17 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) /* Numbers (digits not part of an identifier and periods followed by digits) */ else if((prev != 'q' && text_check_digit(*str)) || (*str == '.' && text_check_digit(*(str+1)))) *fmt = 'n'; + /* Booleans */ + else if(prev != 'q' && (i=find_bool(str)) != -1) + if(i>0) { + while(i>1) { + *fmt = 'n'; fmt++; str++; + i--; + } + *fmt = 'n'; + } + else + *fmt = 'q'; /* Punctuation */ else if(text_check_delim(*str)) *fmt = '!'; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b2607a2452b..2d582d54bbd 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1557,7 +1557,7 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "tabnumber"); RNA_def_property_range(prop, 2, 8); RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL); + RNA_def_property_update(prop, NC_TEXT|NA_EDITED, NULL); prop= RNA_def_property(srna, "font_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "lheight"); |