Initial cleanup for the FileEdtitor.

This commit is contained in:
Relintai 2022-07-15 19:47:59 +02:00
parent 614464725b
commit 3f304192f4
2 changed files with 768 additions and 1417 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,32 @@
#ifndef FILEEDITOR_H #ifndef FILEEDITOR_H
#define FILEEDITOR_H #define FILEEDITOR_H
#include "core/reference.h"
#include "core/ustring.h"
#include "core/variant.h"
#include "core/vector.h"
#include "scene/gui/control.h"
class MenuButton;
class PopupMenu;
class HSplitContainer;
class VBoxContainer;
class ItemList;
class LineEdit;
class OptionButton;
class FileDialog;
class AcceptDialog;
class ConfirmationDialog;
class LastOpenedFiles;
class DynamicFont;
class VanillaEditor;
class FileEditor : public Control { class FileEditor : public Control {
GDCLASS(FileEditor, Control); GDCLASS(FileEditor, Control);
public: public:
String get_DIRECTORY();
void set_DIRECTORY(const String &val);
String get_EXCEPTIONS();
void set_EXCEPTIONS(const String &val);
PoolStringArray get_EXTENSIONS();
void set_EXTENSIONS(const PoolStringArray &val);
MenuButton get_*file_btn();
void set_*file_btn(const MenuButton &val);
MenuButton get_*preview_btn();
void set_*preview_btn(const MenuButton &val);
MenuButton get_*settings_btn();
void set_*settings_btn(const MenuButton &val);
PopupMenu get_*file_btn_popup();
void set_*file_btn_popup(const PopupMenu &val);
PopupMenu get_*preview_btn_popup();
void set_*preview_btn_popup(const PopupMenu &val);
PopupMenu get_*settings_btn_popup();
void set_*settings_btn_popup(const PopupMenu &val);
HSplitContainer get_*editor_container();
void set_*editor_container(const HSplitContainer &val);
VBoxContainer get_*file_container();
void set_*file_container(const VBoxContainer &val);
ItemList get_*open_file_list();
void set_*open_file_list(const ItemList &val);
VBoxContainer get_*split_editor_container();
void set_*split_editor_container(const VBoxContainer &val);
LineEdit get_*open_file_name();
void set_*open_file_name(const LineEdit &val);
OptionButton get_*wrap_btn();
void set_*wrap_btn(const OptionButton &val);
OptionButton get_*map_btn();
void set_*map_btn(const OptionButton &val);
FileDialog get_*file_list();
void set_*file_list(const FileDialog &val);
AcceptDialog get_*new_file_dialogue();
void set_*new_file_dialogue(const AcceptDialog &val);
LineEdit get_*new_file_dialogue_name();
void set_*new_file_dialogue_name(const LineEdit &val);
ConfirmationDialog get_*confirmation_close();
void set_*confirmation_close(const ConfirmationDialog &val);
FileDialog get_*select_font_dialog();
void set_*select_font_dialog(const FileDialog &val);
Reference get_*LastOpenedFiles();
void set_*LastOpenedFiles(const Reference &val);
Variant get_Variant();
void set_Variant(const Variant &val);
Variant get_Variant();
void set_Variant(const Variant &val);
Array get_directories();
void set_directories(const Array &val);
Array get_files();
void set_files(const Array &val);
int get_current_file_index() const;
void set_current_file_index(const int val);
String get_current_file_path();
void set_current_file_path(const String &val);
bool get_save_as() const;
void set_save_as(const bool val);
Control get_*current_editor();
void set_*current_editor(const Control &val);
Ref<DynamicFont> get_current_font();
void set_current_font(const Ref<DynamicFont> &val);
bool get_editing_file() const;
void set_editing_file(const bool val);
enum FileMenuOptions { enum FileMenuOptions {
FILE_MENU_OPTION_NEW = 0, FILE_MENU_OPTION_NEW = 0,
FILE_MENU_OPTION_OPEN = 1, FILE_MENU_OPTION_OPEN = 1,
FILE_MENU_OPTION_CLOSE = 2, FILE_MENU_OPTION_CLOSE = 2,
@ -113,104 +35,96 @@ class FileEditor : public Control {
FILE_MENU_OPTION_DELETE = 5, FILE_MENU_OPTION_DELETE = 5,
FILE_MENU_OPTION_SEARCH = 6, FILE_MENU_OPTION_SEARCH = 6,
FILE_MENU_OPTION_REPLACE = 7, FILE_MENU_OPTION_REPLACE = 7,
}; };
void _init();
void _ready(); void _ready();
void connect_signals(); void connect_signals();
void create_selected_file(); void create_selected_file();
void open_selected_file(); void open_selected_file();
void delete_selected_file(); void delete_selected_file();
void save_current_file_as(); void save_current_file_as();
void _on_file_btn_pressed(const int index); void _on_file_btn_pressed(const int index);
void _on_preview_btn_pressed(const int id); void _on_preview_btn_pressed(const int id);
void _on_settings_btn_pressed(const int index); void _on_settings_btn_pressed(const int index);
void _on_font_selected(const String &font_path); void _on_font_selected(const String &font_path);
void _on_fileitem_pressed(const int index); void _on_fileitem_pressed(const int index);
void open_file(const String &path, const String &font = "null"); void open_file(const String &path, const String &font = "null");
void generate_file_item(const String &path, const Control &veditor); void generate_file_item(const String &path, Control *veditor);
Control open_in_vanillaeditor(const String &path); VanillaEditor *open_in_vanillaeditor(const String &path);
void close_file(const int index); void close_file(const int index);
void confirm_close(const int index); void confirm_close(const int index);
void _on_update_file(); void _on_update_file();
void delete_file(const PoolStringArray &files_selected); void delete_file(const PoolStringArray &files_selected);
void open_new_file_dialogue(); void open_new_file_dialogue();
void open_file_list(); void open_file_list();
void create_new_file(const String &given_path); void create_new_file(const String &given_path);
void save_file(const String &current_path); void save_file(const String &current_path);
void clean_editor(); void clean_editor();
void csv_preview(); void csv_preview();
void bbcode_preview(); void bbcode_preview();
void markdown_preview(); void markdown_preview();
void html_preview(); void html_preview();
void _on_vanillaeditor_text_changed(); void _on_vanillaeditor_text_changed();
void update_list(); void update_list();
void on_wrap_button(const int index); void on_wrap_button(const int index);
void on_minimap_button(const int index); void on_minimap_button(const int index);
void check_file_preview(const String &file); void check_file_preview(const String &file);
void _on_ConfirmationDialog_confirmed(); void _on_ConfirmationDialog_confirmed();
FileEditor(); FileEditor();
~FileEditor(); ~FileEditor();
protected: protected:
static void _bind_methods(); static void _bind_methods();
//tool String DIRECTORY;
}; String EXCEPTIONS;
String DIRECTORY = "res://"; Vector<String> EXTENSIONS;
String EXCEPTIONS = "addons";
PoolStringArray EXTENSIONS = [; MenuButton *file_btn;
"*.txt ; Plain Text File",; MenuButton *preview_btn;
"*.rtf ; Rich Text Format File",; MenuButton *settings_btn;
"*.log ; Log File",;
"*.md ; MD File",; PopupMenu *file_btn_popup;
"*.doc ; WordPad Document",; PopupMenu *preview_btn_popup;
"*.doc ; Microsoft Word Document",; PopupMenu *settings_btn_popup;
"*.docm ; Word Open XML Macro-Enabled Document",;
"*.docx ; Microsoft Word Open XML Document",; HSplitContainer *editor_container;
"*.bbs ; Bulletin Board System Text",; VBoxContainer *file_container;
"*.dat ; Data File",; ItemList *_open_file_list;
"*.xml ; XML File",; VBoxContainer *split_editor_container;
"*.sql ; SQL database file",; LineEdit *open_file_name;
"*.json ; JavaScript Object Notation File",; OptionButton *wrap_btn;
"*.html ; HyperText Markup Language",; OptionButton *map_btn;
"*.csv ; Comma-separated values",;
"*.cfg ; Configuration File",; FileDialog *file_list;
"*.ini ; Initialization File (same as .cfg Configuration File)",; AcceptDialog *new_file_dialogue;
"*.csv ; Comma-separated values File",; LineEdit *new_file_dialogue_name;
"*.res ; Resource File",; ConfirmationDialog *confirmation_close;
]; FileDialog *select_font_dialog;
MenuButton *file_btn = null;
MenuButton *preview_btn = null; Ref<LastOpenedFiles> last_opened_files;
MenuButton *settings_btn = null;
PopupMenu *file_btn_popup = null; Array directories;
PopupMenu *preview_btn_popup = null; Array files;
PopupMenu *settings_btn_popup = null;
HSplitContainer *editor_container = null; int current_file_index;
VBoxContainer *file_container = null; String current_file_path;
ItemList *open_file_list = null; bool save_as;
VBoxContainer *split_editor_container = null;
LineEdit *open_file_name = null; VanillaEditor *current_editor;
OptionButton *wrap_btn = null;
OptionButton *map_btn = null;
FileDialog *file_list = null;
AcceptDialog *new_file_dialogue = null;
LineEdit *new_file_dialogue_name = null;
ConfirmationDialog *confirmation_close = null;
FileDialog *select_font_dialog = null;
Reference *LastOpenedFiles = null;
Variant = preload("res://addons/file-editor/scripts/Preview.gd");
Variant = preload("res://addons/file-editor/scripts/VanillaEditor.gd");
Array directories = ;
Array files = ;
int current_file_index = -1;
String current_file_path = ;
bool save_as = false;
Control *current_editor;
Ref<DynamicFont> current_font; Ref<DynamicFont> current_font;
bool editing_file = false; bool editing_file;
}; };
#endif #endif