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

View File

@ -601,9 +601,9 @@ needs no additional maintenance. It is also C++98 compatible. For example:
\code
#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_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_INLINE_CALLBACK_2( inline_cb_btn_2,

View File

@ -24,7 +24,7 @@ class ExternalCodeEditor {
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)
const char *filename_;
Fl_String command_line_;
std::string command_line_;
int last_error_;
int alert_pipe_[2];
bool alert_pipe_open_;

View File

@ -18,7 +18,6 @@
#include "Fl_Group_Type.h"
#include "settings_panel.h"
#include "shell_command.h" // get and set Fl_String preferences
#include "file.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.
*/
void Fd_Layout_Suite::update_label() {
Fl_String sym;
std::string sym;
switch (storage_) {
case FD_STORE_INTERNAL: sym.assign("@fd_beaker "); 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.
*/
int Fd_Layout_List::load(const Fl_String &filename) {
int Fd_Layout_List::load(const std::string &filename) {
remove_all(FD_STORE_FILE);
Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, Fl_Preferences::C_LOCALE);
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.
*/
int Fd_Layout_List::save(const Fl_String &filename) {
int Fd_Layout_List::save(const std::string &filename) {
assert(this);
Fl_Preferences prefs(filename.c_str(), "layout.fluid.fltk.org", NULL, (Fl_Preferences::Root)(Fl_Preferences::C_LOCALE|Fl_Preferences::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) {
Fl_Preferences prefs_list(prefs, "Layouts");
Fl_String cs;
std::string cs;
int cp = 0;
preferences_get(prefs_list, "current_suite", cs, "");
prefs_list.get("current_preset", cp, 0);
@ -741,7 +740,7 @@ void Fd_Layout_List::read(Fd_Project_Reader *in) {
const char *key;
key = in->read_word(1);
if (key && !strcmp(key, "{")) {
Fl_String cs;
std::string cs;
int cp = 0;
for (;;) {
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
\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;
for (int i = 0; i < list_size_; ++i) {
Fd_Layout_Suite &suite = list_[i];

View File

@ -119,7 +119,7 @@ public:
bool list_is_static_;
int current_suite_;
int current_preset_;
Fl_String filename_;
std::string filename_;
public:
Fd_Layout_List();
~Fd_Layout_List();
@ -127,7 +127,7 @@ public:
void update_menu_labels();
int current_suite() const { return current_suite_; }
void current_suite(int ix);
void current_suite(Fl_String);
void current_suite(std::string);
int current_preset() const { return current_preset_; }
void current_preset(int ix);
Fd_Layout_Suite &operator[](int ix) { return list_[ix]; }
@ -135,8 +135,8 @@ public:
void rename(const char *name);
void capacity(int);
int load(const Fl_String &filename);
int save(const Fl_String &filename);
int load(const std::string &filename);
int save(const std::string &filename);
void write(Fl_Preferences &prefs, Fd_Tool_Store storage);
void read(Fl_Preferences &prefs, Fd_Tool_Store storage);
void write(Fd_Project_Writer*);

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
Fl_Margin win_margin(0, 0, 0, 0);
Fl_Margin win_blend(10, 10, 10, 10);

View File

@ -53,7 +53,7 @@ extern const int FL_SNAP_TO_WINDOW;
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

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
\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_Widget_Type *w;
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
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();
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");
@ -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());
}
}
Fl_String loc_include, loc_conditional;
std::string loc_include, loc_conditional;
if (g_project.i18n_type==FD_I18N_GNU) {
loc_include = g_project.i18n_gnu_include;
loc_conditional = g_project.i18n_gnu_conditional;

View File

@ -29,7 +29,7 @@ struct Fd_Text_Tree;
struct Fd_Pointer_Tree;
int is_id(char c);
int write_strings(const Fl_String &filename);
int write_strings(const std::string &filename);
class Fd_Code_Writer
{

View File

@ -182,9 +182,9 @@ void update_codeview_cb(class Fl_Button*, void*) {
cv_strings->buffer()->loadfile(fn);
cv_strings->scroll(top, 0);
} 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;
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;
// generate the code and load the files

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->scroll(top, 0);
} 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;
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;
// generate the code and load the files

View File

@ -148,7 +148,7 @@ int modflag_c = 0;
/// Application work directory, stored here when temporarily changing to the source code directory.
/// \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.
/// \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
/// 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
Fl_String g_header_filename_arg;
std::string g_header_filename_arg;
/// 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
Fl_String g_autodoc_path;
std::string g_autodoc_path;
/// path to store temporary files during app run
/// \see tmpdir_create_called
Fl_String tmpdir_path;
std::string tmpdir_path;
/// true if the temporary file path was already created
/// \see tmpdir_path
@ -267,7 +267,7 @@ void Fluid_Project::update_settings_dialog() {
\param[in] str directory or path name
\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];
if (last !='/' && last != '\\')
return str + "/";
@ -293,7 +293,7 @@ static void create_tmpdir() {
// C:/Windows/Temp/
// C:\Users\<username>\AppData\Local\Temp
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];
char tempdir[FL_PATH_MAX+1];
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);
tempdir[wn] = 0;
}
Fl_String path = tempdir;
std::string path = tempdir;
end_with_slash(path);
path += name;
fl_make_path(path.c_str());
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
#else
fl_snprintf(buf, sizeof(buf)-1, "fluid-%d/", getpid());
Fl_String name = buf;
Fl_String path = fl_getenv("TMPDIR");
std::string name = buf;
std::string path = fl_getenv("TMPDIR");
if (!path.empty()) {
end_with_slash(path);
path += name;
@ -319,7 +319,7 @@ static void create_tmpdir() {
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
}
if (tmpdir_path.empty()) {
path = Fl_String("/tmp/") + name;
path = std::string("/tmp/") + name;
fl_make_path(path.c_str());
if (fl_access(path.c_str(), 6) == 0) tmpdir_path = path;
}
@ -327,7 +327,7 @@ static void create_tmpdir() {
if (tmpdir_path.empty()) {
char pbuf[FL_PATH_MAX+1];
fluid_prefs.get_userdata_path(pbuf, FL_PATH_MAX);
path = Fl_String(pbuf);
path = std::string(pbuf);
end_with_slash(path);
path += name;
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);
if (n_de >= 0) {
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_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
string if no directory could be created.
*/
const Fl_String &get_tmpdir() {
const std::string &get_tmpdir() {
if (!tmpdir_create_called)
create_tmpdir();
return tmpdir_path;
@ -465,7 +465,7 @@ void enter_project_dir() {
// store the current working directory for later
app_work_dir = fl_getcwd();
// 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) {
fprintf(stderr, "** Fluid internal error: enter_project_dir() can't chdir to %s: %s\n",
project_path.c_str(), strerror(errno));
@ -610,7 +610,7 @@ void save_cb(Fl_Widget *, void *v) {
if (fnfc.show() != 0) return;
c = fnfc.filename();
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"
"Do you want to replace it?", "Cancel",
"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, ...)
\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;
dialog.title(title.c_str());
dialog.type(Fl_Native_File_Chooser::BROWSE_FILE);
dialog.filter("FLUID Files\t*.f[ld]\n");
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.preset_file(fl_filename_name(current_project_file).c_str());
}
if (dialog.show() != 0)
return Fl_String();
return Fl_String(dialog.filename());
return std::string();
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
\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);
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
Fl_String new_filename = filename_arg;
std::string new_filename = filename_arg;
if (new_filename.empty()) {
new_filename = open_project_filechooser(title);
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
\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
if (confirm_project_clear() == false)
return false;
// ask for a filename if none was given
Fl_String new_filename = filename_arg;
std::string new_filename = filename_arg;
if (new_filename.empty()) {
new_filename = open_project_filechooser("Open Project File");
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
*/
void apple_open_cb(const char *c) {
open_project_file(Fl_String(c));
open_project_file(std::string(c));
}
#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/`.
\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));
}
@ -1094,7 +1094,7 @@ Fl_String Fluid_Project::projectfile_path() const {
Get the project file name including extension, for example `test.fl`.
\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);
}
@ -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/`.
\return the path ending in '/'
*/
Fl_String Fluid_Project::codefile_path() const {
Fl_String path = fl_filename_path(code_file_name);
std::string Fluid_Project::codefile_path() const {
std::string path = fl_filename_path(code_file_name);
if (batch_mode)
return end_with_slash(fl_filename_absolute(path, g_launch_path));
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`.
\return the file name without path
*/
Fl_String Fluid_Project::codefile_name() const {
Fl_String name = fl_filename_name(code_file_name);
std::string Fluid_Project::codefile_name() const {
std::string name = fl_filename_name(code_file_name);
if (name.empty()) {
return fl_filename_setext(fl_filename_name(filename), ".cxx");
} 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/`.
\return the path ending in '/'
*/
Fl_String Fluid_Project::headerfile_path() const {
Fl_String path = fl_filename_path(header_file_name);
std::string Fluid_Project::headerfile_path() const {
std::string path = fl_filename_path(header_file_name);
if (batch_mode)
return end_with_slash(fl_filename_absolute(path, g_launch_path));
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`.
\return the file name without path
*/
Fl_String Fluid_Project::headerfile_name() const {
Fl_String name = fl_filename_name(header_file_name);
std::string Fluid_Project::headerfile_name() const {
std::string name = fl_filename_name(header_file_name);
if (name.empty()) {
return fl_filename_setext(fl_filename_name(filename), ".h");
} else if (name[0] == '.') {
@ -1160,7 +1160,7 @@ Fl_String Fluid_Project::headerfile_name() const {
batch mode.
\return the path ending in '/'
*/
Fl_String Fluid_Project::stringsfile_path() const {
std::string Fluid_Project::stringsfile_path() const {
if (batch_mode)
return g_launch_path;
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`.
\return the file name without path
*/
Fl_String Fluid_Project::stringsfile_name() const {
std::string Fluid_Project::stringsfile_name() const {
switch (i18n_type) {
default: return fl_filename_setext(fl_filename_name(filename), ".txt");
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.
\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), "");
}
@ -1218,14 +1218,14 @@ int write_code_files(bool dont_show_completion_dialog)
// -- generate the file names with absolute paths
Fd_Code_Writer f;
Fl_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 code_filename = g_project.codefile_path() + g_project.codefile_name();
std::string header_filename = g_project.headerfile_path() + g_project.headerfile_name();
// -- write the code and header files
if (!batch_mode) enter_project_dir();
int x = f.write_code(code_filename.c_str(), header_filename.c_str());
Fl_String code_filename_rel = fl_filename_relative(code_filename);
Fl_String header_filename_rel = fl_filename_relative(header_filename);
std::string code_filename_rel = fl_filename_relative(code_filename);
std::string header_filename_rel = fl_filename_relative(header_filename);
if (!batch_mode) leave_project_dir();
// -- 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;
}
Fl_String proj_filename = g_project.projectfile_path() + g_project.projectfile_name();
Fl_String code_filename;
std::string proj_filename = g_project.projectfile_path() + g_project.projectfile_name();
std::string code_filename;
#if 1
if (!batch_mode) {
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);
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);
if (batch_mode) {
if (x) {
@ -1626,7 +1626,7 @@ void print_menu_cb(Fl_Widget *, void *) {
fl_draw(date, w - (int)fl_width(date), fl_height());
// 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());
// 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_open_cb(Fl_Widget *, void *) { open_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*) {
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]));
if (absolute_history[i][0]) {
// 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);
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
else history_item[i].flags = 0;
@ -2003,7 +2003,7 @@ void update_history(const char *flname) {
// Put the new file at the top...
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);
// Update the menu items as needed...
@ -2072,9 +2072,9 @@ void set_modflag(int mf, int mfc) {
}
if (main_window) {
Fl_String basename;
std::string basename;
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());
char mod_star = modflag ? '*' : ' ';
char mod_c_star = modflag_c ? '*' : ' ';

View File

@ -90,11 +90,11 @@ extern int batch_mode;
extern int pasteoffset;
extern Fl_String g_code_filename_arg;
extern Fl_String g_header_filename_arg;
extern Fl_String g_launch_path;
extern std::string g_code_filename_arg;
extern std::string g_header_filename_arg;
extern std::string g_launch_path;
extern Fl_String g_autodoc_path;
extern std::string g_autodoc_path;
// ---- project class declaration
@ -117,39 +117,39 @@ public:
void reset();
void update_settings_dialog();
Fl_String projectfile_path() const;
Fl_String projectfile_name() const;
Fl_String codefile_path() const;
Fl_String codefile_name() const;
Fl_String headerfile_path() const;
Fl_String headerfile_name() const;
Fl_String stringsfile_path() const;
Fl_String stringsfile_name() const;
Fl_String basename() const;
std::string projectfile_path() const;
std::string projectfile_name() const;
std::string codefile_path() const;
std::string codefile_name() const;
std::string headerfile_path() const;
std::string headerfile_name() const;
std::string stringsfile_path() const;
std::string stringsfile_name() const;
std::string basename() const;
/// One of the available internationalization types.
Fd_I18n_Type i18n_type;
/// Include file for GNU i18n, writes an #include statement into the source
/// 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.
Fl_String i18n_gnu_conditional;
std::string i18n_gnu_conditional;
/// For the gettext/intl.h options, this is the function that translates text
/// 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
/// 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
/// 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.
Fl_String i18n_pos_conditional;
std::string i18n_pos_conditional;
/// Name of the nl_catd database
Fl_String i18n_pos_file;
std::string i18n_pos_file;
/// 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
int include_H_from_C;
@ -165,9 +165,9 @@ public:
int code_file_set;
int write_mergeback_data;
/// 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.
Fl_String code_file_name;
std::string code_file_name;
};
extern Fluid_Project g_project;
@ -180,7 +180,7 @@ extern void leave_project_dir();
extern void set_filename(const char *c);
extern void set_modflag(int mf, int mfc=-1);
extern const Fl_String &get_tmpdir();
extern const std::string &get_tmpdir();
// ---- public callback functions

View File

@ -18,10 +18,10 @@
\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>.
\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
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
\see fl_filename_name(const char *filename)
*/
Fl_String fl_filename_name(const Fl_String &filename) {
return Fl_String(fl_filename_name(filename.c_str()));
std::string fl_filename_name(const std::string &filename) {
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
\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 *name = fl_filename_name(base);
if (name) {
return Fl_String(base, (int)(name-base));
return std::string(base, (int)(name-base));
} 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
\see fl_filename_ext(const char *buf)
*/
Fl_String fl_filename_ext(const Fl_String &filename) {
return Fl_String(fl_filename_ext(filename.c_str()));
std::string fl_filename_ext(const std::string &filename) {
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
\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];
fl_strlcpy(buffer, filename.c_str(), FL_PATH_MAX);
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
\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];
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
\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];
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
\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];
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
\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];
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
\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];
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
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
*/
Fl_String fl_getcwd() {
std::string fl_getcwd() {
char 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
\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
static const char *ell = "...";
static const int ell_bytes = 3;
// Replace the start of a path with "~" if it matches the home directory
static Fl_String tilde = "~/";
static Fl_String home;
static std::string tilde = "~/";
static std::string home;
static int home_chars = -1;
if (home_chars==-1) {
home = fl_filename_expand(tilde);
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__)
bool starts_with_home = fl_utf_strncasecmp(home.c_str(), filename.c_str(), home_chars)==0;
#else

View File

@ -18,10 +18,10 @@
\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>.
\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
or major release after 1.4.x (i.e. 1.5 or maybe 4.0).
@ -41,17 +41,17 @@
#include "../src/Fl_String.H"
Fl_String fl_filename_shortened(const Fl_String &filename, int maxchars);
Fl_String fl_filename_name(const Fl_String &filename);
Fl_String fl_filename_path(const Fl_String &filename);
Fl_String fl_filename_ext(const Fl_String &filename);
Fl_String fl_filename_setext(const Fl_String &filename, const Fl_String &new_extension);
Fl_String fl_filename_expand(const Fl_String &from);
Fl_String fl_filename_absolute(const Fl_String &from);
Fl_String fl_filename_absolute(const Fl_String &from, const Fl_String &base);
Fl_String fl_filename_relative(const Fl_String &from);
Fl_String fl_filename_relative(const Fl_String &from, const Fl_String &base);
Fl_String fl_getcwd();
std::string fl_filename_shortened(const std::string &filename, int maxchars);
std::string fl_filename_name(const std::string &filename);
std::string fl_filename_path(const std::string &filename);
std::string fl_filename_ext(const std::string &filename);
std::string fl_filename_setext(const std::string &filename, const std::string &new_extension);
std::string fl_filename_expand(const std::string &from);
std::string fl_filename_absolute(const std::string &from);
std::string fl_filename_absolute(const std::string &from, const std::string &base);
std::string fl_filename_relative(const std::string &from);
std::string fl_filename_relative(const std::string &from, const std::string &base);
std::string fl_getcwd();
# endif

View File

@ -101,7 +101,7 @@ extern void redraw_browser();
\return -2 if no code file was found
\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) {
Fd_Mergeback mergeback;
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
\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 here = ::ftell(code);
::fseek(code, start, SEEK_SET);
@ -165,7 +165,7 @@ Fl_String Fd_Mergeback::read_and_unindent_block(long start, long end) {
else
block[bsize] = 0;
unindent(block);
Fl_String str = block;
std::string str = block;
::free(block);
::fseek(code, here, SEEK_SET);
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
(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) {
fl_message("Comparing\n \"%s\"\nto\n \"%s\"\n\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);
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.";
if (num_possible_override)
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) {
Fl_Type *tp = Fl_Type::find_by_uid(uid);
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());
// check if the code and project crc are the same, so this modification was already applied
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) {
Fl_Type *tp = Fl_Type::find_by_uid(uid);
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());
// check if the code and project crc are the same, so this modification was already applied
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) {
Fl_Type *tp = Fl_Type::find_by_uid(uid);
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());
if (project_crc!=code_crc) {
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) {
Fl_Type *tp = Fl_Type::find_by_uid(uid);
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());
if (project_crc!=code_crc) {
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
\return -1 if an error was found in a tag
\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;
code = fl_fopen(s.c_str(), "rb");
if (!code) return -2;

View File

@ -38,7 +38,7 @@ const int FD_MERGEBACK_APPLY = 2;
const int FD_MERGEBACK_APPLY_IF_SAFE = 3;
/** 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
{
@ -59,7 +59,7 @@ protected:
int num_possible_override;
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_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);
@ -68,13 +68,13 @@ protected:
public:
Fd_Mergeback();
~Fd_Mergeback();
int merge_back(const Fl_String &s, const Fl_String &p, int task);
int ask_user_to_merge(const Fl_String &s, const Fl_String &p);
int merge_back(const std::string &s, const std::string &p, int task);
int ask_user_to_merge(const std::string &s, const std::string &p);
int analyse();
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

View File

@ -512,7 +512,7 @@ static void cb_2(Fl_Button*, void* v) {
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_);
const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str());
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*) {
// 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());
if (new_name == NULL)
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.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT);
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.preset_file(fl_filename_name(filename).c_str());
if (fnfc.show() != 0) return;

View File

@ -479,7 +479,7 @@ or just ".ext" to set extension.}
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_);
const char *new_name = fl_input("Enter a name for the new layout:", old_name.c_str());
if (new_name == NULL)
@ -509,7 +509,7 @@ g_layout_list.update_dialogs();}
label {Rename...}
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());
if (new_name == NULL)
return;
@ -570,7 +570,7 @@ g_layout_list.update_dialogs();}
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.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.preset_file(fl_filename_name(filename).c_str());
if (fnfc.show() != 0) return;

View File

@ -108,7 +108,7 @@
#include <errno.h>
static Fl_String fltk_config_cmd;
static std::string fltk_config_cmd;
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
\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 ret = prefs.get(key, v, defaultValue.c_str());
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).
\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());
}
@ -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;;) {
i = cmd.find(macro, i);
if (i==Fl_String::npos) break;
if (i==std::string::npos) break;
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, "@PROJECTFILE_PATH@", g_project.projectfile_path());
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_NAME@", g_project.stringsfile_name());
// 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();
// 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());
}
@ -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] 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()) {
fl_alert("No shell command entered!");
return;
@ -419,7 +419,7 @@ void run_shell_command(const Fl_String &cmd, int flags) {
if (!prepare_shell_command(flags)) return;
Fl_String expanded_cmd = cmd;
std::string expanded_cmd = cmd;
expand_macros(expanded_cmd);
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
*/
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),
label(in_name),
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_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,
const Fl_String &in_label,
Fd_Shell_Command::Fd_Shell_Command(const std::string &in_name,
const std::string &in_label,
Fl_Shortcut in_shortcut,
Fd_Tool_Store in_storage,
int in_condition,
const Fl_String &in_condition_data,
const Fl_String &in_command,
const std::string &in_condition_data,
const std::string &in_command,
int in_flags)
: name(in_name),
label(in_label),

View File

@ -39,11 +39,11 @@ struct Fl_Menu_Item;
class Fl_Widget;
class Fl_Preferences;
char preferences_get(Fl_Preferences &prefs, const char *key, Fl_String &value, const Fl_String &defaultValue);
char preferences_set(Fl_Preferences &prefs, const char *key, const Fl_String &value);
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 std::string &value);
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);
class Fl_Process {
@ -84,22 +84,22 @@ public:
DONT_SHOW_TERMINAL = 8, CLEAR_TERMINAL = 16, CLEAR_HISTORY = 32 }; // flags
Fd_Shell_Command();
Fd_Shell_Command(const Fd_Shell_Command *rhs);
Fd_Shell_Command(const Fl_String &in_name);
Fd_Shell_Command(const Fl_String &in_name,
const Fl_String &in_label,
Fd_Shell_Command(const std::string &in_name);
Fd_Shell_Command(const std::string &in_name,
const std::string &in_label,
Fl_Shortcut in_shortcut,
Fd_Tool_Store in_storage,
int in_condition,
const Fl_String &in_condition_data,
const Fl_String &in_command,
const std::string &in_condition_data,
const std::string &in_command,
int in_flags);
Fl_String name;
Fl_String label;
std::string name;
std::string label;
Fl_Shortcut shortcut;
Fd_Tool_Store storage;
int condition; // always, hide, windows only, linux only, mac only, user, machine
Fl_String condition_data; // user name, machine name
Fl_String command;
std::string condition_data; // user name, machine name
std::string command;
int flags; // save_project, save_code, save_string, ...
Fl_Menu_Item *shell_menu_item_;
void run();
@ -128,8 +128,8 @@ public:
void clear(Fd_Tool_Store store);
// void move_up();
// void move_down();
// int load(const Fl_String &filename);
// int save(const Fl_String &filename);
// int load(const std::string &filename);
// int save(const std::string &filename);
void read(Fl_Preferences &prefs, Fd_Tool_Store storage);
void write(Fl_Preferences &prefs, Fd_Tool_Store storage);
void read(class Fd_Project_Reader*);

View File

@ -551,7 +551,7 @@ char *Fl_Unix_System_Driver::preference_user_rootnode(
prefs_path_14 = home_path + "/.config";
} else {
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 "~"
prefs_path_14.replace(0, 1, home_path);
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);
}
if (prefs_path_14[prefs_path_14.size()-1]!='/')
prefs_path_14.append('/');
prefs_path_14.append("/");
prefs_path_14.append(vendor);
// 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
prefs_path_14.append('/');
prefs_path_14.append("/");
prefs_path_14.append(application);
prefs_path_14.append(".prefs");
strlcpy(buffer, prefs_path_14.c_str(), FL_PATH_MAX);