summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-03-23 03:13:31 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-03-23 03:13:31 +0000
commit325dc85b2c756d13b329dba4541fcb35feabdda9 (patch)
tree839c3947afa9d2cc2f53c5fa9d1846dd3f0a19e5 /fluid
parentf0c00448b01eecd86d438f46ede20e8ab100a3f5 (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')
-rw-r--r--fluid/CodeEditor.cxx20
-rw-r--r--fluid/function_panel.cxx30
-rw-r--r--fluid/function_panel.fl23
-rw-r--r--fluid/function_panel.h6
4 files changed, 50 insertions, 29 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
diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx
index e4d77bb78..01923e069 100644
--- a/fluid/function_panel.cxx
+++ b/fluid/function_panel.cxx
@@ -99,7 +99,7 @@ Fl_Window* make_function_panel() {
Fl_Window *code_panel=(Fl_Window *)0;
-Fl_Text_Editor *code_input=(Fl_Text_Editor *)0;
+CodeEditor *code_input=(CodeEditor *)0;
Fl_Return_Button *code_panel_ok=(Fl_Return_Button *)0;
@@ -110,13 +110,19 @@ Fl_Window* make_code_panel() {
{ Fl_Window* o = code_panel = new Fl_Window(545, 175, "Code Properties");
w = o;
o->labelsize(11);
- { Fl_Text_Editor* o = code_input = new Fl_Text_Editor(10, 12, 525, 123);
+ { CodeEditor* o = code_input = new CodeEditor(10, 12, 525, 123);
o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
o->labelsize(11);
+ o->labelcolor(FL_BLACK);
+ o->textfont(4);
o->textsize(11);
+ o->align(FL_ALIGN_TOP);
+ o->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(o);
- o->buffer(new Fl_Text_Buffer);
- o->textfont(FL_COURIER);
o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);
}
{ Fl_Group* o = new Fl_Group(12, 145, 523, 20);
@@ -340,7 +346,7 @@ Fl_Window* make_class_panel() {
Fl_Window *comment_panel=(Fl_Window *)0;
-Fl_Text_Editor *comment_input=(Fl_Text_Editor *)0;
+CodeEditor *comment_input=(CodeEditor *)0;
Fl_Return_Button *comment_panel_ok=(Fl_Return_Button *)0;
@@ -359,13 +365,19 @@ Fl_Window* make_comment_panel() {
{ Fl_Window* o = comment_panel = new Fl_Window(545, 285, "Comment Properties");
w = o;
o->labelsize(11);
- { Fl_Text_Editor* o = comment_input = new Fl_Text_Editor(95, 10, 438, 241);
+ { CodeEditor* o = comment_input = new CodeEditor(95, 10, 438, 241);
o->box(FL_DOWN_BOX);
+ o->color(FL_BACKGROUND2_COLOR);
+ o->selection_color(FL_SELECTION_COLOR);
+ o->labeltype(FL_NORMAL_LABEL);
+ o->labelfont(0);
o->labelsize(11);
+ o->labelcolor(FL_BLACK);
+ o->textfont(4);
o->textsize(11);
+ o->align(FL_ALIGN_TOP);
+ o->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(o);
- o->buffer(new Fl_Text_Buffer);
- o->textfont(FL_COURIER);
o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);
}
{ Fl_Group* o = new Fl_Group(368, 255, 167, 25);
@@ -432,7 +444,7 @@ Fl_Window *widgetbin_panel=(Fl_Window *)0;
Fl_Window* make_widgetbin() {
Fl_Window* w;
- { Fl_Window* o = widgetbin_panel = new Fl_Window(490, 100, "Widget Bin");
+ { Fl_Window* o = widgetbin_panel = new Fl_Window(485, 100, "Widget Bin");
w = o;
{ Fl_Group* o = new Fl_Group(3, 3, 74, 74);
o->box(FL_THIN_DOWN_BOX);
diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl
index 900eefd13..ae0275934 100644
--- a/fluid/function_panel.fl
+++ b/fluid/function_panel.fl
@@ -83,10 +83,10 @@ Function {make_code_panel()} {open
xywh {527 128 545 175} type Single labelsize 11 hide resizable modal
} {
Fl_Text_Editor code_input {
- xywh {10 12 525 123} box DOWN_BOX labelsize 11 textsize 11 resizable
- code0 {o->buffer(new Fl_Text_Buffer);}
- code1 {o->textfont(FL_COURIER);}
- code2 {o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);}
+ xywh {10 12 525 123} box DOWN_BOX labelsize 11 textfont 4 textsize 11 resizable
+ code0 {o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);}
+ code1 {\#include "CodeEditor.h"}
+ class CodeEditor
}
Fl_Group {} {open
xywh {12 145 523 20} labelsize 11
@@ -218,11 +218,10 @@ Function {make_comment_panel()} {open
label {Comment Properties}
xywh {328 152 545 285} type Single labelsize 11 hide resizable modal
} {
- Fl_Text_Editor comment_input {
- xywh {95 10 438 241} box DOWN_BOX labelsize 11 textsize 11 resizable
- code0 {o->buffer(new Fl_Text_Buffer);}
- code1 {o->textfont(FL_COURIER);}
- code2 {o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);}
+ Fl_Text_Editor comment_input {selected
+ xywh {95 10 438 241} box DOWN_BOX labelsize 11 textfont 4 textsize 11 resizable
+ code0 {o->when(FL_WHEN_ENTER_KEY_CHANGED|FL_WHEN_RELEASE);}
+ class CodeEditor
}
Fl_Group {} {open
xywh {368 255 167 25} labelsize 11
@@ -283,8 +282,8 @@ Function {make_widgetbin()} {open
} {
Fl_Window widgetbin_panel {
label {Widget Bin} open
- xywh {385 53 485 100} type Single
- code0 {o->size(o->w(),80);} non_modal visible
+ xywh {385 53 485 100} type Single hide
+ code0 {o->size(o->w(),80);} non_modal
} {
Fl_Group {} {open
xywh {3 3 74 74} box THIN_DOWN_BOX
@@ -551,7 +550,7 @@ Function {make_widgetbin()} {open
}
Fl_Button {} {
user_data {"Fl_Input_Choice"}
- callback type_make_cb selected
+ callback type_make_cb
tooltip {Input Choice} xywh {384 4 24 24} box THIN_UP_BOX
code0 {o->image(pixmap[15]);}
}
diff --git a/fluid/function_panel.h b/fluid/function_panel.h
index 2fcb01340..9f3b86277 100644
--- a/fluid/function_panel.h
+++ b/fluid/function_panel.h
@@ -44,8 +44,8 @@ extern Fl_Return_Button *f_panel_ok;
extern Fl_Button *f_panel_cancel;
Fl_Window* make_function_panel();
extern Fl_Window *code_panel;
-#include <FL/Fl_Text_Editor.H>
-extern Fl_Text_Editor *code_input;
+#include "CodeEditor.h"
+extern CodeEditor *code_input;
#include <FL/Fl_Group.H>
extern Fl_Return_Button *code_panel_ok;
extern Fl_Button *code_panel_cancel;
@@ -78,7 +78,7 @@ extern Fl_Return_Button *c_panel_ok;
extern Fl_Button *c_panel_cancel;
Fl_Window* make_class_panel();
extern Fl_Window *comment_panel;
-extern Fl_Text_Editor *comment_input;
+extern CodeEditor *comment_input;
extern Fl_Return_Button *comment_panel_ok;
extern Fl_Button *comment_panel_cancel;
extern Fl_Light_Button *comment_in_source;