ecere/gui/EditBox: (#670) Refined numbers syntax highlighting
authorJerome St-Louis <jerome@ecere.com>
Wed, 7 Aug 2013 23:58:52 +0000 (19:58 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 7 Aug 2013 23:58:52 +0000 (19:58 -0400)
- Fixed problems with previous commit, including expression members dots being colorized as numbers

ecere/src/gui/controls/EditBox.ec

index b3981bc..b35231c 100644 (file)
@@ -1720,25 +1720,27 @@ private:
                            if(!wasEscaped)
                               escaped = true;
                         }
-                        else if(!inQuotes && !inString && !inMultiLineComment && !inSingleLineComment && 
-                           ( ( isdigit(word[0]) /*&& (!c || word[-1] == ' ' || word[-1] == '\t')*/ ) || (word[0] == '.' /*&& isdigit(word[1])*/ )))
+                        else if(!inQuotes && !inString && !inMultiLineComment && !inSingleLineComment && (isdigit(word[0]) || word[0] == '.'))
                         {
+                           char * dot = strchr(word, '.');
                            char * s = null;
-                           strtod(word, &s);
+                           if(dot)
+                              strtod(dot+1, &s);
+                           else
+                              strtod(word, &s);
                            if(s)
                            {
-                              if(*s == 'f')
+                              if(dot && *s == 'f' && !isalnum(s[1]))
                               {
-                                 if(strchr(word, '.'))
-                                 {
-                                    int newWordLen = s + 1 - word;
-                                    newTextColor = colorScheme.numberColor;
-                                    c += newWordLen - wordLen;
-                                    wordLen = newWordLen;
-                                 }
+                                 int newWordLen = s + 1 - word;
+                                 newTextColor = colorScheme.numberColor;
+                                 c += newWordLen - wordLen;
+                                 wordLen = newWordLen;
                               }
                               else if(!isalpha(*s))
                                  newTextColor = colorScheme.numberColor;
+                              else if(dot && dot > word && isalpha(dot[1]))
+                                 newTextColor = colorScheme.numberColor;
                            }
                         }
                         else