diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 23:48:25 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 23:48:25 +0500 |
| commit | c53067d2f6cfd6e3c6b476c51ab8c4b931e40a30 (patch) | |
| tree | 95bfab59b2d9a38a57b6aa05244cab2d0435c7d2 /fluid/proj | |
| parent | 57860e277f2298ad6c0830b1492087cfa124c862 (diff) | |
wip
Diffstat (limited to 'fluid/proj')
| -rw-r--r-- | fluid/proj/i18n.cxx | 18 | ||||
| -rw-r--r-- | fluid/proj/i18n.h | 16 | ||||
| -rw-r--r-- | fluid/proj/mergeback.cxx | 54 | ||||
| -rw-r--r-- | fluid/proj/mergeback.h | 23 | ||||
| -rw-r--r-- | fluid/proj/undo.cxx | 10 | ||||
| -rw-r--r-- | fluid/proj/undo.h | 12 |
6 files changed, 76 insertions, 57 deletions
diff --git a/fluid/proj/i18n.cxx b/fluid/proj/i18n.cxx index d2b9b202c..dc4380bd4 100644 --- a/fluid/proj/i18n.cxx +++ b/fluid/proj/i18n.cxx @@ -28,7 +28,7 @@ using namespace fld::proj; Reset all project setting to create a new empty project. */ void I18n::reset() { - type = fld::I18n_Type::NONE; + type = FLD_I18N_TYPE_NONE; gnu_include = "<libintl.h>"; gnu_conditional = ""; @@ -53,33 +53,33 @@ void I18n::read(io::Project_Reader &f, const char *key) { } else if (!strcmp(key, "i18n_pos_set")) { posix_set = f.read_word(); } else if (!strcmp(key, "i18n_include")) { - if (type == fld::I18n_Type::GNU) { + if (type == FLD_I18N_TYPE_GNU) { gnu_include = f.read_word(); - } else if (type == fld::I18n_Type::POSIX) { + } else if (type == FLD_I18N_TYPE_POSIX) { posix_include = f.read_word(); } } else if (!strcmp(key, "i18n_conditional")) { - if (type == fld::I18n_Type::GNU) { + if (type == FLD_I18N_TYPE_GNU) { gnu_conditional = f.read_word(); - } else if (type == fld::I18n_Type::POSIX) { + } else if (type == FLD_I18N_TYPE_POSIX) { posix_conditional = f.read_word(); } } } void I18n::write(io::Project_Writer &f) const { - if ((type != fld::I18n_Type::NONE)) { + if ((type != FLD_I18N_TYPE_NONE)) { f.write_string("\ni18n_type %d", static_cast<int>(type)); switch (type) { - case fld::I18n_Type::NONE: + case FLD_I18N_TYPE_NONE: break; - case fld::I18n_Type::GNU : /* GNU gettext */ + case FLD_I18N_TYPE_GNU : /* GNU gettext */ f.write_string("\ni18n_include"); f.write_word(gnu_include); f.write_string("\ni18n_conditional"); f.write_word(gnu_conditional); f.write_string("\ni18n_gnu_function"); f.write_word(gnu_function); f.write_string("\ni18n_gnu_static_function"); f.write_word(gnu_static_function); break; - case fld::I18n_Type::POSIX : /* POSIX catgets */ + case FLD_I18N_TYPE_POSIX : /* POSIX catgets */ f.write_string("\ni18n_include"); f.write_word(posix_include); f.write_string("\ni18n_conditional"); f.write_word(posix_conditional); if (!posix_file.empty()) { diff --git a/fluid/proj/i18n.h b/fluid/proj/i18n.h index 30e09efae..0d9119ca2 100644 --- a/fluid/proj/i18n.h +++ b/fluid/proj/i18n.h @@ -26,12 +26,18 @@ class Project; /** Enumeration of available internationalization types. */ -enum class I18n_Type { - NONE = 0, ///< No i18n, all strings are litearals - GNU, ///< GNU gettext internationalization - POSIX ///< Posix catgets internationalization +typedef int I18n_Type; + +} // namespace fld + +enum { + FLD_I18N_TYPE_NONE = 0, ///< No i18n, all strings are litearals + FLD_I18N_TYPE_GNU, ///< GNU gettext internationalization + FLD_I18N_TYPE_POSIX ///< Posix catgets internationalization }; +namespace fld { + namespace io { class Project_Reader; class Project_Writer; @@ -48,7 +54,7 @@ public: Project &project_; /// One of the available internationalization types. - fld::I18n_Type type = I18n_Type::NONE; + fld::I18n_Type type = FLD_I18N_TYPE_NONE; /// Include file for GNU i18n, writes an #include statement into the source /// file. This is usually `<libintl.h>` or `"gettext.h"` for GNU gettext. std::string gnu_include = "<libintl.h>"; diff --git a/fluid/proj/mergeback.cxx b/fluid/proj/mergeback.cxx index 34e4e1361..016732795 100644 --- a/fluid/proj/mergeback.cxx +++ b/fluid/proj/mergeback.cxx @@ -263,7 +263,7 @@ void Mergeback::analyse_callback(unsigned long code_crc, unsigned long tag_crc, */ void Mergeback::analyse_code(unsigned long code_crc, unsigned long tag_crc, int uid) { Node *tp = proj_.tree.find_by_uid(uid); - if (tp && tp->is_a(Type::Code)) { + if (tp && tp->is_a(FLD_NODE_TYPE_Code)) { std::string code = tp->name(); code += "\n"; unsigned long project_crc = fld::io::Code_Writer::block_crc(code.c_str()); // check if the code and project crc are the same, so this modification was already applied @@ -361,10 +361,10 @@ void Mergeback::print_tag(FILE *out, Tag prev_type, Tag next_type, uint16_t uid, static const char *tag_lut[] = { "----------", "-- code --", " callback ", " callback " }; fputs("//fl ", out); // Distinct start of tag using utf8 // Indicate that the text above can be edited - if (prev_type != Tag::GENERIC) fputs("▲", out); - if (prev_type != Tag::GENERIC && next_type != Tag::GENERIC) fputc('/', out); + if (prev_type != FLD_MERGEBACK_TAG_GENERIC) fputs("▲", out); + if (prev_type != FLD_MERGEBACK_TAG_GENERIC && next_type != FLD_MERGEBACK_TAG_GENERIC) fputc('/', out); // Indicate that the text below can be edited - if (next_type != Tag::GENERIC) fputs("▼", out); + if (next_type != FLD_MERGEBACK_TAG_GENERIC) fputs("▼", out); fputc(' ', out); // Write the first 32 bit word as an encoded divider line uint32_t pt = static_cast<uint32_t>(prev_type); @@ -372,18 +372,18 @@ void Mergeback::print_tag(FILE *out, Tag prev_type, Tag next_type, uint16_t uid, uint32_t word = (0<<24) | (pt<<16) | (uid); // top 8 bit available for encoding type print_trichar32(out, word); // Write a string indicating the type of editable text - if ( next_type != Tag::GENERIC) { + if ( next_type != FLD_MERGEBACK_TAG_GENERIC) { fputs(tag_lut[nt], out); - } else if (prev_type != Tag::GENERIC) { + } else if (prev_type != FLD_MERGEBACK_TAG_GENERIC) { fputs(tag_lut[nt], out); } // Write the second 32 bit word as an encoded divider line print_trichar32(out, crc); // Repeat the intor pattern fputc(' ', out); - if (prev_type != Tag::GENERIC) fputs("▲", out); - if (prev_type != Tag::GENERIC && next_type != Tag::GENERIC) fputc('/', out); - if (next_type != Tag::GENERIC) fputs("▼", out); + if (prev_type != FLD_MERGEBACK_TAG_GENERIC) fputs("▲", out); + if (prev_type != FLD_MERGEBACK_TAG_GENERIC && next_type != FLD_MERGEBACK_TAG_GENERIC) fputc('/', out); + if (next_type != FLD_MERGEBACK_TAG_GENERIC) fputs("▼", out); fputs(" fl//\n", out); } @@ -431,24 +431,24 @@ int Mergeback::analyse() { code_crc = fld::io::Code_Writer::block_crc(line, -1, code_crc, &line_start); } else { // if this line has a tag, read all tag data - Tag tag_type = Tag::UNUSED_; + Tag tag_type = FLD_MERGEBACK_TAG_UNUSED_; uint16_t uid = 0; uint32_t tag_crc = 0; bool tag_ok = read_tag(tag, &tag_type, &uid, &tag_crc); - if (!tag_ok || tag_type==Tag::UNUSED_ ) { + if (!tag_ok || tag_type==FLD_MERGEBACK_TAG_UNUSED_ ) { tag_error = 1; return -1; } if (code_crc != tag_crc) { switch (tag_type) { - case Tag::GENERIC: + case FLD_MERGEBACK_TAG_GENERIC: num_changed_structure++; break; - case Tag::MENU_CALLBACK: - case Tag::WIDGET_CALLBACK: + case FLD_MERGEBACK_TAG_MENU_CALLBACK: + case FLD_MERGEBACK_TAG_WIDGET_CALLBACK: analyse_callback(code_crc, tag_crc, uid); break; - case Tag::CODE: + case FLD_MERGEBACK_TAG_CODE: analyse_code(code_crc, tag_crc, uid); break; default: break; @@ -483,7 +483,7 @@ int Mergeback::apply_callback(long block_end, long block_start, unsigned long co */ int Mergeback::apply_code(long block_end, long block_start, unsigned long code_crc, int uid) { Node *tp = proj_.tree.find_by_uid(uid); - if (tp && tp->is_a(Type::Code)) { + if (tp && tp->is_a(FLD_NODE_TYPE_Code)) { std::string cb = tp->name(); cb += "\n"; unsigned long project_crc = fld::io::Code_Writer::block_crc(cb.c_str()); if (project_crc!=code_crc) { @@ -525,18 +525,18 @@ int Mergeback::apply() { block_end = ::ftell(code); } else { // if this line has a tag, read all tag data - Tag tag_type = Tag::UNUSED_; + Tag tag_type = FLD_MERGEBACK_TAG_UNUSED_; uint16_t uid = 0; uint32_t tag_crc = 0; bool tag_ok = read_tag(tag, &tag_type, &uid, &tag_crc); - if (!tag_ok || tag_type==Tag::UNUSED_ ) { + if (!tag_ok || tag_type==FLD_MERGEBACK_TAG_UNUSED_ ) { tag_error = 1; return -1; } if (code_crc != tag_crc) { - if (tag_type==Tag::MENU_CALLBACK || tag_type==Tag::WIDGET_CALLBACK) { + if (tag_type==FLD_MERGEBACK_TAG_MENU_CALLBACK || tag_type==FLD_MERGEBACK_TAG_WIDGET_CALLBACK) { changed |= apply_callback(block_end, block_start, code_crc, uid); - } else if (tag_type==Tag::CODE) { + } else if (tag_type==FLD_MERGEBACK_TAG_CODE) { changed |= apply_code(block_end, block_start, code_crc, uid); } } @@ -562,7 +562,7 @@ int Mergeback::merge_back(const std::string &s, const std::string &p, Task task) code = fl_fopen(s.c_str(), "rb"); if (!code) return -2; do { // no actual loop, just make sure we close the code file - if (task == Task::ANALYSE) { + if (task == FLD_MERGEBACK_TASK_ANALYSE) { analyse(); if (tag_error) {ret = -1; break; } if (num_changed_structure) ret |= 1; @@ -571,14 +571,14 @@ int Mergeback::merge_back(const std::string &s, const std::string &p, Task task) if (num_possible_override) ret |= 8; break; } - if (task == Task::INTERACTIVE) { + if (task == FLD_MERGEBACK_TASK_INTERACTIVE) { analyse(); ret = ask_user_to_merge(s, p); if (ret != 1) return ret; - task = Task::APPLY; // fall through + task = FLD_MERGEBACK_TASK_APPLY; // fall through } - if (task == Task::APPLY_IF_SAFE) { + if (task == FLD_MERGEBACK_TASK_APPLY_IF_SAFE) { analyse(); if (tag_error || num_changed_structure || num_possible_override) { ret = -1; @@ -588,9 +588,9 @@ int Mergeback::merge_back(const std::string &s, const std::string &p, Task task) ret = 0; break; } - task = Task::APPLY; // fall through + task = FLD_MERGEBACK_TASK_APPLY; // fall through } - if (task == Task::APPLY) { + if (task == FLD_MERGEBACK_TASK_APPLY) { ret = apply(); if (ret == 1) { proj_.set_modflag(1); @@ -660,7 +660,7 @@ int mergeback_code_files(Project &proj, Mergeback::Feedback feedback) if (code_filename.empty()) code_filename = proj.codefile_path() + proj.codefile_name(); if (!Fluid.batch_mode) proj.enter_project_dir(); - int c = merge_back(proj, code_filename, proj_filename, Mergeback::Task::INTERACTIVE); + int c = merge_back(proj, code_filename, proj_filename, FLD_MERGEBACK_TASK_INTERACTIVE); if (c>0) { // update the project to reflect the changes proj.set_modflag(1); diff --git a/fluid/proj/mergeback.h b/fluid/proj/mergeback.h index a515b1815..48cc4e400 100644 --- a/fluid/proj/mergeback.h +++ b/fluid/proj/mergeback.h @@ -33,15 +33,26 @@ namespace proj { /** Class that implements the MergeBack functionality. \see merge_back(const std::string &s, int task) */ +enum { + FLD_MERGEBACK_TAG_GENERIC = 0, + FLD_MERGEBACK_TAG_CODE, + FLD_MERGEBACK_TAG_MENU_CALLBACK, + FLD_MERGEBACK_TAG_WIDGET_CALLBACK, + FLD_MERGEBACK_TAG_UNUSED_ +}; + +enum { + FLD_MERGEBACK_TASK_ANALYSE = 0, + FLD_MERGEBACK_TASK_INTERACTIVE, + FLD_MERGEBACK_TASK_APPLY, + FLD_MERGEBACK_TASK_APPLY_IF_SAFE = 3 +}; + class Mergeback { public: - enum class Tag { - GENERIC = 0, CODE, MENU_CALLBACK, WIDGET_CALLBACK, UNUSED_ - }; - enum class Task { - ANALYSE = 0, INTERACTIVE, APPLY, APPLY_IF_SAFE = 3 - }; + typedef int Tag; + typedef int Task; enum Feedback { QUIET = 0, CHATTY = 1 }; protected: /// Apply mergeback for this project. diff --git a/fluid/proj/undo.cxx b/fluid/proj/undo.cxx index 0f1a478fb..01d1b68c2 100644 --- a/fluid/proj/undo.cxx +++ b/fluid/proj/undo.cxx @@ -82,7 +82,7 @@ char *Undo::filename(int level) { void Undo::redo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); - once_type_ = OnceType::ALWAYS; + once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; if (current_ >= last_) { fl_beep(); @@ -126,7 +126,7 @@ void Undo::redo() { void Undo::undo() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); - once_type_ = OnceType::ALWAYS; + once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; if (current_ <= 0) { fl_beep(); @@ -184,8 +184,8 @@ void Undo::undo() { \return 1 if the checkpoint was set, 0 if this is a repeating event */ int Undo::checkpoint(OnceType type) { - if (type == OnceType::ALWAYS) { - once_type_ = OnceType::ALWAYS; + if (type == FLD_UNDO_ONCETYPE_ALWAYS) { + once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; return 0; } if (paused_) return 0; @@ -209,7 +209,7 @@ void Undo::checkpoint() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); - once_type_ = OnceType::ALWAYS; + once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; // Save the current UI to a checkpoint file... const char *file = filename(current_); diff --git a/fluid/proj/undo.h b/fluid/proj/undo.h index 7bb02b72f..de038908a 100644 --- a/fluid/proj/undo.h +++ b/fluid/proj/undo.h @@ -27,14 +27,16 @@ class Project; namespace proj { +enum { + FLD_UNDO_ONCETYPE_ALWAYS = 0, + FLD_UNDO_ONCETYPE_WINDOW_RESIZE +}; + class Undo { public: - enum class OnceType { - ALWAYS = 0, - WINDOW_RESIZE - }; + typedef int OnceType; /// Link Undo class to this project. Project &proj_; @@ -53,7 +55,7 @@ public: // length w/o filename unsigned int path_len_ = 0; /// Suspend further undos of the same type - OnceType once_type_ = OnceType::ALWAYS; + OnceType once_type_ = FLD_UNDO_ONCETYPE_ALWAYS; public: |
