diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-23 03:13:31 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-03-23 03:13:31 +0000 |
| commit | 325dc85b2c756d13b329dba4541fcb35feabdda9 (patch) | |
| tree | 839c3947afa9d2cc2f53c5fa9d1846dd3f0a19e5 /fluid/CodeEditor.cxx | |
| parent | f0c00448b01eecd86d438f46ede20e8ab100a3f5 (diff) | |
Fix syntax highlighting bug in the editor demo, and port changes to the
CodeEditor widget in FLUID.
Use the CodeEditor widget for the other code windows.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4163 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/CodeEditor.cxx')
| -rw-r--r-- | fluid/CodeEditor.cxx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/fluid/CodeEditor.cxx b/fluid/CodeEditor.cxx index 926f30506..f979ce107 100644 --- a/fluid/CodeEditor.cxx +++ b/fluid/CodeEditor.cxx @@ -138,8 +138,18 @@ void CodeEditor::style_parse(const char *text, char *style, int length) { *bufptr; const char *temp; + // Style letters: + // + // A - Plain + // B - Line comments + // C - Block comments + // D - Strings + // E - Directives + // F - Types + // G - Keywords + for (current = *style, col = 0, last = 0; length > 0; length --, text ++) { - if (current == 'B') current = 'A'; + if (current == 'B' || current == 'F' || current == 'G') current = 'A'; if (current == 'A') { // Check for directives, comments, strings, and keywords... if (col == 0 && *text == '#') { @@ -162,13 +172,13 @@ void CodeEditor::style_parse(const char *text, char *style, int length) { continue; } else if (*text == '\"') { current = 'D'; - } else if (!last && islower(*text)) { + } else if (!last && (islower(*text) || *text == '_')) { // Might be a keyword... for (temp = text, bufptr = buf; - islower(*temp) && bufptr < (buf + sizeof(buf) - 1); + (islower(*temp) || *temp == '_') && bufptr < (buf + sizeof(buf) - 1); *bufptr++ = *temp++); - if (!islower(*temp)) { + if (!islower(*temp) && *temp != '_') { *bufptr = '\0'; bufptr = buf; @@ -237,7 +247,7 @@ void CodeEditor::style_parse(const char *text, char *style, int length) { else *style++ = current; col ++; - last = isalnum(*text) || *text == '.'; + last = isalnum(*text) || *text == '_' || *text == '.'; if (*text == '\n') { // Reset column and possibly reset the style |
