summaryrefslogtreecommitdiff
path: root/fluid/panels/widget_panel.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'fluid/panels/widget_panel.cxx')
-rw-r--r--fluid/panels/widget_panel.cxx103
1 files changed, 47 insertions, 56 deletions
diff --git a/fluid/panels/widget_panel.cxx b/fluid/panels/widget_panel.cxx
index 897cec6cc..1f60bc178 100644
--- a/fluid/panels/widget_panel.cxx
+++ b/fluid/panels/widget_panel.cxx
@@ -32,7 +32,7 @@
#include <FL/Fl_File_Chooser.H>
#include <ctype.h>
#include <stdlib.h> // free()
-#include <functional> // std::function
+#include <string.h>
#define ZERO_ENTRY 1000
extern const char* when_symbol_name(int n);
extern void set_whenmenu(int n);
@@ -57,37 +57,6 @@ static int use_tab_navigation(int, Fl_Text_Editor*) {
//fl ▲ ----------~~-~=---~-------------~-=--~~-=~=-~~--~-~=-- ▲ fl//
}
-static void update_current(Fl_Input* o, void *v,
- std::function<std::string()> getter,
- std::function<void(std::string)> setter) {
-//fl ▼ ------------------------ code --~---=~--=-=-=---~=~~=~ ▼ fl//
- if (v == LOAD) {
- o->value( getter().c_str() );
- } else {
- std::string v = o->value();
- if (v != getter()) {
- setter(v);
- Fluid.proj.set_modflag(1);
- }
- }
-//fl ▲ ----------~~~=~---=~-------------~=-~--~=~~-=--=-==~-= ▲ fl//
-}
-
-static void update_current(Fl_Text_Editor* o, void *v,
- std::function<std::string()> getter,
- std::function<void(std::string)> setter) {
-//fl ▼ ------------------------ code ----~-~-=~~~~=-~-==--~-- ▼ fl//
- if (v == LOAD) {
- o->buffer()->text( getter().c_str() );
- } else {
- std::string v = o->buffer()->text();
- if (v != getter()) {
- setter(v);
- Fluid.proj.set_modflag(1);
- }
- }
-//fl ▲ ----------~~-=-~=--=-=----------~-~~=-~-~~-~~==~~--=~- ▲ fl//
-}
Fl_Double_Window *image_panel_window=(Fl_Double_Window *)0;
@@ -2619,10 +2588,15 @@ static void cb_wp_data_filename(Fl_Input* o, void* v) {
//fl ▼ ---------------------- callback ~-~=~~~~~~-=~~=~-==--- ▼ fl//
if (!current_node || !current_node->is_a(FLD_NODE_TYPE_Data)) return;
Data_Node* nd = (Data_Node*)current_node;
- update_current(o, v,
- [nd](){return nd->filename();},
- [nd](std::string s){nd->filename(s);}
- );
+ if (v == LOAD) {
+ o->value(nd->filename());
+ } else {
+ const char *val = o->value();
+ if (strcmp(val ? val : "", nd->filename()) != 0) {
+ nd->filename(val);
+ Fluid.proj.set_modflag(1);
+ }
+ }
//fl ▲ ----------~=-~--=--~------------~-~==--==-~=---==--~-~ ▲ fl//
}
@@ -2885,12 +2859,13 @@ static void cb_Attribute(Fl_Input* o, void* v) {
Class_Node* nd = (Class_Node*)current_node;
if (v == LOAD) {
- o->value( nd->prefix().c_str() );
+ o->value( nd->prefix() );
} else {
- auto nn = nd->prefix();
- if (nn != o->value())
+ const char *nn = nd->prefix();
+ const char *ov = o->value();
+ if (strcmp(nn ? nn : "", ov ? ov : "") != 0)
{
- nd->prefix( o->value() );
+ nd->prefix( ov );
Fluid.proj.set_modflag(1);
}
}
@@ -2948,11 +2923,12 @@ static void cb_Base(Fl_Input* o, void* v) {
Class_Node* nd = (Class_Node*)current_node;
if (v == LOAD) {
- o->value( nd->base_class().c_str() );
+ o->value( nd->base_class() );
} else {
- auto nn = nd->base_class();
- if (nn != o->value()) {
- nd->base_class( o->value() );
+ const char *nn = nd->base_class();
+ const char *ov = o->value();
+ if (strcmp(nn ? nn : "", ov ? ov : "") != 0) {
+ nd->base_class( ov );
Fluid.proj.set_modflag(1);
}
}
@@ -3018,10 +2994,15 @@ static void cb_End(Fl_Input* o, void* v) {
//fl ▼ ---------------------- callback -~-~--~-----=-~~~~~=-~ ▼ fl//
if (!current_node || !current_node->is_a(FLD_NODE_TYPE_DeclBlock)) return;
DeclBlock_Node* nd = (DeclBlock_Node*)current_node;
- update_current(o, v,
- [nd](){return nd->end_code();},
- [nd](std::string s){nd->end_code(s);}
- );
+ if (v == LOAD) {
+ o->value(nd->end_code());
+ } else {
+ const char *val = o->value();
+ if (strcmp(val ? val : "", nd->end_code()) != 0) {
+ nd->end_code(val);
+ Fluid.proj.set_modflag(1);
+ }
+ }
//fl ▲ ----------=~~~~~~=~-=-------------=~--~=~--=~~~=~~-~~= ▲ fl//
}
@@ -3295,10 +3276,15 @@ static void cb_End1(Fl_Input* o, void* v) {
//fl ▼ ---------------------- callback ~~-~~=~=-~=-~-=~~~=-=~ ▼ fl//
if (!current_node || !current_node->is_a(FLD_NODE_TYPE_CodeBlock)) return;
CodeBlock_Node* nd = (CodeBlock_Node*)current_node;
- update_current(o, v,
- [nd](){return nd->end_code();},
- [nd](std::string s){nd->end_code(s);}
- );
+ if (v == LOAD) {
+ o->value(nd->end_code());
+ } else {
+ const char *val = o->value();
+ if (strcmp(val ? val : "", nd->end_code()) != 0) {
+ nd->end_code(val);
+ Fluid.proj.set_modflag(1);
+ }
+ }
//fl ▲ ----------~=----=-~-=~----------~~~~-~-=~--=-=~~=---~~ ▲ fl//
}
@@ -3487,10 +3473,15 @@ static void cb_Return(fld::widget::Code_Editor* o, void* v) {
//fl ▼ ---------------------- callback -~=--~-~=~=~~~---=~~=~ ▼ fl//
if (!current_node || !current_node->is_a(FLD_NODE_TYPE_Function)) return;
Function_Node* nd = (Function_Node*)current_node;
- update_current(o, v,
- [nd](){return nd->return_type();},
- [nd](std::string s){nd->return_type(s);}
- );
+ if (v == LOAD) {
+ o->buffer()->text(nd->return_type());
+ } else {
+ const char *val = o->buffer()->text();
+ if (strcmp(val ? val : "", nd->return_type()) != 0) {
+ nd->return_type(val);
+ Fluid.proj.set_modflag(1);
+ }
+ }
//fl ▲ ----------~=~~=~~==~~-----------~~=~=-~=~-~-~-=~-=~--~ ▲ fl//
}