From c1242cb1600f3e73be9a6ac9eca6c9ccad4a0341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Tue, 13 Oct 2020 17:17:22 +0200 Subject: [PATCH 1/5] Update file for #25 --- addons/file-editor/scripts/FileEditor.gd | 77 +++++++++---------- addons/file-editor/scripts/LastOpenedFiles.gd | 5 ++ addons/file-editor/scripts/VanillaEditor.gd | 7 +- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/addons/file-editor/scripts/FileEditor.gd b/addons/file-editor/scripts/FileEditor.gd index fede799..f907a95 100644 --- a/addons/file-editor/scripts/FileEditor.gd +++ b/addons/file-editor/scripts/FileEditor.gd @@ -66,9 +66,7 @@ var current_ini_editor : Control var current_csv_editor : Control var current_font : DynamicFont - func _ready(): - clean_editor() update_version() connect_signals() @@ -361,7 +359,7 @@ func open_file(path : String, font : String = "null"): current_file_path = path var vanilla_editor = open_in_vanillaeditor(path) - if font != "null": + if font != "null" and vanilla_editor.get("custom_fonts/font")!=null: vanilla_editor.set_font(font) var ini_editor = open_in_inieditor(path) var csv_editor = open_in_csveditor(path) @@ -372,47 +370,42 @@ func open_file(path : String, font : String = "null"): current_editor.show() func generate_file_item(path : String , veditor : Control , inieditor : Control, csveditor : Control): - OpenFileName.set_text(path) - OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true) - current_file_index = OpenFileList.get_item_count()-1 - OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor]) - OpenFileList.select(OpenFileList.get_item_count()-1) + OpenFileName.set_text(path) + OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true) + current_file_index = OpenFileList.get_item_count()-1 + OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor]) + OpenFileList.select(OpenFileList.get_item_count()-1) func open_in_vanillaeditor(path : String) -> Control: - var editor = VanillaEditor.instance() - SplitEditorContainer.add_child(editor,true) - - if current_editor and current_editor!=editor: - editor.show() - current_editor.hide() - if current_csv_editor and current_csv_editor.visible: - current_csv_editor.hide() - if current_ini_editor and current_ini_editor.visible: - current_ini_editor.hide() - - current_editor = editor - - - editor.connect("text_changed",self,"_on_vanillaeditor_text_changed") - - var current_file : File = File.new() - current_file.open(path,File.READ) - var current_content = "" - current_content = current_file.get_as_text() - - var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path)) - - current_file.close() - - editor.new_file_open(current_content,last_modified,current_file_path) - - update_list() - - if WrapBTN.get_selected_id() == 1: - current_editor.set_wrap_enabled(true) - - - return editor + var editor = VanillaEditor.instance() + SplitEditorContainer.add_child(editor,true) + + if current_editor and current_editor!=editor: + editor.show() + current_editor.hide() + if current_csv_editor and current_csv_editor.visible: + current_csv_editor.hide() + if current_ini_editor and current_ini_editor.visible: + current_ini_editor.hide() + + current_editor = editor + editor.connect("text_changed",self,"_on_vanillaeditor_text_changed") + + var current_file : File = File.new() + current_file.open(path,File.READ) + var current_content = "" + current_content = current_file.get_as_text() + + var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path)) + + current_file.close() + editor.new_file_open(current_content,last_modified,current_file_path) + update_list() + + if WrapBTN.get_selected_id() == 1: + current_editor.set_wrap_enabled(true) + + return editor func open_in_inieditor(path : String) -> Control: var extension = path.get_file().get_extension() diff --git a/addons/file-editor/scripts/LastOpenedFiles.gd b/addons/file-editor/scripts/LastOpenedFiles.gd index e47f517..aca2e5f 100644 --- a/addons/file-editor/scripts/LastOpenedFiles.gd +++ b/addons/file-editor/scripts/LastOpenedFiles.gd @@ -3,6 +3,8 @@ extends Node const lastopenedfile_path : String = "res://addons/file-editor/lastopenedfiles.lastcfg" +var editor_plugin : EditorPlugin = EditorPlugin.new() + func _ready(): pass @@ -40,3 +42,6 @@ func store_editor_fonts(file_name : String, font_path : String): file.load(lastopenedfile_path) file.set_value("Fonts",file_name,font_path) file.save(lastopenedfile_path) + +func get_editor_font(): + return editor_plugin.get_editor_interface().get_editor_settings().get_setting("interface/editor/code_font") diff --git a/addons/file-editor/scripts/VanillaEditor.gd b/addons/file-editor/scripts/VanillaEditor.gd index 4068a3e..618aceb 100644 --- a/addons/file-editor/scripts/VanillaEditor.gd +++ b/addons/file-editor/scripts/VanillaEditor.gd @@ -25,7 +25,6 @@ var current_path = "" var current_filename = "" var Preview = load("res://addons/file-editor/scenes/Preview.tscn") - var search_flag = 0 signal text_changed() @@ -39,6 +38,7 @@ func _ready(): ReadOnly.set("custom_icons/unchecked",IconLoader.load_icon_from_name("edit")) add_to_group("vanilla_editor") + load_default_font() func set_font(font_path : String) -> void: var dynamic_font : DynamicFont = DynamicFont.new() @@ -47,6 +47,11 @@ func set_font(font_path : String) -> void: dynamic_font.set_font_data(dynamic_font_data) TextEditor.set("custom_fonts/font",dynamic_font) +func load_default_font() -> void: + var default_font = LastOpenedFiles.get_editor_font() + if default_font: + set_font(default_font) + func set_wrap_enabled(enabled:bool): TextEditor.set_wrap_enabled(enabled) TextEditor.update() From 75aaedf56b6d63dbf52e46ff0a257e55eac22032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Tue, 13 Oct 2020 17:17:55 +0200 Subject: [PATCH 2/5] Update version to 1.7.7 --- addons/file-editor/plugin.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/file-editor/plugin.cfg b/addons/file-editor/plugin.cfg index 89ea660..c622640 100644 --- a/addons/file-editor/plugin.cfg +++ b/addons/file-editor/plugin.cfg @@ -3,5 +3,5 @@ name="File Editor" description="An internal file editor to view and edit text files in your project folder." author="Nicolo 'fenix' Santilio" -version="1.7.6" +version="1.7.7" script="scripts/file-editor.gd" From bc97f46b786779491cdd8aa383a8ec9b1d97df2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Tue, 13 Oct 2020 17:18:08 +0200 Subject: [PATCH 3/5] Delete README.md --- addons/file-editor/README.md | 63 ------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 addons/file-editor/README.md diff --git a/addons/file-editor/README.md b/addons/file-editor/README.md deleted file mode 100644 index 99b9c4c..0000000 --- a/addons/file-editor/README.md +++ /dev/null @@ -1,63 +0,0 @@ -Check my **[Discord](https://discord.gg/KnJGY9S)** to stay updated on this repository. -*(Recommended since the AssetLibrary is not automatically updated)* - -This plugin is now supported in [Godot Extended Library Discord](https://discord.gg/JNrcucg), check out the [Godot Extended Library Project](https://github.com/godot-extended-libraries)! - -# Godot Text Editor -A little plugin to easy-way manage your text files inside your project folder. - -Author: *"Nicolo (fenix) Santilio"* -Version: *1.7.1* -Godot Version: *3.2.1* - -**This repository was pushed directly from Godot Engine Editor thanks to [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integration)!** - -## What is this? -This is a little plugin I've made to easily edit text files in your project folder. - -## How does it work? -You can open an existing file, create a new file and delete a file. -When opening / creating a file, the editor will open and you will be able to edit it and save it. -You can just *Save* the file, or *Save file As* a new file (if it is a new file but also to make some copies). -You will also be able to see some informations about the file you are editing (time and date of last edit) and you can set your editor to *Read Only* if you don't want to make changes but still read the content of the file. -Multiple files can be opened in different tabs. -![preview1](https://i.imgur.com/BbZzKzD.png)![preview2](https://i.imgur.com/asggk4f.png) ![preview3](https://i.imgur.com/omReRZr.png) ![preview4](https://i.imgur.com/d8pMJsE.png) - -## How do I install it? -**Manual** -Just download this whole repository and put it in your `res://addons` folder inside the project you want to work on. -Then, go to `Project > Plugins > "File Editor" > Status > Activate`. - -**Automatic** -You can find this plugin in the AssetLib of Godot Engine Editor. Just download it from there and everything should be fine! -(Remember to activate this plugin) - -## Supported formats -+ "*.txt ; Plain Text File", -+ "*.rtf ; Rich Text Format File", -+ "*.log ; Log File", -+ "*.md ; MD File", -+ "*.doc ; WordPad Document", -+ "*.doc ; Microsoft Word Document", -+ "*.docm ; Word Open XML Macro-Enabled Document", -+ "*.docx ; Microsoft Word Open XML Document", -+ "*.bbs ; Bulletin Board System Text", -+ "*.dat ; Data File", -+ "*.xml ; XML File", -+ "*.sql ; SQL database file", -+ "*.json ; JavaScript Object Notation File", -+ "*.html ; HyperText Markup Language" -+ "*.cfg ; Configuration File" -+ "*.ini ; Initialization File (same as .cfg Configuration File)" -+ "*.csv ; Comma-separated values File" - -#### Current version -To check all the features included in the current version, please read the [VERSION file](./VERSION.md) - -#### Upcoming features -To check all the features I'm currently working on, please read the [TODO file](./TODO.md) - -# Disclaimer -This addon was built for a **personal use** intention. It was released as an open source plugin in the hope that it could be useful to the Godot Engine Community. -As a "work in progress" project, there is *no warranty* for any eventual issue and bug that may broke your project. -I don't assume any responsibility for possible corruptions of your project files. It is always advisable to keep a copy of your files and check any changes. From 6d709e6c732c8d2760d44c7e87388b8bb74ac11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Tue, 13 Oct 2020 17:18:15 +0200 Subject: [PATCH 4/5] Delete TODO.md --- addons/file-editor/TODO.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 addons/file-editor/TODO.md diff --git a/addons/file-editor/TODO.md b/addons/file-editor/TODO.md deleted file mode 100644 index 01cb33c..0000000 --- a/addons/file-editor/TODO.md +++ /dev/null @@ -1,3 +0,0 @@ -### to do (v-0.x.x) -- Popup dialog when closing a tab if there is new content -- Module for markdown support/conversion From cb7508ba47b46798ed136fbb9a31f396701b7e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Santilio?= Date: Tue, 13 Oct 2020 17:18:23 +0200 Subject: [PATCH 5/5] Delete VERSION.md --- addons/file-editor/VERSION.md | 114 ---------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 addons/file-editor/VERSION.md diff --git a/addons/file-editor/VERSION.md b/addons/file-editor/VERSION.md deleted file mode 100644 index 04afa11..0000000 --- a/addons/file-editor/VERSION.md +++ /dev/null @@ -1,114 +0,0 @@ -**version 0.0.1** -*added* -- Plugin Created - ------------------------ - -**version 0.1.1** -*added* -- "Create new File" option -- "Open File" option -- "Delete File" option -- "Save File" option -- "Save File As.." option - ------------------------ - -**version 0.1.2** -*fixed* -- Repository Installation, folder order - ------------------------ - -**version 0.2.5** -*removed* -- Old layout - -*added* -- New Layout -- Last modified time and date -- Tabs - ------------------------ - -**version 0.3.1** -*added* -- Version check -- Preview support -- Context menu in editor -- BBCode converter -- Light Mardkwon converter (DEMO) - ------------------------ - -**version 1.2.1** -*removed* -- Old layout, the plugin won't appear in docs -- Icons file extensions, plugin size reduced -- Old Mardkwon preview method - -*added* -- More supported files -1. "*.dat ; Data File", -2. "*.xml ; XML File", -3. "*.sql ; SQL database file", -4. "*.json ; JavaScript Object Notation File", -5. "*.html ; HyperText Markup Language", -- New Markdown preview method ( Markdown -> BBCode converter) -- New HTML preview method ( HTML -> BBCode converter) -- New Plugin Layout: a new ButtonTool "File" in you TopBar will appear -- Error check -- Message popups for closing unsaved files - ------------------------ - -**version 1.4.3** -*removed* -- Old layout - -*added* -- More supported files: -1. "*.cfg ; Configuration File", -2. "*.ini ; Initialization File (same as .cfg Configuration File)", -- Added some sample files -- Memorize system of last opened files -- Added *Editor* button , you can now choose which editor to use: -1. Vanilla Editor (simple text editor) -2. Cfg/Ini Editor (table editor for Cfg/Ini files) - Editors are automatically updated, so if you update a cfg/ini file in the Vanilla Editor it will be updated in the Cfg/Ini Editor, and viceversa -- Added editor shorcuts: -1. *Ctrl + N* (new file) -2. *Ctrl + O* (open file) -3. *Ctrl + Alt + C* (close file) -4. *Ctrl + S* (save file) -5. *Ctrl + Alt + S* (save file as...) -6. *Ctrl + D* (delete file) -7. *Ctrl + 1* (Vanilla Editor) -8. *Ctrl + 3* (Cfg/Ini Editor) - ------------------------ - -**version 1.6.0** -*fixed* -- Each opened file now has own editor: unsaved changes are no longer erased if a new file is opened without saving the previous opened file - -*added* -- Custom Syntax Highlighting for each file type (.md, .cfg/.ini, .html, .bbs) -- Characters counter in VanillaEditor -- String searcher in VanillaEditor (with custom shortcut *Ctrl + F*) -- String replacer in VanillaEditor (with custom shortcut *Ctrl + R*) - ------------------------ - -**version 1.6.4** -*added* -- CSV VisualEditor (shortcut *Ctrl+2*): - - you can now read and edit CSV files which importing them as simple CSV files (and not translate file) -- MiniMap drawer in VanillaEditor -- SoftWrap / NoWrap in VanillaEditor -- **Version 3.2alpha2 supported** - ---------------------- - -**version 1.7.1** -- several bug fixes