summaryrefslogtreecommitdiff
path: root/fluid/sourceview_panel.fl
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-10-24 14:28:56 +0200
committerMatthias Melcher <github@matthiasm.com>2023-10-24 14:29:01 +0200
commite8d218109e246b14df0cdf2d818e2575c8108e9f (patch)
tree64c3f3ae1acd99f81fd54d6391591663981c9b23 /fluid/sourceview_panel.fl
parent5a8a28cbb5fd627dfd032b996cd83d0965d9ac5e (diff)
FLUID: Adds much more detailed CodeView
in preparation for "find" and "reveal"
Diffstat (limited to 'fluid/sourceview_panel.fl')
-rw-r--r--fluid/sourceview_panel.fl121
1 files changed, 106 insertions, 15 deletions
diff --git a/fluid/sourceview_panel.fl b/fluid/sourceview_panel.fl
index 61f6242a9..7f221c43e 100644
--- a/fluid/sourceview_panel.fl
+++ b/fluid/sourceview_panel.fl
@@ -44,6 +44,9 @@ decl {char *sv_header_filename = NULL;} {private local
decl {char *sv_design_filename = NULL;} {private local
}
+decl {int sv_code_choice;} {public local
+}
+
Function {update_sourceview_position()} {
comment {Update the header and source code highlighting depending on the
currently selected object
@@ -60,27 +63,83 @@ file.} open return_type void
if (sourceview_panel && sourceview_panel->visible() && Fl_Type::current) {
int pos0, pos1;
if (sv_source->visible_r()) {
- pos0 = Fl_Type::current->code_position;
- pos1 = Fl_Type::current->code_position_end;
+ switch (sv_code_choice) {
+ case 0: // prolog: not yet (include statements)
+ pos0 = Fl_Type::current->code1_start;
+ pos1 = Fl_Type::current->code2_end;
+ break;
+ case 1: // static: callbacks, menu declarations
+ pos0 = Fl_Type::current->code_static_start;
+ pos1 = Fl_Type::current->code_static_end;
+ break;
+ case 2: // code: entire implementation block including children
+ pos0 = Fl_Type::current->code1_start;
+ pos1 = Fl_Type::current->code2_end;
+ break;
+ case 3: // code1: all implementation code before the children
+ pos0 = Fl_Type::current->code1_start;
+ pos1 = Fl_Type::current->code1_end;
+ break;
+ case 4: // code1: all implementation code before the children
+ pos0 = Fl_Type::current->code2_start;
+ pos1 = Fl_Type::current->code2_end;
+ break;
+ }
if (pos0>=0) {
if (pos1<pos0)
- pos1 = pos0;
+ pos1 = sv_source->buffer()->line_end(pos0);
sv_source->buffer()->highlight(pos0, pos1);
int line = sv_source->buffer()->count_lines(0, pos0);
sv_source->scroll(line, 0);
}
}
if (sv_header->visible_r()) {
- pos0 = Fl_Type::current->header_position;
- pos1 = Fl_Type::current->header_position_end;
+ switch (sv_code_choice) {
+ case 2: // code: entire implementation block including children
+ case 3: // code1: all implementation code before the children
+ case 4: // code1: all implementation code before the children
+ pos0 = Fl_Type::current->header_start;
+ pos1 = Fl_Type::current->header_end;
+ break;
+ case 0: // prolog: not yet (include statements)
+ case 1: // static: callbacks, menu declarations
+ pos0 = Fl_Type::current->header_static_start;
+ pos1 = Fl_Type::current->header_static_end;
+ break;
+ }
if (pos0>=0) {
if (pos1<pos0)
- pos1 = pos0;
+ pos1 = sv_header->buffer()->line_end(pos0);
sv_header->buffer()->highlight(pos0, pos1);
int line = sv_header->buffer()->count_lines(0, pos0);
sv_header->scroll(line, 0);
}
}
+ if (sv_project->visible_r()) {
+ switch (sv_code_choice) {
+ case 0: // prolog: not yet (include statements)
+ case 1: // static: callbacks, menu declarations
+ case 2: // code: entire implementation block including children
+ pos0 = Fl_Type::current->proj1_start;
+ pos1 = Fl_Type::current->proj2_end;
+ break;
+ case 3: // code1: all implementation code before the children
+ pos0 = Fl_Type::current->proj1_start;
+ pos1 = Fl_Type::current->proj1_end;
+ break;
+ case 4: // code1: all implementation code before the children
+ pos0 = Fl_Type::current->proj2_start;
+ pos1 = Fl_Type::current->proj2_end;
+ break;
+ }
+ if (pos0>=0) {
+ if (pos1<pos0)
+ pos1 = sv_project->buffer()->line_end(pos0);
+ sv_project->buffer()->highlight(pos0, pos1);
+ int line = sv_project->buffer()->count_lines(0, pos0);
+ sv_project->scroll(line, 0);
+ }
+ }
}} {}
}
@@ -117,7 +176,7 @@ and load those into the Code Viewer widgets.} open return_type void
}
if (sv_project->visible_r()) {
- write_file(sv_design_filename);
+ write_file(sv_design_filename, false, true);
int top = sv_project->top_line();
sv_project->buffer()->loadfile(sv_design_filename);
sv_project->scroll(top, 0);
@@ -156,8 +215,7 @@ and load those into the Code Viewer widgets.} open return_type void
g_project.code_file_name = code_file_name_bak;
g_project.header_file_name = header_file_name_bak;
- }} {selected
- }
+ }} {}
}
Function {update_sourceview_timer(void*)} {
@@ -194,6 +252,8 @@ The state is stored in the app preferences.
int tab;
svp.get("tab", tab, 0);
if (tab>=0 && tab<sv_tab->children()) sv_tab->value(sv_tab->child(tab));
+ svp.get("code_choice", sv_code_choice, 2);
+ sv_code_choice_w->value(sv_code_choice_w->find_item_with_argument(sv_code_choice));
if (!position_window(sourceview_panel,"sourceview_pos", 0, 320, 120, 550, 500)) return;
}
@@ -215,7 +275,7 @@ Function {make_sourceview()} {open
xywh {400 569 520 490} type Double align 80 resizable size_range {384 120 0 0} visible
} {
Fl_Tabs sv_tab {
- callback update_sourceview_position_cb open
+ callback update_sourceview_position_cb open selected
xywh {10 10 500 440} selection_color 4 labelcolor 7 resizable
} {
Fl_Group {} {
@@ -266,7 +326,7 @@ Function {make_sourceview()} {open
}
}
Fl_Group {} {open
- xywh {10 460 500 20}
+ xywh {10 460 500 22}
} {
Fl_Button {} {
label Refresh
@@ -275,21 +335,52 @@ Function {make_sourceview()} {open
}
Fl_Light_Button sv_autorefresh {
label {Auto-Refresh}
- xywh {76 460 91 20} labelsize 11
+ xywh {77 460 91 20} labelsize 11
code0 {o->callback((Fl_Callback*)update_sourceview_cb);}
}
Fl_Light_Button sv_autoposition {
label {Auto-Position}
xywh {172 460 89 20} labelsize 11
}
+ Fl_Choice sv_code_choice_w {
+ callback {sv_code_choice = (int)o->mvalue()->argument();
+update_sourceview_position();} open
+ xywh {265 460 70 20} down_box BORDER_BOX labelsize 11 textsize 11
+ } {
+ MenuItem {} {
+ label prolog
+ user_data 0 user_data_type long
+ tooltip {Include statements in header or source code} xywh {0 0 100 20} labelsize 11 hide
+ }
+ MenuItem {} {
+ label static
+ user_data 1 user_data_type long
+ tooltip {static declarations in source code} xywh {10 10 100 20} labelsize 11
+ }
+ MenuItem {} {
+ label code
+ user_data 2 user_data_type long
+ tooltip {widget code block including children} xywh {20 20 100 20} labelsize 11
+ }
+ MenuItem {} {
+ label {code 1}
+ user_data 3 user_data_type long
+ tooltip {widget code block before children} xywh {30 30 100 20} labelsize 11
+ }
+ MenuItem {} {
+ label {code 2}
+ user_data 4 user_data_type long
+ tooltip {widget code block after children} xywh {40 40 100 20} labelsize 11
+ }
+ }
+ Fl_Box {} {
+ xywh {375 460 80 20} resizable
+ }
Fl_Button {} {
label Close
callback toggle_sourceview_b_cb
xywh {460 460 50 20} labelsize 11
}
- Fl_Box {} {
- xywh {265 460 190 20} resizable
- }
}
}
}