Replce Fl_String in Fluid with std::string.

Also fix for Linux.
This commit is contained in:
Matthias Melcher
2025-03-07 00:48:18 +01:00
parent 3068c7a0af
commit 9cfd932d3a
21 changed files with 195 additions and 196 deletions
+2 -2
View File
@@ -601,9 +601,9 @@ needs no additional maintenance. It is also C++98 compatible. For example:
\code \code
#include <FL/fl_callback_macros.H> #include <FL/fl_callback_macros.H>
... ...
Fl_String *str = new Fl_String("FLTK"); std::string *str = new std::string("FLTK");
Fl_Button *btn = new Fl_Button(10, 10, 100, 100); Fl_Button *btn = new Fl_Button(10, 10, 100, 100);
FL_METHOD_CALLBACK_2(btn, Fl_String, str, insert, int, 2, const char*, "..."); FL_METHOD_CALLBACK_2(btn, std::string, str, insert, int, 2, const char*, "...");
... ...
Fl_Button *inline_cb_btn_2 = new Fl_Button(390, 60, 180, 25, "2 args"); Fl_Button *inline_cb_btn_2 = new Fl_Button(390, 60, 180, 25, "2 args");
FL_INLINE_CALLBACK_2( inline_cb_btn_2, FL_INLINE_CALLBACK_2( inline_cb_btn_2,
+1 -1
View File
@@ -24,7 +24,7 @@ class ExternalCodeEditor {
time_t file_mtime_; // last modify time of the file (used to determine if file changed) time_t file_mtime_; // last modify time of the file (used to determine if file changed)
size_t file_size_; // last file size (used to determine if changed) size_t file_size_; // last file size (used to determine if changed)
const char *filename_; const char *filename_;
Fl_String command_line_; std::string command_line_;
int last_error_; int last_error_;
int alert_pipe_[2]; int alert_pipe_[2];
bool alert_pipe_open_; bool alert_pipe_open_;
+6 -7
View File
@@ -18,7 +18,6 @@
#include "Fl_Group_Type.h" #include "Fl_Group_Type.h"
#include "settings_panel.h" #include "settings_panel.h"
#include "shell_command.h" // get and set Fl_String preferences
#include "file.h" #include "file.h"
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
@@ -388,7 +387,7 @@ void Fd_Layout_Suite::read(Fd_Project_Reader *in) {
Also updates the FLUID user interface. Also updates the FLUID user interface.
*/ */
void Fd_Layout_Suite::update_label() { void Fd_Layout_Suite::update_label() {
Fl_String sym; std::string sym;
switch (storage_) { switch (storage_) {
case FD_STORE_INTERNAL: sym.assign("@fd_beaker "); break; case FD_STORE_INTERNAL: sym.assign("@fd_beaker "); break;
case FD_STORE_USER: sym.assign("@fd_user "); break; case FD_STORE_USER: sym.assign("@fd_user "); break;
@@ -650,7 +649,7 @@ void Fd_Layout_List::update_menu_labels() {
/** /**
Load all user layouts from the FLUID user preferences. Load all user layouts from the FLUID user preferences.
*/ */
int Fd_Layout_List::load(const Fl_String &filename) { int Fd_Layout_List::load(const std::string &filename) {
remove_all(FD_STORE_FILE); remove_all(FD_STORE_FILE);
Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, Fl_Preferences::C_LOCALE); Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, Fl_Preferences::C_LOCALE);
read(prefs, FD_STORE_FILE); read(prefs, FD_STORE_FILE);
@@ -660,7 +659,7 @@ int Fd_Layout_List::load(const Fl_String &filename) {
/** /**
Save all user layouts to the FLUID user preferences. Save all user layouts to the FLUID user preferences.
*/ */
int Fd_Layout_List::save(const Fl_String &filename) { int Fd_Layout_List::save(const std::string &filename) {
assert(this); assert(this);
Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR)); Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::CLEAR));
prefs.clear(); prefs.clear();
@@ -691,7 +690,7 @@ void Fd_Layout_List::write(Fl_Preferences &prefs, Fd_Tool_Store storage) {
*/ */
void Fd_Layout_List::read(Fl_Preferences &prefs, Fd_Tool_Store storage) { void Fd_Layout_List::read(Fl_Preferences &prefs, Fd_Tool_Store storage) {
Fl_Preferences prefs_list(prefs, "Layouts"); Fl_Preferences prefs_list(prefs, "Layouts");
Fl_String cs; std::string cs;
int cp = 0; int cp = 0;
preferences_get(prefs_list, "current_suite", cs, ""); preferences_get(prefs_list, "current_suite", cs, "");
prefs_list.get("current_preset", cp, 0); prefs_list.get("current_preset", cp, 0);
@@ -741,7 +740,7 @@ void Fd_Layout_List::read(Fd_Project_Reader *in) {
const char *key; const char *key;
key = in->read_word(1); key = in->read_word(1);
if (key && !strcmp(key, "{")) { if (key && !strcmp(key, "{")) {
Fl_String cs; std::string cs;
int cp = 0; int cp = 0;
for (;;) { for (;;) {
key = in->read_word(); key = in->read_word();
@@ -786,7 +785,7 @@ void Fd_Layout_List::current_suite(int ix) {
\param[in] arg_name name of the selected suite \param[in] arg_name name of the selected suite
\return if no name is given or the name is not found, keep the current suite selected \return if no name is given or the name is not found, keep the current suite selected
*/ */
void Fd_Layout_List::current_suite(Fl_String arg_name) { void Fd_Layout_List::current_suite(std::string arg_name) {
if (arg_name.empty()) return; if (arg_name.empty()) return;
for (int i = 0; i < list_size_; ++i) { for (int i = 0; i < list_size_; ++i) {
Fd_Layout_Suite &suite = list_[i]; Fd_Layout_Suite &suite = list_[i];
+4 -4
View File
@@ -119,7 +119,7 @@ public:
bool list_is_static_; bool list_is_static_;
int current_suite_; int current_suite_;
int current_preset_; int current_preset_;
Fl_String filename_; std::string filename_;
public: public:
Fd_Layout_List(); Fd_Layout_List();
~Fd_Layout_List(); ~Fd_Layout_List();
@@ -127,7 +127,7 @@ public:
void update_menu_labels(); void update_menu_labels();
int current_suite() const { return current_suite_; } int current_suite() const { return current_suite_; }
void current_suite(int ix); void current_suite(int ix);
void current_suite(Fl_String); void current_suite(std::string);
int current_preset() const { return current_preset_; } int current_preset() const { return current_preset_; }
void current_preset(int ix); void current_preset(int ix);
Fd_Layout_Suite &operator[](int ix) { return list_[ix]; } Fd_Layout_Suite &operator[](int ix) { return list_[ix]; }
@@ -135,8 +135,8 @@ public:
void rename(const char *name); void rename(const char *name);
void capacity(int); void capacity(int);
int load(const Fl_String &filename); int load(const std::string &filename);
int save(const Fl_String &filename); int save(const std::string &filename);
void write(Fl_Preferences &prefs, Fd_Tool_Store storage); void write(Fl_Preferences &prefs, Fd_Tool_Store storage);
void read(Fl_Preferences &prefs, Fd_Tool_Store storage); void read(Fl_Preferences &prefs, Fd_Tool_Store storage);
void write(Fd_Project_Writer*); void write(Fd_Project_Writer*);
+1 -1
View File
@@ -368,7 +368,7 @@ int fl_snapshot(const char *filename, Fl_Widget *w,
/** @} */ /** @} */
void run_autodoc(const Fl_String &target_dir) { void run_autodoc(const std::string &target_dir) {
// A list of all the margins we will use later // A list of all the margins we will use later
Fl_Margin win_margin(0, 0, 0, 0); Fl_Margin win_margin(0, 0, 0, 0);
Fl_Margin win_blend(10, 10, 10, 10); Fl_Margin win_blend(10, 10, 10, 10);
+1 -1
View File
@@ -53,7 +53,7 @@ extern const int FL_SNAP_TO_WINDOW;
extern Fl_Widget *FL_SNAP_AREA_CLEAR; extern Fl_Widget *FL_SNAP_AREA_CLEAR;
extern void run_autodoc(const Fl_String &target_dir); extern void run_autodoc(const std::string &target_dir);
#endif #endif
+3 -3
View File
@@ -85,7 +85,7 @@ int write_escaped_strings(FILE *out, const char *text) {
\param[in] filename file path and name to a file that will hold the strings \param[in] filename file path and name to a file that will hold the strings
\return 1 if the file could not be opened for writing, or the result of `fclose`. \return 1 if the file could not be opened for writing, or the result of `fclose`.
*/ */
int write_strings(const Fl_String &filename) { int write_strings(const std::string &filename) {
Fl_Type *p; Fl_Type *p;
Fl_Widget_Type *w; Fl_Widget_Type *w;
int i; int i;
@@ -797,7 +797,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
} }
// Remember the last code file location for MergeBack // Remember the last code file location for MergeBack
if (s && g_project.write_mergeback_data && !to_codeview) { if (s && g_project.write_mergeback_data && !to_codeview) {
Fl_String proj_filename = g_project.projectfile_path() + g_project.projectfile_name(); std::string proj_filename = g_project.projectfile_path() + g_project.projectfile_name();
int i, n = proj_filename.size(); int i, n = proj_filename.size();
for (i=0; i<n; i++) if (proj_filename[i]=='\\') proj_filename[i] = '/'; for (i=0; i<n; i++) if (proj_filename[i]=='\\') proj_filename[i] = '/';
Fl_Preferences build_records(Fl_Preferences::USER_L, "fltk.org", "fluid-build"); Fl_Preferences build_records(Fl_Preferences::USER_L, "fltk.org", "fluid-build");
@@ -848,7 +848,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_codeview) {
write_c("#include \"%s\"\n", g_project.header_file_name.c_str()); write_c("#include \"%s\"\n", g_project.header_file_name.c_str());
} }
} }
Fl_String loc_include, loc_conditional; std::string loc_include, loc_conditional;
if (g_project.i18n_type==FD_I18N_GNU) { if (g_project.i18n_type==FD_I18N_GNU) {
loc_include = g_project.i18n_gnu_include; loc_include = g_project.i18n_gnu_include;
loc_conditional = g_project.i18n_gnu_conditional; loc_conditional = g_project.i18n_gnu_conditional;
+1 -1
View File
@@ -29,7 +29,7 @@ struct Fd_Text_Tree;
struct Fd_Pointer_Tree; struct Fd_Pointer_Tree;
int is_id(char c); int is_id(char c);
int write_strings(const Fl_String &filename); int write_strings(const std::string &filename);
class Fd_Code_Writer class Fd_Code_Writer
{ {
+2 -2
View File
@@ -182,9 +182,9 @@ void update_codeview_cb(class Fl_Button*, void*) {
cv_strings->buffer()->loadfile(fn); cv_strings->buffer()->loadfile(fn);
cv_strings->scroll(top, 0); cv_strings->scroll(top, 0);
} else if (cv_source->visible_r() || cv_header->visible_r()) { } else if (cv_source->visible_r() || cv_header->visible_r()) {
Fl_String code_file_name_bak = g_project.code_file_name; std::string code_file_name_bak = g_project.code_file_name;
g_project.code_file_name = cv_source_filename; g_project.code_file_name = cv_source_filename;
Fl_String header_file_name_bak = g_project.header_file_name; std::string header_file_name_bak = g_project.header_file_name;
g_project.header_file_name = cv_header_filename; g_project.header_file_name = cv_header_filename;
// generate the code and load the files // generate the code and load the files
+2 -2
View File
@@ -203,9 +203,9 @@ and load those into the Code Viewer widgets.} open return_type void
cv_strings->buffer()->loadfile(fn); cv_strings->buffer()->loadfile(fn);
cv_strings->scroll(top, 0); cv_strings->scroll(top, 0);
} else if (cv_source->visible_r() || cv_header->visible_r()) { } else if (cv_source->visible_r() || cv_header->visible_r()) {
Fl_String code_file_name_bak = g_project.code_file_name; std::string code_file_name_bak = g_project.code_file_name;
g_project.code_file_name = cv_source_filename; g_project.code_file_name = cv_source_filename;
Fl_String header_file_name_bak = g_project.header_file_name; std::string header_file_name_bak = g_project.header_file_name;
g_project.header_file_name = cv_header_filename; g_project.header_file_name = cv_header_filename;
// generate the code and load the files // generate the code and load the files
+53 -53
View File
@@ -148,7 +148,7 @@ int modflag_c = 0;
/// Application work directory, stored here when temporarily changing to the source code directory. /// Application work directory, stored here when temporarily changing to the source code directory.
/// \see goto_source_dir() /// \see goto_source_dir()
static Fl_String app_work_dir; static std::string app_work_dir;
/// Used as a counter to set the .fl project dir as the current directory. /// Used as a counter to set the .fl project dir as the current directory.
/// \see enter_project_dir(), leave_project_dir() /// \see enter_project_dir(), leave_project_dir()
@@ -170,20 +170,20 @@ int show_version = 0; // fluid -v
int batch_mode = 0; // if set (-c, -u) don't open display int batch_mode = 0; // if set (-c, -u) don't open display
/// command line arguments that overrides the generate code file extension or name /// command line arguments that overrides the generate code file extension or name
Fl_String g_code_filename_arg; std::string g_code_filename_arg;
/// command line arguments that overrides the generate header file extension or name /// command line arguments that overrides the generate header file extension or name
Fl_String g_header_filename_arg; std::string g_header_filename_arg;
/// current directory path at application launch /// current directory path at application launch
Fl_String g_launch_path; std::string g_launch_path;
/// if set, generate images for automatic documentation in this directory /// if set, generate images for automatic documentation in this directory
Fl_String g_autodoc_path; std::string g_autodoc_path;
/// path to store temporary files during app run /// path to store temporary files during app run
/// \see tmpdir_create_called /// \see tmpdir_create_called
Fl_String tmpdir_path; std::string tmpdir_path;
/// true if the temporary file path was already created /// true if the temporary file path was already created
/// \see tmpdir_path /// \see tmpdir_path
@@ -267,7 +267,7 @@ void Fluid_Project::update_settings_dialog() {
\param[in] str directory or path name \param[in] str directory or path name
\return a new string, ending with a '/' \return a new string, ending with a '/'
*/ */
static Fl_String end_with_slash(const Fl_String &str) { static std::string end_with_slash(const std::string &str) {
char last = str[str.size()-1]; char last = str[str.size()-1];
if (last !='/' && last != '\\') if (last !='/' && last != '\\')
return str + "/"; return str + "/";
@@ -293,7 +293,7 @@ static void create_tmpdir() {
// C:/Windows/Temp/ // C:/Windows/Temp/
// C:\Users\<username>\AppData\Local\Temp // C:\Users\<username>\AppData\Local\Temp
fl_snprintf(buf, sizeof(buf)-1, "fluid-%d/", (long)GetCurrentProcessId()); fl_snprintf(buf, sizeof(buf)-1, "fluid-%d/", (long)GetCurrentProcessId());
Fl_String name = buf; std::string name = buf;
wchar_t tempdirW[FL_PATH_MAX+1]; wchar_t tempdirW[FL_PATH_MAX+1];
char tempdir[FL_PATH_MAX+1]; char tempdir[FL_PATH_MAX+1];
unsigned len = GetTempPathW(FL_PATH_MAX, tempdirW); unsigned len = GetTempPathW(FL_PATH_MAX, tempdirW);
@@ -303,15 +303,15 @@ static void create_tmpdir() {
unsigned wn = fl_utf8fromwc(tempdir, FL_PATH_MAX, tempdirW, len); unsigned wn = fl_utf8fromwc(tempdir, FL_PATH_MAX, tempdirW, len);
tempdir[wn] = 0; tempdir[wn] = 0;
} }
Fl_String path = tempdir; std::string path = tempdir;
end_with_slash(path); end_with_slash(path);
path += name; path += name;
fl_make_path(path.c_str()); fl_make_path(path.c_str());
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path; if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
#else #else
fl_snprintf(buf, sizeof(buf)-1, "fluid-%d/", getpid()); fl_snprintf(buf, sizeof(buf)-1, "fluid-%d/", getpid());
Fl_String name = buf; std::string name = buf;
Fl_String path = fl_getenv("TMPDIR"); std::string path = fl_getenv("TMPDIR");
if (!path.empty()) { if (!path.empty()) {
end_with_slash(path); end_with_slash(path);
path += name; path += name;
@@ -319,7 +319,7 @@ static void create_tmpdir() {
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path; if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
} }
if (tmpdir_path.empty()) { if (tmpdir_path.empty()) {
path = Fl_String("/tmp/") + name; path = std::string("/tmp/") + name;
fl_make_path(path.c_str()); fl_make_path(path.c_str());
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path; if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
} }
@@ -327,7 +327,7 @@ static void create_tmpdir() {
if (tmpdir_path.empty()) { if (tmpdir_path.empty()) {
char pbuf[FL_PATH_MAX+1]; char pbuf[FL_PATH_MAX+1];
fluid_prefs.get_userdata_path(pbuf, FL_PATH_MAX); fluid_prefs.get_userdata_path(pbuf, FL_PATH_MAX);
path = Fl_String(pbuf); path = std::string(pbuf);
end_with_slash(path); end_with_slash(path);
path += name; path += name;
fl_make_path(path.c_str()); fl_make_path(path.c_str());
@@ -357,7 +357,7 @@ static void delete_tmpdir() {
int n_de = fl_filename_list(tmpdir_path.c_str(), &de); int n_de = fl_filename_list(tmpdir_path.c_str(), &de);
if (n_de >= 0) { if (n_de >= 0) {
for (int i=0; i<n_de; i++) { for (int i=0; i<n_de; i++) {
Fl_String path = tmpdir_path + de[i]->d_name; std::string path = tmpdir_path + de[i]->d_name;
fl_unlink(path.c_str()); fl_unlink(path.c_str());
} }
fl_filename_free_list(&de, n_de); fl_filename_free_list(&de, n_de);
@@ -379,7 +379,7 @@ static void delete_tmpdir() {
\return the path to the temporary directory, ending in a '/', or and empty \return the path to the temporary directory, ending in a '/', or and empty
string if no directory could be created. string if no directory could be created.
*/ */
const Fl_String &get_tmpdir() { const std::string &get_tmpdir() {
if (!tmpdir_create_called) if (!tmpdir_create_called)
create_tmpdir(); create_tmpdir();
return tmpdir_path; return tmpdir_path;
@@ -465,7 +465,7 @@ void enter_project_dir() {
// store the current working directory for later // store the current working directory for later
app_work_dir = fl_getcwd(); app_work_dir = fl_getcwd();
// set the current directory to the path of our .fl file // set the current directory to the path of our .fl file
Fl_String project_path = fl_filename_path(fl_filename_absolute(filename)); std::string project_path = fl_filename_path(fl_filename_absolute(filename));
if (fl_chdir(project_path.c_str()) == -1) { if (fl_chdir(project_path.c_str()) == -1) {
fprintf(stderr, "** Fluid internal error: enter_project_dir() can't chdir to %s: %s\n", fprintf(stderr, "** Fluid internal error: enter_project_dir() can't chdir to %s: %s\n",
project_path.c_str(), strerror(errno)); project_path.c_str(), strerror(errno));
@@ -610,7 +610,7 @@ void save_cb(Fl_Widget *, void *v) {
if (fnfc.show() != 0) return; if (fnfc.show() != 0) return;
c = fnfc.filename(); c = fnfc.filename();
if (!fl_access(c, 0)) { if (!fl_access(c, 0)) {
Fl_String basename = fl_filename_name(Fl_String(c)); std::string basename = fl_filename_name(std::string(c));
if (fl_choice("The file \"%s\" already exists.\n" if (fl_choice("The file \"%s\" already exists.\n"
"Do you want to replace it?", "Cancel", "Do you want to replace it?", "Cancel",
"Replace", NULL, basename.c_str()) == 0) return; "Replace", NULL, basename.c_str()) == 0) return;
@@ -972,19 +972,19 @@ bool new_project_from_template() {
\param title a text describing the action after selecting a file (load, merge, ...) \param title a text describing the action after selecting a file (load, merge, ...)
\return the file path and name, or an empty string if the operation was canceled \return the file path and name, or an empty string if the operation was canceled
*/ */
Fl_String open_project_filechooser(const Fl_String &title) { std::string open_project_filechooser(const std::string &title) {
Fl_Native_File_Chooser dialog; Fl_Native_File_Chooser dialog;
dialog.title(title.c_str()); dialog.title(title.c_str());
dialog.type(Fl_Native_File_Chooser::BROWSE_FILE); dialog.type(Fl_Native_File_Chooser::BROWSE_FILE);
dialog.filter("FLUID Files\t*.f[ld]\n"); dialog.filter("FLUID Files\t*.f[ld]\n");
if (filename) { if (filename) {
Fl_String current_project_file = filename; std::string current_project_file = filename;
dialog.directory(fl_filename_path(current_project_file).c_str()); dialog.directory(fl_filename_path(current_project_file).c_str());
dialog.preset_file(fl_filename_name(current_project_file).c_str()); dialog.preset_file(fl_filename_name(current_project_file).c_str());
} }
if (dialog.show() != 0) if (dialog.show() != 0)
return Fl_String(); return std::string();
return Fl_String(dialog.filename()); return std::string(dialog.filename());
} }
/** /**
@@ -997,12 +997,12 @@ Fl_String open_project_filechooser(const Fl_String &title) {
\param[in] filename_arg path and name of the new project file \param[in] filename_arg path and name of the new project file
\return false if the operation failed \return false if the operation failed
*/ */
bool merge_project_file(const Fl_String &filename_arg) { bool merge_project_file(const std::string &filename_arg) {
bool is_a_merge = (Fl_Type::first != NULL); bool is_a_merge = (Fl_Type::first != NULL);
Fl_String title = is_a_merge ? "Merge Project File" : "Open Project File"; std::string title = is_a_merge ? "Merge Project File" : "Open Project File";
// ask for a filename if none was given // ask for a filename if none was given
Fl_String new_filename = filename_arg; std::string new_filename = filename_arg;
if (new_filename.empty()) { if (new_filename.empty()) {
new_filename = open_project_filechooser(title); new_filename = open_project_filechooser(title);
if (new_filename.empty()) { if (new_filename.empty()) {
@@ -1052,13 +1052,13 @@ bool merge_project_file(const Fl_String &filename_arg) {
\param[in] filename_arg load from this file, or show file chooser if empty \param[in] filename_arg load from this file, or show file chooser if empty
\return false if the operation was canceled or failed otherwise \return false if the operation was canceled or failed otherwise
*/ */
bool open_project_file(const Fl_String &filename_arg) { bool open_project_file(const std::string &filename_arg) {
// verify user intention // verify user intention
if (confirm_project_clear() == false) if (confirm_project_clear() == false)
return false; return false;
// ask for a filename if none was given // ask for a filename if none was given
Fl_String new_filename = filename_arg; std::string new_filename = filename_arg;
if (new_filename.empty()) { if (new_filename.empty()) {
new_filename = open_project_filechooser("Open Project File"); new_filename = open_project_filechooser("Open Project File");
if (new_filename.empty()) { if (new_filename.empty()) {
@@ -1078,7 +1078,7 @@ bool open_project_file(const Fl_String &filename_arg) {
\param[in] c the filename of the new design \param[in] c the filename of the new design
*/ */
void apple_open_cb(const char *c) { void apple_open_cb(const char *c) {
open_project_file(Fl_String(c)); open_project_file(std::string(c));
} }
#endif // __APPLE__ #endif // __APPLE__
@@ -1086,7 +1086,7 @@ void apple_open_cb(const char *c) {
Get the absolute path of the project file, for example `/Users/matt/dev/`. Get the absolute path of the project file, for example `/Users/matt/dev/`.
\return the path ending in '/' \return the path ending in '/'
*/ */
Fl_String Fluid_Project::projectfile_path() const { std::string Fluid_Project::projectfile_path() const {
return end_with_slash(fl_filename_absolute(fl_filename_path(filename), g_launch_path)); return end_with_slash(fl_filename_absolute(fl_filename_path(filename), g_launch_path));
} }
@@ -1094,7 +1094,7 @@ Fl_String Fluid_Project::projectfile_path() const {
Get the project file name including extension, for example `test.fl`. Get the project file name including extension, for example `test.fl`.
\return the file name without path \return the file name without path
*/ */
Fl_String Fluid_Project::projectfile_name() const { std::string Fluid_Project::projectfile_name() const {
return fl_filename_name(filename); return fl_filename_name(filename);
} }
@@ -1102,8 +1102,8 @@ Fl_String Fluid_Project::projectfile_name() const {
Get the absolute path of the generated C++ code file, for example `/Users/matt/dev/src/`. Get the absolute path of the generated C++ code file, for example `/Users/matt/dev/src/`.
\return the path ending in '/' \return the path ending in '/'
*/ */
Fl_String Fluid_Project::codefile_path() const { std::string Fluid_Project::codefile_path() const {
Fl_String path = fl_filename_path(code_file_name); std::string path = fl_filename_path(code_file_name);
if (batch_mode) if (batch_mode)
return end_with_slash(fl_filename_absolute(path, g_launch_path)); return end_with_slash(fl_filename_absolute(path, g_launch_path));
else else
@@ -1114,8 +1114,8 @@ Fl_String Fluid_Project::codefile_path() const {
Get the generated C++ code file name including extension, for example `test.cxx`. Get the generated C++ code file name including extension, for example `test.cxx`.
\return the file name without path \return the file name without path
*/ */
Fl_String Fluid_Project::codefile_name() const { std::string Fluid_Project::codefile_name() const {
Fl_String name = fl_filename_name(code_file_name); std::string name = fl_filename_name(code_file_name);
if (name.empty()) { if (name.empty()) {
return fl_filename_setext(fl_filename_name(filename), ".cxx"); return fl_filename_setext(fl_filename_name(filename), ".cxx");
} else if (name[0] == '.') { } else if (name[0] == '.') {
@@ -1129,8 +1129,8 @@ Fl_String Fluid_Project::codefile_name() const {
Get the absolute path of the generated C++ header file, for example `/Users/matt/dev/src/`. Get the absolute path of the generated C++ header file, for example `/Users/matt/dev/src/`.
\return the path ending in '/' \return the path ending in '/'
*/ */
Fl_String Fluid_Project::headerfile_path() const { std::string Fluid_Project::headerfile_path() const {
Fl_String path = fl_filename_path(header_file_name); std::string path = fl_filename_path(header_file_name);
if (batch_mode) if (batch_mode)
return end_with_slash(fl_filename_absolute(path, g_launch_path)); return end_with_slash(fl_filename_absolute(path, g_launch_path));
else else
@@ -1141,8 +1141,8 @@ Fl_String Fluid_Project::headerfile_path() const {
Get the generated C++ header file name including extension, for example `test.cxx`. Get the generated C++ header file name including extension, for example `test.cxx`.
\return the file name without path \return the file name without path
*/ */
Fl_String Fluid_Project::headerfile_name() const { std::string Fluid_Project::headerfile_name() const {
Fl_String name = fl_filename_name(header_file_name); std::string name = fl_filename_name(header_file_name);
if (name.empty()) { if (name.empty()) {
return fl_filename_setext(fl_filename_name(filename), ".h"); return fl_filename_setext(fl_filename_name(filename), ".h");
} else if (name[0] == '.') { } else if (name[0] == '.') {
@@ -1160,7 +1160,7 @@ Fl_String Fluid_Project::headerfile_name() const {
batch mode. batch mode.
\return the path ending in '/' \return the path ending in '/'
*/ */
Fl_String Fluid_Project::stringsfile_path() const { std::string Fluid_Project::stringsfile_path() const {
if (batch_mode) if (batch_mode)
return g_launch_path; return g_launch_path;
else else
@@ -1171,7 +1171,7 @@ Fl_String Fluid_Project::stringsfile_path() const {
Get the generated i18n text file name including extension, for example `test.po`. Get the generated i18n text file name including extension, for example `test.po`.
\return the file name without path \return the file name without path
*/ */
Fl_String Fluid_Project::stringsfile_name() const { std::string Fluid_Project::stringsfile_name() const {
switch (i18n_type) { switch (i18n_type) {
default: return fl_filename_setext(fl_filename_name(filename), ".txt"); default: return fl_filename_setext(fl_filename_name(filename), ".txt");
case FD_I18N_GNU: return fl_filename_setext(fl_filename_name(filename), ".po"); case FD_I18N_GNU: return fl_filename_setext(fl_filename_name(filename), ".po");
@@ -1183,7 +1183,7 @@ Fl_String Fluid_Project::stringsfile_name() const {
Get the name of the project file without the filename extension. Get the name of the project file without the filename extension.
\return the file name without path or extension \return the file name without path or extension
*/ */
Fl_String Fluid_Project::basename() const { std::string Fluid_Project::basename() const {
return fl_filename_setext(fl_filename_name(filename), ""); return fl_filename_setext(fl_filename_name(filename), "");
} }
@@ -1218,14 +1218,14 @@ int write_code_files(bool dont_show_completion_dialog)
// -- generate the file names with absolute paths // -- generate the file names with absolute paths
Fd_Code_Writer f; Fd_Code_Writer f;
Fl_String code_filename = g_project.codefile_path() + g_project.codefile_name(); std::string code_filename = g_project.codefile_path() + g_project.codefile_name();
Fl_String header_filename = g_project.headerfile_path() + g_project.headerfile_name(); std::string header_filename = g_project.headerfile_path() + g_project.headerfile_name();
// -- write the code and header files // -- write the code and header files
if (!batch_mode) enter_project_dir(); if (!batch_mode) enter_project_dir();
int x = f.write_code(code_filename.c_str(), header_filename.c_str()); int x = f.write_code(code_filename.c_str(), header_filename.c_str());
Fl_String code_filename_rel = fl_filename_relative(code_filename); std::string code_filename_rel = fl_filename_relative(code_filename);
Fl_String header_filename_rel = fl_filename_relative(header_filename); std::string header_filename_rel = fl_filename_relative(header_filename);
if (!batch_mode) leave_project_dir(); if (!batch_mode) leave_project_dir();
// -- print error message in batch mode or pop up an error or confirmation dialog box // -- print error message in batch mode or pop up an error or confirmation dialog box
@@ -1278,8 +1278,8 @@ int mergeback_code_files()
return 0; return 0;
} }
Fl_String proj_filename = g_project.projectfile_path() + g_project.projectfile_name(); std::string proj_filename = g_project.projectfile_path() + g_project.projectfile_name();
Fl_String code_filename; std::string code_filename;
#if 1 #if 1
if (!batch_mode) { if (!batch_mode) {
Fl_Preferences build_records(Fl_Preferences::USER_L, "fltk.org", "fluid-build"); Fl_Preferences build_records(Fl_Preferences::USER_L, "fltk.org", "fluid-build");
@@ -1317,7 +1317,7 @@ void write_strings_cb(Fl_Widget *, void *) {
save_cb(0,0); save_cb(0,0);
if (!filename) return; if (!filename) return;
} }
Fl_String filename = g_project.stringsfile_path() + g_project.stringsfile_name(); std::string filename = g_project.stringsfile_path() + g_project.stringsfile_name();
int x = write_strings(filename); int x = write_strings(filename);
if (batch_mode) { if (batch_mode) {
if (x) { if (x) {
@@ -1626,7 +1626,7 @@ void print_menu_cb(Fl_Widget *, void *) {
fl_draw(date, w - (int)fl_width(date), fl_height()); fl_draw(date, w - (int)fl_width(date), fl_height());
// Get the base filename... // Get the base filename...
Fl_String basename = fl_filename_name(Fl_String(filename)); std::string basename = fl_filename_name(std::string(filename));
fl_draw(basename.c_str(), 0, fl_height()); fl_draw(basename.c_str(), 0, fl_height());
// print centered and scaled to fit in the page // print centered and scaled to fit in the page
@@ -1657,7 +1657,7 @@ static void menu_file_new_cb(Fl_Widget *, void *) { new_project(); }
static void menu_file_new_from_template_cb(Fl_Widget *, void *) { new_project_from_template(); } static void menu_file_new_from_template_cb(Fl_Widget *, void *) { new_project_from_template(); }
static void menu_file_open_cb(Fl_Widget *, void *) { open_project_file(""); } static void menu_file_open_cb(Fl_Widget *, void *) { open_project_file(""); }
static void menu_file_insert_cb(Fl_Widget *, void *) { merge_project_file(""); } static void menu_file_insert_cb(Fl_Widget *, void *) { merge_project_file(""); }
static void menu_file_open_history_cb(Fl_Widget *, void *v) { open_project_file(Fl_String((const char*)v)); } static void menu_file_open_history_cb(Fl_Widget *, void *v) { open_project_file(std::string((const char*)v)); }
static void menu_layout_sync_resize_cb(Fl_Menu_ *m, void*) { static void menu_layout_sync_resize_cb(Fl_Menu_ *m, void*) {
if (m->mvalue()->value()) Fl_Type::allow_layout = 1; else Fl_Type::allow_layout = 0; } if (m->mvalue()->value()) Fl_Type::allow_layout = 1; else Fl_Type::allow_layout = 0; }
/** /**
@@ -1943,7 +1943,7 @@ void load_history() {
fluid_prefs.get( Fl_Preferences::Name("file%d", i), absolute_history[i], "", sizeof(absolute_history[i])); fluid_prefs.get( Fl_Preferences::Name("file%d", i), absolute_history[i], "", sizeof(absolute_history[i]));
if (absolute_history[i][0]) { if (absolute_history[i][0]) {
// Make a shortened version of the filename for the menu... // Make a shortened version of the filename for the menu...
Fl_String fn = fl_filename_shortened(absolute_history[i], 48); std::string fn = fl_filename_shortened(absolute_history[i], 48);
strncpy(relative_history[i], fn.c_str(), sizeof(relative_history[i]) - 1); strncpy(relative_history[i], fn.c_str(), sizeof(relative_history[i]) - 1);
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER; if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
else history_item[i].flags = 0; else history_item[i].flags = 0;
@@ -2003,7 +2003,7 @@ void update_history(const char *flname) {
// Put the new file at the top... // Put the new file at the top...
strlcpy(absolute_history[0], absolute, sizeof(absolute_history[0])); strlcpy(absolute_history[0], absolute, sizeof(absolute_history[0]));
Fl_String fn = fl_filename_shortened(absolute_history[0], 48); std::string fn = fl_filename_shortened(absolute_history[0], 48);
strncpy(relative_history[0], fn.c_str(), sizeof(relative_history[0]) - 1); strncpy(relative_history[0], fn.c_str(), sizeof(relative_history[0]) - 1);
// Update the menu items as needed... // Update the menu items as needed...
@@ -2072,9 +2072,9 @@ void set_modflag(int mf, int mfc) {
} }
if (main_window) { if (main_window) {
Fl_String basename; std::string basename;
if (!filename) basename = "Untitled.fl"; if (!filename) basename = "Untitled.fl";
else basename = fl_filename_name(Fl_String(filename)); else basename = fl_filename_name(std::string(filename));
code_ext = fl_filename_ext(g_project.code_file_name.c_str()); code_ext = fl_filename_ext(g_project.code_file_name.c_str());
char mod_star = modflag ? '*' : ' '; char mod_star = modflag ? '*' : ' ';
char mod_c_star = modflag_c ? '*' : ' '; char mod_c_star = modflag_c ? '*' : ' ';
+24 -24
View File
@@ -90,11 +90,11 @@ extern int batch_mode;
extern int pasteoffset; extern int pasteoffset;
extern Fl_String g_code_filename_arg; extern std::string g_code_filename_arg;
extern Fl_String g_header_filename_arg; extern std::string g_header_filename_arg;
extern Fl_String g_launch_path; extern std::string g_launch_path;
extern Fl_String g_autodoc_path; extern std::string g_autodoc_path;
// ---- project class declaration // ---- project class declaration
@@ -117,39 +117,39 @@ public:
void reset(); void reset();
void update_settings_dialog(); void update_settings_dialog();
Fl_String projectfile_path() const; std::string projectfile_path() const;
Fl_String projectfile_name() const; std::string projectfile_name() const;
Fl_String codefile_path() const; std::string codefile_path() const;
Fl_String codefile_name() const; std::string codefile_name() const;
Fl_String headerfile_path() const; std::string headerfile_path() const;
Fl_String headerfile_name() const; std::string headerfile_name() const;
Fl_String stringsfile_path() const; std::string stringsfile_path() const;
Fl_String stringsfile_name() const; std::string stringsfile_name() const;
Fl_String basename() const; std::string basename() const;
/// One of the available internationalization types. /// One of the available internationalization types.
Fd_I18n_Type i18n_type; Fd_I18n_Type i18n_type;
/// Include file for GNU i18n, writes an #include statement into the source /// Include file for GNU i18n, writes an #include statement into the source
/// file. This is usually `<libintl.h>` or `"gettext.h"` for GNU gettext. /// file. This is usually `<libintl.h>` or `"gettext.h"` for GNU gettext.
Fl_String i18n_gnu_include; std::string i18n_gnu_include;
// Optional name of a macro for conditional i18n compilation. // Optional name of a macro for conditional i18n compilation.
Fl_String i18n_gnu_conditional; std::string i18n_gnu_conditional;
/// For the gettext/intl.h options, this is the function that translates text /// For the gettext/intl.h options, this is the function that translates text
/// at runtime. This is usually "gettext" or "_". /// at runtime. This is usually "gettext" or "_".
Fl_String i18n_gnu_function; std::string i18n_gnu_function;
/// For the gettext/intl.h options, this is the function that marks the translation /// For the gettext/intl.h options, this is the function that marks the translation
/// of text at initialisation time. This is usually "gettext_noop" or "N_". /// of text at initialisation time. This is usually "gettext_noop" or "N_".
Fl_String i18n_gnu_static_function; std::string i18n_gnu_static_function;
/// Include file for Posix i18n, write a #include statement into the source /// Include file for Posix i18n, write a #include statement into the source
/// file. This is usually `<nl_types.h>` for Posix catgets. /// file. This is usually `<nl_types.h>` for Posix catgets.
Fl_String i18n_pos_include; std::string i18n_pos_include;
// Optional name of a macro for conditional i18n compilation. // Optional name of a macro for conditional i18n compilation.
Fl_String i18n_pos_conditional; std::string i18n_pos_conditional;
/// Name of the nl_catd database /// Name of the nl_catd database
Fl_String i18n_pos_file; std::string i18n_pos_file;
/// Message set ID for the catalog. /// Message set ID for the catalog.
Fl_String i18n_pos_set; std::string i18n_pos_set;
/// If set, generate code to include the header file form the c++ file /// If set, generate code to include the header file form the c++ file
int include_H_from_C; int include_H_from_C;
@@ -165,9 +165,9 @@ public:
int code_file_set; int code_file_set;
int write_mergeback_data; int write_mergeback_data;
/// Hold the default extension for header files, or the entire filename if set via command line. /// Hold the default extension for header files, or the entire filename if set via command line.
Fl_String header_file_name; std::string header_file_name;
/// Hold the default extension for source code files, or the entire filename if set via command line. /// Hold the default extension for source code files, or the entire filename if set via command line.
Fl_String code_file_name; std::string code_file_name;
}; };
extern Fluid_Project g_project; extern Fluid_Project g_project;
@@ -180,7 +180,7 @@ extern void leave_project_dir();
extern void set_filename(const char *c); extern void set_filename(const char *c);
extern void set_modflag(int mf, int mfc=-1); extern void set_modflag(int mf, int mfc=-1);
extern const Fl_String &get_tmpdir(); extern const std::string &get_tmpdir();
// ---- public callback functions // ---- public callback functions
+28 -28
View File
@@ -18,10 +18,10 @@
\brief File names and URI utility functions for FLUID only. \brief File names and URI utility functions for FLUID only.
This file defines all fl_filename* functions using Fl_String and also This file defines all fl_filename* functions using std::string and also
includes the main header file <FL/filename.H>. includes the main header file <FL/filename.H>.
\note This file contains some filename functions using Fl_String which \note This file contains some filename functions using std::string which
which are used in FLTK 1.4.x but will be removed in the next minor which are used in FLTK 1.4.x but will be removed in the next minor
or major release after 1.4.x (i.e. 1.5 or maybe 4.0). or major release after 1.4.x (i.e. 1.5 or maybe 4.0).
@@ -45,8 +45,8 @@
\return the name part of a filename \return the name part of a filename
\see fl_filename_name(const char *filename) \see fl_filename_name(const char *filename)
*/ */
Fl_String fl_filename_name(const Fl_String &filename) { std::string fl_filename_name(const std::string &filename) {
return Fl_String(fl_filename_name(filename.c_str())); return std::string(fl_filename_name(filename.c_str()));
} }
/** /**
@@ -55,13 +55,13 @@ Fl_String fl_filename_name(const Fl_String &filename) {
\return the path part of a filename without the name \return the path part of a filename without the name
\see fl_filename_name(const char *filename) \see fl_filename_name(const char *filename)
*/ */
Fl_String fl_filename_path(const Fl_String &filename) { std::string fl_filename_path(const std::string &filename) {
const char *base = filename.c_str(); const char *base = filename.c_str();
const char *name = fl_filename_name(base); const char *name = fl_filename_name(base);
if (name) { if (name) {
return Fl_String(base, (int)(name-base)); return std::string(base, (int)(name-base));
} else { } else {
return Fl_String(); return std::string();
} }
} }
@@ -72,8 +72,8 @@ Fl_String fl_filename_path(const Fl_String &filename) {
string if the filename has no extension string if the filename has no extension
\see fl_filename_ext(const char *buf) \see fl_filename_ext(const char *buf)
*/ */
Fl_String fl_filename_ext(const Fl_String &filename) { std::string fl_filename_ext(const std::string &filename) {
return Fl_String(fl_filename_ext(filename.c_str())); return std::string(fl_filename_ext(filename.c_str()));
} }
/** /**
@@ -83,11 +83,11 @@ Fl_String fl_filename_ext(const Fl_String &filename) {
\return the new filename \return the new filename
\see fl_filename_setext(char *to, int tolen, const char *ext) \see fl_filename_setext(char *to, int tolen, const char *ext)
*/ */
Fl_String fl_filename_setext(const Fl_String &filename, const Fl_String &new_extension) { std::string fl_filename_setext(const std::string &filename, const std::string &new_extension) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_strlcpy(buffer, filename.c_str(), FL_PATH_MAX); fl_strlcpy(buffer, filename.c_str(), FL_PATH_MAX);
fl_filename_setext(buffer, FL_PATH_MAX, new_extension.c_str()); fl_filename_setext(buffer, FL_PATH_MAX, new_extension.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -96,10 +96,10 @@ Fl_String fl_filename_setext(const Fl_String &filename, const Fl_String &new_ext
\return the new, expanded filename \return the new, expanded filename
\see fl_filename_expand(char *to, int tolen, const char *from) \see fl_filename_expand(char *to, int tolen, const char *from)
*/ */
Fl_String fl_filename_expand(const Fl_String &from) { std::string fl_filename_expand(const std::string &from) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_filename_expand(buffer, FL_PATH_MAX, from.c_str()); fl_filename_expand(buffer, FL_PATH_MAX, from.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -108,10 +108,10 @@ Fl_String fl_filename_expand(const Fl_String &from) {
\return the new, absolute filename \return the new, absolute filename
\see fl_filename_absolute(char *to, int tolen, const char *from) \see fl_filename_absolute(char *to, int tolen, const char *from)
*/ */
Fl_String fl_filename_absolute(const Fl_String &from) { std::string fl_filename_absolute(const std::string &from) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_filename_absolute(buffer, FL_PATH_MAX, from.c_str()); fl_filename_absolute(buffer, FL_PATH_MAX, from.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -122,10 +122,10 @@ Fl_String fl_filename_absolute(const Fl_String &from) {
\return the new, absolute filename \return the new, absolute filename
\see fl_filename_absolute(char *to, int tolen, const char *from, const char *base) \see fl_filename_absolute(char *to, int tolen, const char *from, const char *base)
*/ */
Fl_String fl_filename_absolute(const Fl_String &from, const Fl_String &base) { std::string fl_filename_absolute(const std::string &from, const std::string &base) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_filename_absolute(buffer, FL_PATH_MAX, from.c_str(), base.c_str()); fl_filename_absolute(buffer, FL_PATH_MAX, from.c_str(), base.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -134,10 +134,10 @@ Fl_String fl_filename_absolute(const Fl_String &from, const Fl_String &base) {
\return the new, relative filename \return the new, relative filename
\see fl_filename_relative(char *to, int tolen, const char *from) \see fl_filename_relative(char *to, int tolen, const char *from)
*/ */
Fl_String fl_filename_relative(const Fl_String &from) { std::string fl_filename_relative(const std::string &from) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_filename_relative(buffer, FL_PATH_MAX, from.c_str()); fl_filename_relative(buffer, FL_PATH_MAX, from.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -147,20 +147,20 @@ Fl_String fl_filename_relative(const Fl_String &from) {
\return the new, relative filename \return the new, relative filename
\see fl_filename_relative(char *to, int tolen, const char *from, const char *base) \see fl_filename_relative(char *to, int tolen, const char *from, const char *base)
*/ */
Fl_String fl_filename_relative(const Fl_String &from, const Fl_String &base) { std::string fl_filename_relative(const std::string &from, const std::string &base) {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_filename_relative(buffer, FL_PATH_MAX, from.c_str(), base.c_str()); fl_filename_relative(buffer, FL_PATH_MAX, from.c_str(), base.c_str());
return Fl_String(buffer); return std::string(buffer);
} }
/** Cross-platform function to get the current working directory /** Cross-platform function to get the current working directory
as a UTF-8 encoded value in an Fl_String. as a UTF-8 encoded value in an std::string.
\return the CWD encoded as UTF-8 \return the CWD encoded as UTF-8
*/ */
Fl_String fl_getcwd() { std::string fl_getcwd() {
char buffer[FL_PATH_MAX]; char buffer[FL_PATH_MAX];
fl_getcwd(buffer, FL_PATH_MAX); fl_getcwd(buffer, FL_PATH_MAX);
return Fl_String(buffer); return std::string(buffer);
} }
/** /**
@@ -177,19 +177,19 @@ Fl_String fl_getcwd() {
\param[in[ max_chars maximum number of characters in result, including ellipsis \param[in[ max_chars maximum number of characters in result, including ellipsis
\return shortened file path and name \return shortened file path and name
*/ */
Fl_String fl_filename_shortened(const Fl_String &filename, int max_chars) { std::string fl_filename_shortened(const std::string &filename, int max_chars) {
// Insert this as the ellipsis // Insert this as the ellipsis
static const char *ell = "..."; static const char *ell = "...";
static const int ell_bytes = 3; static const int ell_bytes = 3;
// Replace the start of a path with "~" if it matches the home directory // Replace the start of a path with "~" if it matches the home directory
static Fl_String tilde = "~/"; static std::string tilde = "~/";
static Fl_String home; static std::string home;
static int home_chars = -1; static int home_chars = -1;
if (home_chars==-1) { if (home_chars==-1) {
home = fl_filename_expand(tilde); home = fl_filename_expand(tilde);
home_chars = fl_utf_nb_char((const uchar*)home.c_str(), home.size()); home_chars = fl_utf_nb_char((const uchar*)home.c_str(), home.size());
} }
Fl_String homed_filename; std::string homed_filename;
#if defined(_WIN32) || defined(__APPLE__) #if defined(_WIN32) || defined(__APPLE__)
bool starts_with_home = fl_utf_strncasecmp(home.c_str(), filename.c_str(), home_chars)==0; bool starts_with_home = fl_utf_strncasecmp(home.c_str(), filename.c_str(), home_chars)==0;
#else #else
+13 -13
View File
@@ -18,10 +18,10 @@
\brief File names and URI utility functions for FLUID only. \brief File names and URI utility functions for FLUID only.
This file declares all fl_filename* functions using Fl_String and also This file declares all fl_filename* functions using std::string and also
includes the main header file <FL/filename.H>. includes the main header file <FL/filename.H>.
\note This file contains some filename functions using Fl_String which \note This file contains some filename functions using std::string which
which are used in FLTK 1.4.x but will be removed in the next minor which are used in FLTK 1.4.x but will be removed in the next minor
or major release after 1.4.x (i.e. 1.5 or maybe 4.0). or major release after 1.4.x (i.e. 1.5 or maybe 4.0).
@@ -41,17 +41,17 @@
#include "../src/Fl_String.H" #include "../src/Fl_String.H"
Fl_String fl_filename_shortened(const Fl_String &filename, int maxchars); std::string fl_filename_shortened(const std::string &filename, int maxchars);
Fl_String fl_filename_name(const Fl_String &filename); std::string fl_filename_name(const std::string &filename);
Fl_String fl_filename_path(const Fl_String &filename); std::string fl_filename_path(const std::string &filename);
Fl_String fl_filename_ext(const Fl_String &filename); std::string fl_filename_ext(const std::string &filename);
Fl_String fl_filename_setext(const Fl_String &filename, const Fl_String &new_extension); std::string fl_filename_setext(const std::string &filename, const std::string &new_extension);
Fl_String fl_filename_expand(const Fl_String &from); std::string fl_filename_expand(const std::string &from);
Fl_String fl_filename_absolute(const Fl_String &from); std::string fl_filename_absolute(const std::string &from);
Fl_String fl_filename_absolute(const Fl_String &from, const Fl_String &base); std::string fl_filename_absolute(const std::string &from, const std::string &base);
Fl_String fl_filename_relative(const Fl_String &from); std::string fl_filename_relative(const std::string &from);
Fl_String fl_filename_relative(const Fl_String &from, const Fl_String &base); std::string fl_filename_relative(const std::string &from, const std::string &base);
Fl_String fl_getcwd(); std::string fl_getcwd();
# endif # endif
+11 -11
View File
@@ -101,7 +101,7 @@ extern void redraw_browser();
\return -2 if no code file was found \return -2 if no code file was found
\return see above \return see above
*/ */
int merge_back(const Fl_String &s, const Fl_String &p, int task) { int merge_back(const std::string &s, const std::string &p, int task) {
if (g_project.write_mergeback_data) { if (g_project.write_mergeback_data) {
Fd_Mergeback mergeback; Fd_Mergeback mergeback;
return mergeback.merge_back(s, p, task); return mergeback.merge_back(s, p, task);
@@ -154,7 +154,7 @@ void Fd_Mergeback::unindent(char *s) {
\param[in] end end of text within the file \param[in] end end of text within the file
\return a string holding the text that was found in the file \return a string holding the text that was found in the file
*/ */
Fl_String Fd_Mergeback::read_and_unindent_block(long start, long end) { std::string Fd_Mergeback::read_and_unindent_block(long start, long end) {
long bsize = end-start; long bsize = end-start;
long here = ::ftell(code); long here = ::ftell(code);
::fseek(code, start, SEEK_SET); ::fseek(code, start, SEEK_SET);
@@ -165,7 +165,7 @@ Fl_String Fd_Mergeback::read_and_unindent_block(long start, long end) {
else else
block[bsize] = 0; block[bsize] = 0;
unindent(block); unindent(block);
Fl_String str = block; std::string str = block;
::free(block); ::free(block);
::fseek(code, here, SEEK_SET); ::fseek(code, here, SEEK_SET);
return str; return str;
@@ -178,7 +178,7 @@ Fl_String Fd_Mergeback::read_and_unindent_block(long start, long end) {
\return -1 if the user wants to cancel or an error occurred or an issue was presented \return -1 if the user wants to cancel or an error occurred or an issue was presented
(message or choice dialog was shown) (message or choice dialog was shown)
*/ */
int Fd_Mergeback::ask_user_to_merge(const Fl_String &code_filename, const Fl_String &proj_filename) { int Fd_Mergeback::ask_user_to_merge(const std::string &code_filename, const std::string &proj_filename) {
if (tag_error) { if (tag_error) {
fl_message("Comparing\n \"%s\"\nto\n \"%s\"\n\n" fl_message("Comparing\n \"%s\"\nto\n \"%s\"\n\n"
"MergeBack found an error in line %d while reading tags\n" "MergeBack found an error in line %d while reading tags\n"
@@ -198,7 +198,7 @@ int Fd_Mergeback::ask_user_to_merge(const Fl_String &code_filename, const Fl_Str
code_filename.c_str(), proj_filename.c_str(), num_changed_structure); code_filename.c_str(), proj_filename.c_str(), num_changed_structure);
return -1; return -1;
} }
Fl_String msg = "Comparing\n \"%1$s\"\nto\n \"%2$s\"\n\n" std::string msg = "Comparing\n \"%1$s\"\nto\n \"%2$s\"\n\n"
"MergeBack found %3$d modifications in the source code."; "MergeBack found %3$d modifications in the source code.";
if (num_possible_override) if (num_possible_override)
msg += "\n\nWARNING: %6$d of these modified blocks appear to also have\n" msg += "\n\nWARNING: %6$d of these modified blocks appear to also have\n"
@@ -241,7 +241,7 @@ int Fd_Mergeback::ask_user_to_merge(const Fl_String &code_filename, const Fl_Str
void Fd_Mergeback::analyse_callback(unsigned long code_crc, unsigned long tag_crc, int uid) { void Fd_Mergeback::analyse_callback(unsigned long code_crc, unsigned long tag_crc, int uid) {
Fl_Type *tp = Fl_Type::find_by_uid(uid); Fl_Type *tp = Fl_Type::find_by_uid(uid);
if (tp && tp->is_true_widget()) { if (tp && tp->is_true_widget()) {
Fl_String cb = tp->callback(); cb += "\n"; std::string cb = tp->callback(); cb += "\n";
unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str()); unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str());
// check if the code and project crc are the same, so this modification was already applied // check if the code and project crc are the same, so this modification was already applied
if (project_crc!=code_crc) { if (project_crc!=code_crc) {
@@ -263,7 +263,7 @@ void Fd_Mergeback::analyse_callback(unsigned long code_crc, unsigned long tag_cr
void Fd_Mergeback::analyse_code(unsigned long code_crc, unsigned long tag_crc, int uid) { void Fd_Mergeback::analyse_code(unsigned long code_crc, unsigned long tag_crc, int uid) {
Fl_Type *tp = Fl_Type::find_by_uid(uid); Fl_Type *tp = Fl_Type::find_by_uid(uid);
if (tp && tp->is_a(ID_Code)) { if (tp && tp->is_a(ID_Code)) {
Fl_String code = tp->name(); code += "\n"; std::string code = tp->name(); code += "\n";
unsigned long project_crc = Fd_Code_Writer::block_crc(code.c_str()); unsigned long project_crc = Fd_Code_Writer::block_crc(code.c_str());
// check if the code and project crc are the same, so this modification was already applied // check if the code and project crc are the same, so this modification was already applied
if (project_crc!=code_crc) { if (project_crc!=code_crc) {
@@ -356,7 +356,7 @@ int Fd_Mergeback::analyse() {
int Fd_Mergeback::apply_callback(long block_end, long block_start, unsigned long code_crc, int uid) { int Fd_Mergeback::apply_callback(long block_end, long block_start, unsigned long code_crc, int uid) {
Fl_Type *tp = Fl_Type::find_by_uid(uid); Fl_Type *tp = Fl_Type::find_by_uid(uid);
if (tp && tp->is_true_widget()) { if (tp && tp->is_true_widget()) {
Fl_String cb = tp->callback(); cb += "\n"; std::string cb = tp->callback(); cb += "\n";
unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str()); unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str());
if (project_crc!=code_crc) { if (project_crc!=code_crc) {
tp->callback(read_and_unindent_block(block_start, block_end).c_str()); tp->callback(read_and_unindent_block(block_start, block_end).c_str());
@@ -372,7 +372,7 @@ int Fd_Mergeback::apply_callback(long block_end, long block_start, unsigned long
int Fd_Mergeback::apply_code(long block_end, long block_start, unsigned long code_crc, int uid) { int Fd_Mergeback::apply_code(long block_end, long block_start, unsigned long code_crc, int uid) {
Fl_Type *tp = Fl_Type::find_by_uid(uid); Fl_Type *tp = Fl_Type::find_by_uid(uid);
if (tp && tp->is_a(ID_Code)) { if (tp && tp->is_a(ID_Code)) {
Fl_String cb = tp->name(); cb += "\n"; std::string cb = tp->name(); cb += "\n";
unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str()); unsigned long project_crc = Fd_Code_Writer::block_crc(cb.c_str());
if (project_crc!=code_crc) { if (project_crc!=code_crc) {
tp->name(read_and_unindent_block(block_start, block_end).c_str()); tp->name(read_and_unindent_block(block_start, block_end).c_str());
@@ -439,9 +439,9 @@ int Fd_Mergeback::apply() {
FD_MERGEBACK_APPLY_IF_SAFE, or FD_MERGEBACK_APPLY FD_MERGEBACK_APPLY_IF_SAFE, or FD_MERGEBACK_APPLY
\return -1 if an error was found in a tag \return -1 if an error was found in a tag
\return -2 if no code file was found \return -2 if no code file was found
\return See more at ::merge_back(const Fl_String &s, int task). \return See more at ::merge_back(const std::string &s, int task).
*/ */
int Fd_Mergeback::merge_back(const Fl_String &s, const Fl_String &p, int task) { int Fd_Mergeback::merge_back(const std::string &s, const std::string &p, int task) {
int ret = 0; int ret = 0;
code = fl_fopen(s.c_str(), "rb"); code = fl_fopen(s.c_str(), "rb");
if (!code) return -2; if (!code) return -2;
+5 -5
View File
@@ -38,7 +38,7 @@ const int FD_MERGEBACK_APPLY = 2;
const int FD_MERGEBACK_APPLY_IF_SAFE = 3; const int FD_MERGEBACK_APPLY_IF_SAFE = 3;
/** Class that implements the MergeBack functionality. /** Class that implements the MergeBack functionality.
\see merge_back(const Fl_String &s, int task) \see merge_back(const std::string &s, int task)
*/ */
class Fd_Mergeback class Fd_Mergeback
{ {
@@ -59,7 +59,7 @@ protected:
int num_possible_override; int num_possible_override;
void unindent(char *s); void unindent(char *s);
Fl_String read_and_unindent_block(long start, long end); std::string read_and_unindent_block(long start, long end);
void analyse_callback(unsigned long code_crc, unsigned long tag_crc, int uid); void analyse_callback(unsigned long code_crc, unsigned long tag_crc, int uid);
void analyse_code(unsigned long code_crc, unsigned long tag_crc, int uid); void analyse_code(unsigned long code_crc, unsigned long tag_crc, int uid);
int apply_callback(long block_end, long block_start, unsigned long code_crc, int uid); int apply_callback(long block_end, long block_start, unsigned long code_crc, int uid);
@@ -68,13 +68,13 @@ protected:
public: public:
Fd_Mergeback(); Fd_Mergeback();
~Fd_Mergeback(); ~Fd_Mergeback();
int merge_back(const Fl_String &s, const Fl_String &p, int task); int merge_back(const std::string &s, const std::string &p, int task);
int ask_user_to_merge(const Fl_String &s, const Fl_String &p); int ask_user_to_merge(const std::string &s, const std::string &p);
int analyse(); int analyse();
int apply(); int apply();
}; };
extern int merge_back(const Fl_String &s, const Fl_String &p, int task); extern int merge_back(const std::string &s, const std::string &p, int task);
#endif // _FLUID_MERGEBACK_H #endif // _FLUID_MERGEBACK_H
+3 -3
View File
@@ -512,7 +512,7 @@ static void cb_2(Fl_Button*, void* v) {
if (v == LOAD) return; if (v == LOAD) return;
Fl_String old_name = "Copy of "; std::string old_name = "Copy of ";
old_name.append(g_layout_list[g_layout_list.current_suite()].name_); old_name.append(g_layout_list[g_layout_list.current_suite()].name_);
const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str()); const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str());
if (new_name == NULL) if (new_name == NULL)
@@ -543,7 +543,7 @@ static void cb_w_layout_menu(Fl_Menu_Button*, void* v) {
static void cb_w_layout_menu_rename(Fl_Menu_*, void*) { static void cb_w_layout_menu_rename(Fl_Menu_*, void*) {
// Rename the current layout suite // Rename the current layout suite
Fl_String old_name = g_layout_list[g_layout_list.current_suite()].name_; std::string old_name = g_layout_list[g_layout_list.current_suite()].name_;
const char *new_name = fl_input("Enter a new name for the layout:", old_name.c_str()); const char *new_name = fl_input("Enter a new name for the layout:", old_name.c_str());
if (new_name == NULL) if (new_name == NULL)
return; return;
@@ -598,7 +598,7 @@ static void cb_w_layout_menu_save(Fl_Menu_*, void*) {
fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT); fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT);
fnfc.filter("FLUID Layouts\t*.fll\n"); fnfc.filter("FLUID Layouts\t*.fll\n");
Fl_String filename = g_layout_list.filename_; std::string filename = g_layout_list.filename_;
fnfc.directory(fl_filename_path(filename).c_str()); fnfc.directory(fl_filename_path(filename).c_str());
fnfc.preset_file(fl_filename_name(filename).c_str()); fnfc.preset_file(fl_filename_name(filename).c_str());
if (fnfc.show() != 0) return; if (fnfc.show() != 0) return;
+3 -3
View File
@@ -479,7 +479,7 @@ or just ".ext" to set extension.}
if (v == LOAD) return; if (v == LOAD) return;
Fl_String old_name = "Copy of "; std::string old_name = "Copy of ";
old_name.append(g_layout_list[g_layout_list.current_suite()].name_); old_name.append(g_layout_list[g_layout_list.current_suite()].name_);
const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str()); const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str());
if (new_name == NULL) if (new_name == NULL)
@@ -509,7 +509,7 @@ g_layout_list.update_dialogs();}
label {Rename...} label {Rename...}
callback {// Rename the current layout suite callback {// Rename the current layout suite
Fl_String old_name = g_layout_list[g_layout_list.current_suite()].name_; std::string old_name = g_layout_list[g_layout_list.current_suite()].name_;
const char *new_name = fl_input("Enter a new name for the layout:", old_name.c_str()); const char *new_name = fl_input("Enter a new name for the layout:", old_name.c_str());
if (new_name == NULL) if (new_name == NULL)
return; return;
@@ -570,7 +570,7 @@ g_layout_list.update_dialogs();}
fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT); fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT);
fnfc.filter("FLUID Layouts\\t*.fll\\n"); fnfc.filter("FLUID Layouts\\t*.fll\\n");
Fl_String filename = g_layout_list.filename_; std::string filename = g_layout_list.filename_;
fnfc.directory(fl_filename_path(filename).c_str()); fnfc.directory(fl_filename_path(filename).c_str());
fnfc.preset_file(fl_filename_name(filename).c_str()); fnfc.preset_file(fl_filename_name(filename).c_str());
if (fnfc.show() != 0) return; if (fnfc.show() != 0) return;
+15 -15
View File
@@ -108,7 +108,7 @@
#include <errno.h> #include <errno.h>
static Fl_String fltk_config_cmd; static std::string fltk_config_cmd;
static Fl_Process s_proc; static Fl_Process s_proc;
/** /**
@@ -129,7 +129,7 @@ bool shell_command_running() {
\param[in] defaultValue default value to be used if no preference was set \param[in] defaultValue default value to be used if no preference was set
\return 0 if the default value was used \return 0 if the default value was used
*/ */
char preferences_get(Fl_Preferences &prefs, const char *key, Fl_String &value, const Fl_String &defaultValue) { char preferences_get(Fl_Preferences &prefs, const char *key, std::string &value, const std::string &defaultValue) {
char *v = NULL; char *v = NULL;
char ret = prefs.get(key, v, defaultValue.c_str()); char ret = prefs.get(key, v, defaultValue.c_str());
value = v; value = v;
@@ -147,7 +147,7 @@ char preferences_get(Fl_Preferences &prefs, const char *key, Fl_String &value, c
\param[in] value set this entry to value (stops at the first nul character). \param[in] value set this entry to value (stops at the first nul character).
\return 0 if setting the value failed \return 0 if setting the value failed
*/ */
char preferences_set(Fl_Preferences &prefs, const char *key, const Fl_String &value) { char preferences_set(Fl_Preferences &prefs, const char *key, const std::string &value) {
return prefs.set(key, value.c_str()); return prefs.set(key, value.c_str());
} }
@@ -362,15 +362,15 @@ void shell_pipe_cb(FL_SOCKET, void*) {
// //
//} //}
static void expand_macro(Fl_String &cmd, const Fl_String &macro, const Fl_String &content) { static void expand_macro(std::string &cmd, const std::string &macro, const std::string &content) {
for (int i=0;;) { for (int i=0;;) {
i = cmd.find(macro, i); i = cmd.find(macro, i);
if (i==Fl_String::npos) break; if (i==std::string::npos) break;
cmd.replace(i, macro.size(), content); cmd.replace(i, macro.size(), content);
} }
} }
static void expand_macros(Fl_String &cmd) { static void expand_macros(std::string &cmd) {
expand_macro(cmd, "@BASENAME@", g_project.basename()); expand_macro(cmd, "@BASENAME@", g_project.basename());
expand_macro(cmd, "@PROJECTFILE_PATH@", g_project.projectfile_path()); expand_macro(cmd, "@PROJECTFILE_PATH@", g_project.projectfile_path());
expand_macro(cmd, "@PROJECTFILE_NAME@", g_project.projectfile_name()); expand_macro(cmd, "@PROJECTFILE_NAME@", g_project.projectfile_name());
@@ -381,11 +381,11 @@ static void expand_macros(Fl_String &cmd) {
expand_macro(cmd, "@TEXTFILE_PATH@", g_project.stringsfile_path()); expand_macro(cmd, "@TEXTFILE_PATH@", g_project.stringsfile_path());
expand_macro(cmd, "@TEXTFILE_NAME@", g_project.stringsfile_name()); expand_macro(cmd, "@TEXTFILE_NAME@", g_project.stringsfile_name());
// TODO: implement finding the script `fltk-config` for all platforms // TODO: implement finding the script `fltk-config` for all platforms
// if (cmd.find("@FLTK_CONFIG@") != Fl_String::npos) { // if (cmd.find("@FLTK_CONFIG@") != std::string::npos) {
// find_fltk_config(); // find_fltk_config();
// expand_macro(cmd, "@FLTK_CONFIG@", fltk_config_cmd.c_str()); // expand_macro(cmd, "@FLTK_CONFIG@", fltk_config_cmd.c_str());
// } // }
if (cmd.find("@TMPDIR@") != Fl_String::npos) if (cmd.find("@TMPDIR@") != std::string::npos)
expand_macro(cmd, "@TMPDIR@", get_tmpdir()); expand_macro(cmd, "@TMPDIR@", get_tmpdir());
} }
@@ -411,7 +411,7 @@ void show_terminal_window() {
\param[in] cmd the command that is sent to `/bin/sh -c ...` or `cmd.exe` on Windows machines \param[in] cmd the command that is sent to `/bin/sh -c ...` or `cmd.exe` on Windows machines
\param[in] flags various flags in preparation of the command \param[in] flags various flags in preparation of the command
*/ */
void run_shell_command(const Fl_String &cmd, int flags) { void run_shell_command(const std::string &cmd, int flags) {
if (cmd.empty()) { if (cmd.empty()) {
fl_alert("No shell command entered!"); fl_alert("No shell command entered!");
return; return;
@@ -419,7 +419,7 @@ void run_shell_command(const Fl_String &cmd, int flags) {
if (!prepare_shell_command(flags)) return; if (!prepare_shell_command(flags)) return;
Fl_String expanded_cmd = cmd; std::string expanded_cmd = cmd;
expand_macros(expanded_cmd); expand_macros(expanded_cmd);
if ( ((flags & Fd_Shell_Command::DONT_SHOW_TERMINAL) == 0) if ( ((flags & Fd_Shell_Command::DONT_SHOW_TERMINAL) == 0)
@@ -487,7 +487,7 @@ Fd_Shell_Command::Fd_Shell_Command(const Fd_Shell_Command *rhs)
\param[in] name is used as a stand-in for the command name and label \param[in] name is used as a stand-in for the command name and label
*/ */
Fd_Shell_Command::Fd_Shell_Command(const Fl_String &in_name) Fd_Shell_Command::Fd_Shell_Command(const std::string &in_name)
: name(in_name), : name(in_name),
label(in_name), label(in_name),
shortcut(0), shortcut(0),
@@ -511,13 +511,13 @@ Fd_Shell_Command::Fd_Shell_Command(const Fl_String &in_name)
\param[in] in_command the shell command that we want to run \param[in] in_command the shell command that we want to run
\param[in] in_flags some flags to tell FLUID to save the project, code, or strings before running the command \param[in] in_flags some flags to tell FLUID to save the project, code, or strings before running the command
*/ */
Fd_Shell_Command::Fd_Shell_Command(const Fl_String &in_name, Fd_Shell_Command::Fd_Shell_Command(const std::string &in_name,
const Fl_String &in_label, const std::string &in_label,
Fl_Shortcut in_shortcut, Fl_Shortcut in_shortcut,
Fd_Tool_Store in_storage, Fd_Tool_Store in_storage,
int in_condition, int in_condition,
const Fl_String &in_condition_data, const std::string &in_condition_data,
const Fl_String &in_command, const std::string &in_command,
int in_flags) int in_flags)
: name(in_name), : name(in_name),
label(in_label), label(in_label),
+14 -14
View File
@@ -39,11 +39,11 @@ struct Fl_Menu_Item;
class Fl_Widget; class Fl_Widget;
class Fl_Preferences; class Fl_Preferences;
char preferences_get(Fl_Preferences &prefs, const char *key, Fl_String &value, const Fl_String &defaultValue); char preferences_get(Fl_Preferences &prefs, const char *key, std::string &value, const std::string &defaultValue);
char preferences_set(Fl_Preferences &prefs, const char *key, const Fl_String &value); char preferences_set(Fl_Preferences &prefs, const char *key, const std::string &value);
void show_terminal_window(); void show_terminal_window();
void run_shell_command(const Fl_String &cmd, int flags); void run_shell_command(const std::string &cmd, int flags);
bool shell_command_running(void); bool shell_command_running(void);
class Fl_Process { class Fl_Process {
@@ -84,22 +84,22 @@ public:
DONT_SHOW_TERMINAL = 8, CLEAR_TERMINAL = 16, CLEAR_HISTORY = 32 }; // flags DONT_SHOW_TERMINAL = 8, CLEAR_TERMINAL = 16, CLEAR_HISTORY = 32 }; // flags
Fd_Shell_Command(); Fd_Shell_Command();
Fd_Shell_Command(const Fd_Shell_Command *rhs); Fd_Shell_Command(const Fd_Shell_Command *rhs);
Fd_Shell_Command(const Fl_String &in_name); Fd_Shell_Command(const std::string &in_name);
Fd_Shell_Command(const Fl_String &in_name, Fd_Shell_Command(const std::string &in_name,
const Fl_String &in_label, const std::string &in_label,
Fl_Shortcut in_shortcut, Fl_Shortcut in_shortcut,
Fd_Tool_Store in_storage, Fd_Tool_Store in_storage,
int in_condition, int in_condition,
const Fl_String &in_condition_data, const std::string &in_condition_data,
const Fl_String &in_command, const std::string &in_command,
int in_flags); int in_flags);
Fl_String name; std::string name;
Fl_String label; std::string label;
Fl_Shortcut shortcut; Fl_Shortcut shortcut;
Fd_Tool_Store storage; Fd_Tool_Store storage;
int condition; // always, hide, windows only, linux only, mac only, user, machine int condition; // always, hide, windows only, linux only, mac only, user, machine
Fl_String condition_data; // user name, machine name std::string condition_data; // user name, machine name
Fl_String command; std::string command;
int flags; // save_project, save_code, save_string, ... int flags; // save_project, save_code, save_string, ...
Fl_Menu_Item *shell_menu_item_; Fl_Menu_Item *shell_menu_item_;
void run(); void run();
@@ -128,8 +128,8 @@ public:
void clear(Fd_Tool_Store store); void clear(Fd_Tool_Store store);
// void move_up(); // void move_up();
// void move_down(); // void move_down();
// int load(const Fl_String &filename); // int load(const std::string &filename);
// int save(const Fl_String &filename); // int save(const std::string &filename);
void read(Fl_Preferences &prefs, Fd_Tool_Store storage); void read(Fl_Preferences &prefs, Fd_Tool_Store storage);
void write(Fl_Preferences &prefs, Fd_Tool_Store storage); void write(Fl_Preferences &prefs, Fd_Tool_Store storage);
void read(class Fd_Project_Reader*); void read(class Fd_Project_Reader*);
+3 -3
View File
@@ -551,7 +551,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
prefs_path_14 = home_path + "/.config"; prefs_path_14 = home_path + "/.config";
} else { } else {
if (prefs_path_14[prefs_path_14.size()-1]!='/') if (prefs_path_14[prefs_path_14.size()-1]!='/')
prefs_path_14.append('/'); prefs_path_14.append("/");
if (prefs_path_14.find("~/")==0) // starts with "~" if (prefs_path_14.find("~/")==0) // starts with "~"
prefs_path_14.replace(0, 1, home_path); prefs_path_14.replace(0, 1, home_path);
int h_env = prefs_path_14.find("${HOME}"); int h_env = prefs_path_14.find("${HOME}");
@@ -562,7 +562,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
prefs_path_14.replace(h_env, 5, home_path); prefs_path_14.replace(h_env, 5, home_path);
} }
if (prefs_path_14[prefs_path_14.size()-1]!='/') if (prefs_path_14[prefs_path_14.size()-1]!='/')
prefs_path_14.append('/'); prefs_path_14.append("/");
prefs_path_14.append(vendor); prefs_path_14.append(vendor);
// 2: If this base path does not exist, try the 1.3 path // 2: If this base path does not exist, try the 1.3 path
@@ -578,7 +578,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
} }
// 3: neither path exists, return the 1.4 file path and name // 3: neither path exists, return the 1.4 file path and name
prefs_path_14.append('/'); prefs_path_14.append("/");
prefs_path_14.append(application); prefs_path_14.append(application);
prefs_path_14.append(".prefs"); prefs_path_14.append(".prefs");
strlcpy(buffer, prefs_path_14.c_str(), FL_PATH_MAX); strlcpy(buffer, prefs_path_14.c_str(), FL_PATH_MAX);