add syntax highlighting color for symbols
authorCampbell Barton <ideasman42@gmail.com>
Sun, 30 Dec 2012 01:26:31 +0000 (01:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 30 Dec 2012 01:26:31 +0000 (01:26 +0000)
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_text/text_format_osl.c
source/blender/editors/space_text/text_format_py.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index a114981a700b69ad05069671cd29fce46eb27452..e575d9ac9243b40611e84319e089159446c698a9 100644 (file)
@@ -127,6 +127,7 @@ enum {
        TH_SYNTAX_L,
        TH_SYNTAX_D,
        TH_SYNTAX_N,
+       TH_SYNTAX_S,
        
        TH_BONE_SOLID,
        TH_BONE_POSE,
index b078125612693e347ea15859af4b1b40360c6afc..25e7a4b58bad66dbc3511e8d19e5bb03bba70100 100644 (file)
@@ -364,6 +364,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                        cp = ts->syntaxr; break;
                                case TH_SYNTAX_N:
                                        cp = ts->syntaxn; break;
+                               case TH_SYNTAX_S:
+                                       cp = ts->syntaxs; break;
 
                                case TH_NODE:
                                        cp = ts->syntaxl; break;
@@ -890,6 +892,7 @@ void ui_theme_init_default(void)
        rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
        rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange*/
        rgba_char_args_set(btheme->text.syntaxb,    128, 0, 80, 255);   /* Builtin  Red-purple */
+       rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
        
        /* space oops */
        btheme->toops = btheme->tv3d;
@@ -2093,6 +2096,7 @@ void init_userdef_do_versions(void)
                for (btheme = U.themes.first; btheme; btheme = btheme->next) {
                        rgba_char_args_set(btheme->text.syntaxd,    50, 0, 140, 255);   /* Decorator/Preprocessor Dir.  Blue-purple */
                        rgba_char_args_set(btheme->text.syntaxr,    140, 60, 0, 255);   /* Reserved  Orange */
+                       rgba_char_args_set(btheme->text.syntaxs,    76, 76, 76, 255);   /* Grey (mix between fg/bg) */
                }
        }
        
index 01adf6a410709ebf8305be5d2e76fcbabfa2fe34..2256c1c7e25694d00f0add73df224cc3f803fbd0 100644 (file)
@@ -120,7 +120,7 @@ static void format_draw_color(char formatchar)
                case FMT_TYPE_WHITESPACE:
                        break;
                case FMT_TYPE_SYMBOL:
-                       UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f);
+                       UI_ThemeColor(TH_SYNTAX_S);
                        break;
                case FMT_TYPE_COMMENT:
                        UI_ThemeColor(TH_SYNTAX_C);
index 433ff0a035b3c21da70e8d0c0f693add188f5cd5..38903d65ec0f0a614d5b708a1c647c854bbe0deb 100644 (file)
@@ -154,8 +154,8 @@ static int txtfmt_osl_find_preprocessor(const char *string)
 {
        if (string[0] == '#') {
                int i = 1;
-               /* whitespace is ok '#  foo' */
-               while (string[i] == '\t' || string[i] == ' ') {
+               /* Whitespace is ok '#  foo' */
+               while (text_check_whitespace(string[i])) {
                        i++;
                }
                while (text_check_identifier(string[i])) {
@@ -166,24 +166,6 @@ static int txtfmt_osl_find_preprocessor(const char *string)
        return -1;
 }
 
-/* not in OSL, keep for now though */
-#if 0
-static int txtfmt_osl_find_bool(const char *string)
-{
-       int i, len;
-
-       if      (STR_LITERAL_STARTSWITH(string, "None",  len))  i = len;
-       else if (STR_LITERAL_STARTSWITH(string, "True",  len))  i = len;
-       else if (STR_LITERAL_STARTSWITH(string, "False", len))  i = len;
-       else                                                    i = 0;
-
-       /* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
-       if (i == 0 || text_check_identifier(string[i]))
-               return -1;
-       return i;
-}
-#endif
-
 static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const int do_next)
 {
        FlattenString fs;
index 02b67c3205235804de77c23303a0cc137222faf6..a78dabbfb9b81664030d1c961551024785360935 100644 (file)
@@ -127,8 +127,8 @@ static int txtfmt_py_find_decorator(const char *string)
 {
        if (string[0] == '@') {
                int i = 1;
-               /* whitespace is ok '@  foo' */
-               while (string[i] == '\t' || string[i] == ' ') {
+               /* Whitespace is ok '@  foo' */
+               while (text_check_whitespace(string[i])) {
                        i++;
                }
                while (text_check_identifier(string[i])) {
index 530caeca910a37abbad2ec161d591ea7960ae689..38848e30bf61e44acb900ee5c268850b8ccb1805 100644 (file)
@@ -246,12 +246,14 @@ typedef struct ThemeSpace {
        char vertex_size, outline_width, facedot_size;
        char noodle_curving;
 
-       char syntaxl[4], syntaxn[4], syntaxb[4]; /* syntax for textwindow and nodes */
+       /* syntax for textwindow and nodes */
+       char syntaxl[4], syntaxs[4];
+       char syntaxb[4], syntaxn[4];
        char syntaxv[4], syntaxc[4];
        char syntaxd[4], syntaxr[4];
        
        char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4];             /* for sequence editor */
-       char effect[4], hpad0[4], transition[4], meta[4];
+       char effect[4], transition[4], meta[4];
        char editmesh_active[4]; 
 
        char handle_vertex[4];
index 79d6a1d7d6b5e7d34c245b0df844a7bcec348a6c..21b81e3e16a16c7db33fe01df2bfe0140a388606 100644 (file)
@@ -1636,6 +1636,12 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Syntax Built-in", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
        
+       prop = RNA_def_property(srna, "syntax_symbols", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "syntaxs");
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Syntax Symbols", "");
+       RNA_def_property_update(prop, 0, "rna_userdef_update");
+
        prop = RNA_def_property(srna, "syntax_special", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "syntaxv");
        RNA_def_property_array(prop, 3);