diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-01 18:03:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-06 20:28:20 +0200 |
| commit | f09e17c3c564e8310125a10c03397cbf473ff643 (patch) | |
| tree | 8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /fluid/CodeEditor.cxx | |
| parent | b0e0c355edaa2e23148cb0260ada907aec930f05 (diff) | |
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files
The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
Diffstat (limited to 'fluid/CodeEditor.cxx')
| -rw-r--r-- | fluid/CodeEditor.cxx | 316 |
1 files changed, 155 insertions, 161 deletions
diff --git a/fluid/CodeEditor.cxx b/fluid/CodeEditor.cxx index 689f12855..4dd1cef96 100644 --- a/fluid/CodeEditor.cxx +++ b/fluid/CodeEditor.cxx @@ -1,6 +1,4 @@ // -// "$Id$" -// // Code editor widget for the Fast Light Tool Kit (FLTK). // // Copyright 1998-2016 by Bill Spitzak and others. @@ -9,11 +7,11 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems on the following page: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // // @@ -28,91 +26,91 @@ Fl_Text_Display::Style_Table_Entry CodeEditor:: - styletable[] = { // Style table - { FL_FOREGROUND_COLOR, FL_COURIER, 11 }, // A - Plain - { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // B - Line comments - { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // C - Block comments - { FL_BLUE, FL_COURIER, 11 }, // D - Strings - { FL_DARK_RED, FL_COURIER, 11 }, // E - Directives - { FL_DARK_RED, FL_COURIER_BOLD, 11 }, // F - Types - { FL_BLUE, FL_COURIER_BOLD, 11 } // G - Keywords - }; + styletable[] = { // Style table + { FL_FOREGROUND_COLOR, FL_COURIER, 11 }, // A - Plain + { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // B - Line comments + { FL_DARK_GREEN, FL_COURIER_ITALIC, 11 }, // C - Block comments + { FL_BLUE, FL_COURIER, 11 }, // D - Strings + { FL_DARK_RED, FL_COURIER, 11 }, // E - Directives + { FL_DARK_RED, FL_COURIER_BOLD, 11 }, // F - Types + { FL_BLUE, FL_COURIER_BOLD, 11 } // G - Keywords + }; const char * const CodeEditor:: - code_keywords[] = { // Sorted list of C/C++ keywords... - "and", - "and_eq", - "asm", - "bitand", - "bitor", - "break", - "case", - "catch", - "compl", - "continue", - "default", - "delete", - "do", - "else", - "false", - "for", - "goto", - "if", - "new", - "not", - "not_eq", - "operator", - "or", - "or_eq", - "return", - "switch", - "template", - "this", - "throw", - "true", - "try", - "while", - "xor", - "xor_eq" - }; + code_keywords[] = { // Sorted list of C/C++ keywords... + "and", + "and_eq", + "asm", + "bitand", + "bitor", + "break", + "case", + "catch", + "compl", + "continue", + "default", + "delete", + "do", + "else", + "false", + "for", + "goto", + "if", + "new", + "not", + "not_eq", + "operator", + "or", + "or_eq", + "return", + "switch", + "template", + "this", + "throw", + "true", + "try", + "while", + "xor", + "xor_eq" + }; const char * const CodeEditor:: - code_types[] = { // Sorted list of C/C++ types... - "auto", - "bool", - "char", - "class", - "const", - "const_cast", - "double", - "dynamic_cast", - "enum", - "explicit", - "extern", - "float", - "friend", - "inline", - "int", - "long", - "mutable", - "namespace", - "private", - "protected", - "public", - "register", - "short", - "signed", - "sizeof", - "static", - "static_cast", - "struct", - "template", - "typedef", - "typename", - "union", - "unsigned", - "virtual", - "void", - "volatile" - }; + code_types[] = { // Sorted list of C/C++ types... + "auto", + "bool", + "char", + "class", + "const", + "const_cast", + "double", + "dynamic_cast", + "enum", + "explicit", + "extern", + "float", + "friend", + "inline", + "int", + "long", + "mutable", + "namespace", + "private", + "protected", + "public", + "register", + "short", + "signed", + "sizeof", + "static", + "static_cast", + "struct", + "template", + "typedef", + "typename", + "union", + "unsigned", + "virtual", + "void", + "volatile" + }; // attempt to make the fluid code editor widget honour textsize setting void CodeEditor::textsize(Fl_Fontsize s) { @@ -134,12 +132,12 @@ extern "C" { // 'style_parse()' - Parse text and produce style data. void CodeEditor::style_parse(const char *text, char *style, int length) { - char current; - int col; - int last; - char buf[255], - *bufptr; - const char *temp; + char current; + int col; + int last; + char buf[255], + *bufptr; + const char *temp; // Style letters: // @@ -160,64 +158,64 @@ void CodeEditor::style_parse(const char *text, char *style, int length) { current = 'E'; } else if (strncmp(text, "//", 2) == 0) { current = 'B'; - for (; length > 0 && *text != '\n'; length --, text ++) *style++ = 'B'; + for (; length > 0 && *text != '\n'; length --, text ++) *style++ = 'B'; if (length == 0) break; } else if (strncmp(text, "/*", 2) == 0) { current = 'C'; } else if (strncmp(text, "\\\"", 2) == 0) { // Quoted quote... - *style++ = current; - *style++ = current; - text ++; - length --; - col += 2; - continue; + *style++ = current; + *style++ = current; + text ++; + length --; + col += 2; + continue; } else if (*text == '\"') { current = 'D'; } else if (!last && (islower(*text) || *text == '_')) { // Might be a keyword... - for (temp = text, bufptr = buf; - (islower(*temp) || *temp == '_') && bufptr < (buf + sizeof(buf) - 1); - *bufptr++ = *temp++) { - // nothing - } + for (temp = text, bufptr = buf; + (islower(*temp) || *temp == '_') && bufptr < (buf + sizeof(buf) - 1); + *bufptr++ = *temp++) { + // nothing + } if (!islower(*temp) && *temp != '_') { - *bufptr = '\0'; + *bufptr = '\0'; bufptr = buf; - if (bsearch(&bufptr, code_types, - sizeof(code_types) / sizeof(code_types[0]), - sizeof(code_types[0]), compare_keywords)) { - while (text < temp) { - *style++ = 'F'; - text ++; - length --; - col ++; - } - - text --; - length ++; - last = 1; - continue; - } else if (bsearch(&bufptr, code_keywords, - sizeof(code_keywords) / sizeof(code_keywords[0]), - sizeof(code_keywords[0]), compare_keywords)) { - while (text < temp) { - *style++ = 'G'; - text ++; - length --; - col ++; - } - - text --; - length ++; - last = 1; - continue; - } - } + if (bsearch(&bufptr, code_types, + sizeof(code_types) / sizeof(code_types[0]), + sizeof(code_types[0]), compare_keywords)) { + while (text < temp) { + *style++ = 'F'; + text ++; + length --; + col ++; + } + + text --; + length ++; + last = 1; + continue; + } else if (bsearch(&bufptr, code_keywords, + sizeof(code_keywords) / sizeof(code_keywords[0]), + sizeof(code_keywords[0]), compare_keywords)) { + while (text < temp) { + *style++ = 'G'; + text ++; + length --; + col ++; + } + + text --; + length ++; + last = 1; + continue; + } + } } } else if (current == 'C' && strncmp(text, "*/", 2) == 0) { // Close a C comment... @@ -232,18 +230,18 @@ void CodeEditor::style_parse(const char *text, char *style, int length) { // Continuing in string... if (strncmp(text, "\\\"", 2) == 0) { // Quoted end quote... - *style++ = current; - *style++ = current; - text ++; - length --; - col += 2; - continue; + *style++ = current; + *style++ = current; + text ++; + length --; + col += 2; + continue; } else if (*text == '\"') { // End quote... - *style++ = current; - col ++; - current = 'A'; - continue; + *style++ = current; + col ++; + current = 'A'; + continue; } } @@ -269,12 +267,12 @@ void CodeEditor::style_unfinished_cb(int, void*) { } void CodeEditor::style_update(int pos, int nInserted, int nDeleted, int /*nRestyled*/, const char * /*deletedText*/, void *cbArg) { - CodeEditor *editor = (CodeEditor *)cbArg; - int start, // Start of text - end; // End of text - char last, // Last style on line - *style, // Style data - *text; // Text data + CodeEditor *editor = (CodeEditor *)cbArg; + int start, // Start of text + end; // End of text + char last, // Last style on line + *style, // Style data + *text; // Text data // If this is just a selection change, just unselect the style buffer... @@ -360,7 +358,7 @@ int CodeEditor::auto_indent(int, CodeEditor* e) { char *ptr; for (ptr = text; isspace(*ptr); ptr ++) {/*empty*/} - *ptr = '\0'; + *ptr = '\0'; if (*text) { // use only a single 'insert' call to avoid redraw issues int n = strlen(text); @@ -394,7 +392,7 @@ CodeEditor::CodeEditor(int X, int Y, int W, int H, const char *L) : highlight_data(new Fl_Text_Buffer(mBuffer->length()), styletable, sizeof(styletable) / sizeof(styletable[0]), - 'A', style_unfinished_cb, this); + 'A', style_unfinished_cb, this); style_parse(text, style, mBuffer->length()); @@ -420,9 +418,9 @@ CodeEditor::~CodeEditor() { CodeViewer::CodeViewer(int X, int Y, int W, int H, const char *L) -: CodeEditor(X, Y, W, H, L) +: CodeEditor(X, Y, W, H, L) { - default_key_function(kf_ignore); + default_key_function(kf_ignore); remove_all_key_bindings(&key_bindings); cursor_style(CARET_CURSOR); } @@ -436,7 +434,3 @@ void CodeViewer::draw() CodeEditor::draw(); Fl::set_color(FL_SELECTION_COLOR, c); } - -// -// End of "$Id$". -// |
