diff options
| -rw-r--r-- | fluid/Fl_Type.cxx | 28 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 3 | ||||
| -rw-r--r-- | fluid/sourceview_panel.cxx | 69 | ||||
| -rw-r--r-- | fluid/sourceview_panel.fl | 78 | ||||
| -rw-r--r-- | fluid/sourceview_panel.h | 3 |
5 files changed, 150 insertions, 31 deletions
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index 6142a0beb..ecb109785 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -348,7 +348,6 @@ void update_visibility_flag(Fl_Type *p) { Constructor and base for any node in the widget tree. */ Fl_Type::Fl_Type() : -code_include_start(-1), code_include_end(-1), code_static_start(-1), code_static_end(-1), code1_start(-1), code1_end(-1), code2_start(-1), code2_end(-1), @@ -1024,5 +1023,32 @@ void Fl_Type::write_code1(Fd_Code_Writer& f) { void Fl_Type::write_code2(Fd_Code_Writer&) { } +/** Find a type node by using the sourceview text positions. + + \param[in] text_type 0=source file, 1=header, 2=.fl project file + \param[in] crsr cursor position in text + \return the node we found or NULL + */ +Fl_Type *Fl_Type::find_in_text(int text_type, int crsr) { + for (Fl_Type *node = first; node; node = node->next) { + switch (text_type) { + case 0: + if (crsr >= node->code1_start && crsr < node->code1_end) return node; + if (crsr >= node->code2_start && crsr < node->code2_end) return node; + if (crsr >= node->code_static_start && crsr < node->code_static_end) return node; + break; + case 1: + if (crsr >= node->header_start && crsr < node->header_end) return node; + if (crsr >= node->header_static_start && crsr < node->header_static_end) return node; + break; + case 2: + if (crsr >= node->proj1_start && crsr < node->proj1_end) return node; + if (crsr >= node->proj2_start && crsr < node->proj2_end) return node; + break; + } + } + return 0; +} + /// \} diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 0226696f5..1f7f689da 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -145,7 +145,6 @@ public: // things that should not be public: const char *callback_name(Fd_Code_Writer& f); // text positions of this type in code, header, and project file (see SourceView) - int code_include_start, code_include_end; int code_static_start, code_static_end; int code1_start, code1_end; int code2_start, code2_end; @@ -248,6 +247,8 @@ public: bool is_in_class() const; int has_function(const char*, const char*) const; + + static Fl_Type *find_in_text(int text_type, int crsr); }; #endif // _FLUID_FL_TYPE_H diff --git a/fluid/sourceview_panel.cxx b/fluid/sourceview_panel.cxx index bfee26654..804111c5e 100644 --- a/fluid/sourceview_panel.cxx +++ b/fluid/sourceview_panel.cxx @@ -26,6 +26,8 @@ static char *sv_source_filename = NULL; static char *sv_header_filename = NULL; static char *sv_design_filename = NULL; int sv_code_choice; +extern void select_only(Fl_Type *o); +extern void reveal_in_browser(Fl_Type *t); /** Update the header and source code highlighting depending on the @@ -261,6 +263,24 @@ TextViewer *sv_strings=(TextViewer *)0; TextViewer *sv_project=(TextViewer *)0; +static void cb_Reveal(Fl_Button*, void*) { + if (sourceview_panel && sourceview_panel->visible()) { + Fl_Type *node = NULL; + if (sv_source->visible_r()) + node = Fl_Type::find_in_text(0, sv_source->insert_position()); + else if (sv_header->visible_r()) + node = Fl_Type::find_in_text(1, sv_header->insert_position()); + else if (sv_project->visible_r()) + node = Fl_Type::find_in_text(2, sv_project->insert_position()); + if (node) { + select_only(node); + reveal_in_browser(node); + if (Fl::event_clicks()==1) // double click + node->open(); + } + } +} + Fl_Light_Button *sv_autorefresh=(Fl_Light_Button *)0; Fl_Light_Button *sv_autoposition=(Fl_Light_Button *)0; @@ -282,7 +302,7 @@ Fl_Menu_Item menu_sv_code_choice_w[] = { }; Fl_Double_Window* make_sourceview() { - { sourceview_panel = new Fl_Double_Window(520, 490, "Code View"); + { sourceview_panel = new Fl_Double_Window(520, 515, "Code View"); sourceview_panel->callback((Fl_Callback*)toggle_sourceview_cb); sourceview_panel->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE)); { sv_tab = new Fl_Tabs(10, 10, 500, 440); @@ -291,7 +311,8 @@ Fl_Double_Window* make_sourceview() { sv_tab->callback((Fl_Callback*)update_sourceview_position_cb); { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Source"); o->labelsize(13); - { CodeViewer* o = sv_source = new CodeViewer(20, 50, 480, 390); + o->hide(); + { CodeViewer* o = sv_source = new CodeViewer(10, 40, 500, 410); sv_source->box(FL_DOWN_FRAME); sv_source->color(FL_BACKGROUND2_COLOR); sv_source->selection_color(FL_SELECTION_COLOR); @@ -313,7 +334,7 @@ Fl_Double_Window* make_sourceview() { { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Header"); o->labelsize(13); o->hide(); - { CodeViewer* o = sv_header = new CodeViewer(20, 50, 480, 390); + { CodeViewer* o = sv_header = new CodeViewer(10, 40, 500, 410); sv_header->box(FL_DOWN_FRAME); sv_header->color(FL_BACKGROUND2_COLOR); sv_header->selection_color(FL_SELECTION_COLOR); @@ -334,7 +355,7 @@ Fl_Double_Window* make_sourceview() { { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Strings"); o->labelsize(13); o->hide(); - { TextViewer* o = sv_strings = new TextViewer(20, 50, 480, 390); + { TextViewer* o = sv_strings = new TextViewer(10, 40, 500, 410); sv_strings->box(FL_DOWN_FRAME); sv_strings->color(FL_BACKGROUND2_COLOR); sv_strings->selection_color(FL_SELECTION_COLOR); @@ -354,8 +375,7 @@ Fl_Double_Window* make_sourceview() { } // Fl_Group* o { Fl_Group* o = new Fl_Group(10, 35, 500, 415, "Project"); o->labelsize(13); - o->hide(); - { TextViewer* o = sv_project = new TextViewer(20, 50, 480, 390); + { TextViewer* o = sv_project = new TextViewer(10, 40, 500, 410); sv_project->box(FL_DOWN_FRAME); sv_project->color(FL_BACKGROUND2_COLOR); sv_project->selection_color(FL_SELECTION_COLOR); @@ -376,29 +396,52 @@ Fl_Double_Window* make_sourceview() { sv_tab->end(); Fl_Group::current()->resizable(sv_tab); } // Fl_Tabs* sv_tab - { Fl_Group* o = new Fl_Group(10, 460, 500, 22); - { Fl_Button* o = new Fl_Button(10, 460, 61, 20, "Refresh"); + { Fl_Group* o = new Fl_Group(10, 460, 500, 20); + { Fl_Button* o = new Fl_Button(244, 460, 25, 20, "aA"); + o->labelsize(11); + } // Fl_Button* o + { Fl_Button* o = new Fl_Button(273, 460, 25, 20, "<<"); + o->labelsize(11); + } // Fl_Button* o + { Fl_Button* o = new Fl_Button(298, 460, 25, 20, ">>"); + o->labelsize(11); + } // Fl_Button* o + { Fl_Button* o = new Fl_Button(327, 460, 61, 20, "Reveal"); + o->labelsize(11); + o->callback((Fl_Callback*)cb_Reveal); + } // Fl_Button* o + { Fl_Input* o = new Fl_Input(40, 460, 200, 20, "Find:"); + o->labelsize(11); + o->textsize(11); + } // Fl_Input* o + { Fl_Box* o = new Fl_Box(490, 460, 20, 20); + Fl_Group::current()->resizable(o); + } // Fl_Box* o + o->end(); + } // Fl_Group* o + { Fl_Group* o = new Fl_Group(10, 485, 500, 20); + { Fl_Button* o = new Fl_Button(10, 485, 61, 20, "Refresh"); o->labelsize(11); o->callback((Fl_Callback*)update_sourceview_cb); } // Fl_Button* o - { Fl_Light_Button* o = sv_autorefresh = new Fl_Light_Button(77, 460, 91, 20, "Auto-Refresh"); + { Fl_Light_Button* o = sv_autorefresh = new Fl_Light_Button(77, 485, 91, 20, "Auto-Refresh"); sv_autorefresh->labelsize(11); o->callback((Fl_Callback*)update_sourceview_cb); } // Fl_Light_Button* sv_autorefresh - { sv_autoposition = new Fl_Light_Button(172, 460, 89, 20, "Auto-Position"); + { sv_autoposition = new Fl_Light_Button(172, 485, 89, 20, "Auto-Position"); sv_autoposition->labelsize(11); } // Fl_Light_Button* sv_autoposition - { sv_code_choice_w = new Fl_Choice(265, 460, 70, 20); + { sv_code_choice_w = new Fl_Choice(265, 485, 70, 20); sv_code_choice_w->down_box(FL_BORDER_BOX); sv_code_choice_w->labelsize(11); sv_code_choice_w->textsize(11); sv_code_choice_w->callback((Fl_Callback*)cb_sv_code_choice_w); sv_code_choice_w->menu(menu_sv_code_choice_w); } // Fl_Choice* sv_code_choice_w - { Fl_Box* o = new Fl_Box(375, 460, 80, 20); + { Fl_Box* o = new Fl_Box(375, 485, 80, 20); Fl_Group::current()->resizable(o); } // Fl_Box* o - { Fl_Button* o = new Fl_Button(460, 460, 50, 20, "Close"); + { Fl_Button* o = new Fl_Button(460, 485, 50, 20, "Close"); o->labelsize(11); o->callback((Fl_Callback*)toggle_sourceview_b_cb); } // Fl_Button* o diff --git a/fluid/sourceview_panel.fl b/fluid/sourceview_panel.fl index 7f221c43e..6925a2057 100644 --- a/fluid/sourceview_panel.fl +++ b/fluid/sourceview_panel.fl @@ -47,6 +47,12 @@ decl {char *sv_design_filename = NULL;} {private local decl {int sv_code_choice;} {public local } +decl {extern void select_only(Fl_Type *o);} {private global +} + +decl {extern void reveal_in_browser(Fl_Type *t);} {private global +} + Function {update_sourceview_position()} { comment {Update the header and source code highlighting depending on the currently selected object @@ -272,18 +278,18 @@ Function {make_sourceview()} {open Fl_Window sourceview_panel { label {Code View} callback toggle_sourceview_cb open - xywh {400 569 520 490} type Double align 80 resizable size_range {384 120 0 0} visible + xywh {389 507 520 515} type Double align 80 resizable size_range {384 120 0 0} visible } { Fl_Tabs sv_tab { - callback update_sourceview_position_cb open selected + callback update_sourceview_position_cb open xywh {10 10 500 440} selection_color 4 labelcolor 7 resizable } { Fl_Group {} { label Source open - xywh {10 35 500 415} labelsize 13 resizable + xywh {10 35 500 415} labelsize 13 hide resizable } { Fl_Text_Editor sv_source { - xywh {20 50 480 390} textfont 4 textsize 11 resizable + xywh {10 40 500 410} textfont 4 textsize 11 resizable code0 {\#include "CodeEditor.h"} code1 {o->linenumber_width(60);} code2 {o->linenumber_size(o->Fl_Text_Display::textsize());} @@ -295,7 +301,7 @@ Function {make_sourceview()} {open xywh {10 35 500 415} labelsize 13 hide } { Fl_Text_Editor sv_header { - xywh {20 50 480 390} textfont 4 textsize 11 resizable + xywh {10 40 500 410} textfont 4 textsize 11 resizable code0 {\#include "CodeEditor.h"} code1 {o->linenumber_width(60);} code2 {o->linenumber_size(o->Fl_Text_Display::textsize());} @@ -307,7 +313,7 @@ Function {make_sourceview()} {open xywh {10 35 500 415} labelsize 13 hide } { Fl_Text_Display sv_strings { - xywh {20 50 480 390} textfont 4 textsize 11 resizable + xywh {10 40 500 410} textfont 4 textsize 11 resizable code1 {o->linenumber_width(60);} code2 {o->linenumber_size(o->Fl_Text_Display::textsize());} class TextViewer @@ -315,10 +321,10 @@ Function {make_sourceview()} {open } Fl_Group {} { label Project open - xywh {10 35 500 415} labelsize 13 hide + xywh {10 35 500 415} labelsize 13 } { Fl_Text_Display sv_project { - xywh {20 50 480 390} textfont 4 textsize 11 resizable + xywh {10 40 500 410} textfont 4 textsize 11 resizable code1 {o->linenumber_width(60);} code2 {o->linenumber_size(o->Fl_Text_Display::textsize());} class TextViewer @@ -326,26 +332,68 @@ Function {make_sourceview()} {open } } Fl_Group {} {open - xywh {10 460 500 22} + xywh {10 460 500 20} + } { + Fl_Button {} { + label aA + xywh {244 460 25 20} labelsize 11 + } + Fl_Button {} { + label {<<} + xywh {273 460 25 20} labelsize 11 + } + Fl_Button {} { + label {>>} + xywh {298 460 25 20} labelsize 11 + } + Fl_Button {} { + label Reveal + callback {if (sourceview_panel && sourceview_panel->visible()) { + Fl_Type *node = NULL; + if (sv_source->visible_r()) + node = Fl_Type::find_in_text(0, sv_source->insert_position()); + else if (sv_header->visible_r()) + node = Fl_Type::find_in_text(1, sv_header->insert_position()); + else if (sv_project->visible_r()) + node = Fl_Type::find_in_text(2, sv_project->insert_position()); + if (node) { + select_only(node); + reveal_in_browser(node); + if (Fl::event_clicks()==1) // double click + node->open(); + } +}} selected + xywh {327 460 61 20} labelsize 11 + } + Fl_Input {} { + label {Find:} + xywh {40 460 200 20} labelsize 11 textsize 11 + } + Fl_Box {} { + xywh {490 460 20 20} resizable + } + } + Fl_Group {} {open + xywh {10 485 500 20} } { Fl_Button {} { label Refresh callback update_sourceview_cb - xywh {10 460 61 20} labelsize 11 + xywh {10 485 61 20} labelsize 11 } Fl_Light_Button sv_autorefresh { label {Auto-Refresh} - xywh {77 460 91 20} labelsize 11 + xywh {77 485 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 + xywh {172 485 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 + xywh {265 485 70 20} down_box BORDER_BOX labelsize 11 textsize 11 } { MenuItem {} { label prolog @@ -374,12 +422,12 @@ update_sourceview_position();} open } } Fl_Box {} { - xywh {375 460 80 20} resizable + xywh {375 485 80 20} resizable } Fl_Button {} { label Close callback toggle_sourceview_b_cb - xywh {460 460 50 20} labelsize 11 + xywh {460 485 50 20} labelsize 11 } } } diff --git a/fluid/sourceview_panel.h b/fluid/sourceview_panel.h index 52b3a9566..0893fe395 100644 --- a/fluid/sourceview_panel.h +++ b/fluid/sourceview_panel.h @@ -38,12 +38,13 @@ extern CodeViewer *sv_header; extern TextViewer *sv_strings; extern TextViewer *sv_project; #include <FL/Fl_Button.H> +#include <FL/Fl_Input.H> +#include <FL/Fl_Box.H> #include <FL/Fl_Light_Button.H> extern Fl_Light_Button *sv_autorefresh; extern Fl_Light_Button *sv_autoposition; #include <FL/Fl_Choice.H> extern Fl_Choice *sv_code_choice_w; -#include <FL/Fl_Box.H> extern void toggle_sourceview_b_cb(Fl_Button*, void*); Fl_Double_Window* make_sourceview(); extern Fl_Menu_Item menu_sv_code_choice_w[]; |
