Add files via upload

This commit is contained in:
fenix-hub 2019-10-03 16:06:46 +02:00 committed by GitHub
parent 087492cad1
commit 9aa62ae732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 440 additions and 219 deletions

View File

@ -1,58 +1,58 @@
# Godot Text Editor
A little plugin to easy-way manage your text files inside your project folder.
Author: *"Nicolo (fenix) Santilio"*
Version: *0.3.3*
Godot Version: *3.1.1-stable*
**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.
Always remember to save your file when you close the tab!
![preview](https://i.imgur.com/RLQoWt8.png)![preview2](https://i.imgur.com/A3kHV1k.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"
#### 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.
# Want to contact me?
I'm planning to create a Discord group to collect each plugin I've made (and I will make), but until then you can directly talk with my via e-mail at *n.santilio97@gmail.com*
Check my **[Discord](https://discord.gg/KnJGY9S)** to stay updated on this repository.
*(Recommended since the AssetLibrary is not automatically updated)*
# Godot Text Editor
A little plugin to easy-way manage your text files inside your project folder.
Author: *"Nicolo (fenix) Santilio"*
Version: *1.2.1*
Godot Version: *3.1.1-stable*
**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.
![preview](https://i.imgur.com/LcrGCGS.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"
#### 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.

View File

@ -1,49 +1,65 @@
**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 0.3.3**
*added* file support:
+ "*.dat ; Data File",
+ "*.xml ; XML File",
+ "*.sql ; SQL database file",
+ "*.json ; JavaScript Object Notation File"
**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
-----------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View File

@ -1,7 +1,7 @@
[plugin]
[plugin]
name="File Editor"
description="An internal file editor to view and edit text files in your project folder."
author="Nicolò 'fenix' Santilio"
version="0.3.3"
author="Nicolo 'fenix' Santilio"
version="1.2.1"
script="scripts/file-editor.gd"

View File

@ -1,16 +1,13 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/file-editor/scripts/FileEditor.gd" type="Script" id=1]
[ext_resource path="res://addons/file-editor/icons/new.svg" type="Texture" id=2]
[ext_resource path="res://addons/file-editor/icons/file.svg" type="Texture" id=3]
[ext_resource path="res://addons/file-editor/icons/delete.svg" type="Texture" id=4]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=2]
[sub_resource type="DynamicFont" id=1]
[sub_resource type="DynamicFont" id=6]
size = 13
font_data = ExtResource( 5 )
font_data = ExtResource( 2 )
[sub_resource type="StyleBoxFlat" id=2]
[sub_resource type="StyleBoxFlat" id=7]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.196078, 0.231373, 0.309804, 1 )
@ -20,7 +17,7 @@ border_width_right = 1
border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0
[sub_resource type="StyleBoxFlat" id=3]
[sub_resource type="StyleBoxFlat" id=8]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 )
@ -30,7 +27,7 @@ border_width_right = 1
border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0
[sub_resource type="StyleBoxFlat" id=4]
[sub_resource type="StyleBoxFlat" id=9]
bg_color = Color( 0.121569, 0.145098, 0.192157, 1 )
draw_center = false
border_width_left = 1
@ -42,57 +39,64 @@ border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
[node name="FileEditor" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 )
[node name="Container" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 6.0
margin_right = -5.0
margin_bottom = -7.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Buttons" type="HBoxContainer" parent="Container"]
margin_right = 1024.0
margin_bottom = 22.0
margin_right = 1013.0
margin_bottom = 20.0
[node name="newfile_btn" type="Button" parent="Container/Buttons"]
margin_right = 337.0
margin_bottom = 22.0
size_flags_horizontal = 3
margin_right = 110.0
margin_bottom = 20.0
text = "Create new File"
icon = ExtResource( 2 )
flat = true
[node name="openfile_btn" type="Button" parent="Container/Buttons"]
margin_left = 341.0
margin_right = 678.0
margin_bottom = 22.0
size_flags_horizontal = 3
margin_left = 114.0
margin_right = 188.0
margin_bottom = 20.0
text = "Open File"
icon = ExtResource( 3 )
flat = true
[node name="deletefile_btn" type="Button" parent="Container/Buttons"]
margin_left = 682.0
margin_right = 1019.0
margin_bottom = 22.0
size_flags_horizontal = 3
margin_left = 192.0
margin_right = 274.0
margin_bottom = 20.0
text = "Delete File"
icon = ExtResource( 4 )
flat = true
[node name="version" type="Label" parent="Container/Buttons"]
margin_left = 1023.0
margin_top = 2.0
margin_right = 1023.0
margin_bottom = 19.0
custom_fonts/font = SubResource( 1 )
margin_left = 974.0
margin_top = 1.0
margin_right = 1013.0
margin_bottom = 18.0
size_flags_horizontal = 10
custom_fonts/font = SubResource( 6 )
custom_colors/font_color = Color( 0.121569, 0.145098, 0.192157, 1 )
text = "v1.2.1"
align = 1
[node name="Editor" type="TabContainer" parent="Container"]
visible = false
margin_top = 32.0
margin_right = 1024.0
margin_top = 26.0
margin_right = 1000.0
margin_bottom = 600.0
size_flags_vertical = 3
custom_styles/tab_fg = SubResource( 2 )
custom_styles/tab_bg = SubResource( 3 )
custom_styles/panel = SubResource( 4 )
size_flags_horizontal = 3
size_flags_vertical = 11
custom_styles/tab_fg = SubResource( 7 )
custom_styles/tab_bg = SubResource( 8 )
custom_styles/panel = SubResource( 9 )
custom_colors/font_color_fg = Color( 1, 1, 1, 1 )
tab_align = 0
drag_to_rearrange_enabled = true
@ -104,7 +108,7 @@ margin_bottom = 600.0
size_flags_vertical = 3
popup_exclusive = true
dialog_hide_on_ok = true
filters = PoolStringArray( "*.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" )
filters = PoolStringArray( "*.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" )
[node name="NewFileDialogue" type="AcceptDialog" parent="."]
editor/display_folded = true
@ -124,7 +128,7 @@ margin_bottom = -36.0
[node name="Label" type="Label" parent="NewFileDialogue/VBoxContainer"]
margin_right = 280.0
margin_bottom = 17.0
margin_bottom = 16.0
size_flags_vertical = 3
text = "Insert file name (no extension needed)"
align = 1
@ -132,11 +136,29 @@ valign = 1
[node name="new_filename" type="LineEdit" parent="NewFileDialogue/VBoxContainer"]
margin_left = 40.0
margin_top = 21.0
margin_top = 20.0
margin_right = 240.0
margin_bottom = 45.0
margin_bottom = 44.0
rect_min_size = Vector2( 200, 0 )
size_flags_horizontal = 6
size_flags_vertical = 3
clear_button_enabled = true
placeholder_text = "example"
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -323.5
margin_top = -37.5
margin_right = 323.5
margin_bottom = 37.5
window_title = "Unsaved changes"
dialog_text = "There are some unsaved changes.
Press \"OK\" if you want to close this tab anyway, or \"cancel\" if you want to keep on editing your file."
[node name="VSeparator" type="VSeparator" parent="."]
visible = false
anchor_bottom = 1.0
margin_right = 24.0

View File

@ -1,15 +1,15 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=12 format=2]
[ext_resource path="res://addons/file-editor/scripts/FileScene.gd" type="Script" id=1]
[ext_resource path="res://addons/file-editor/icons/read.svg" type="Texture" id=2]
[ext_resource path="res://addons/file-editor/icons/edit.png" type="Texture" id=3]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=2]
[sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 )
[sub_resource type="StyleBoxEmpty" id=9]
[sub_resource type="StyleBoxEmpty" id=2]
[sub_resource type="StyleBoxEmpty" id=3]
@ -23,25 +23,21 @@ bg_color = Color( 0.145098, 0.172549, 0.231373, 1 )
[sub_resource type="StyleBoxEmpty" id=7]
[sub_resource type="DynamicFont" id=8]
font_data = ExtResource( 4 )
font_data = ExtResource( 2 )
[node name="filename" type="VBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_vertical = 3
script = ExtResource( 1 )
[node name="HSeparator" type="HSeparator" parent="."]
margin_right = 1016.0
margin_right = 1024.0
margin_bottom = 4.0
[node name="TopBar" type="HBoxContainer" parent="."]
margin_top = 8.0
margin_right = 1016.0
margin_right = 1024.0
margin_bottom = 28.0
[node name="VSeparator" type="VSeparator" parent="TopBar"]
@ -56,31 +52,31 @@ custom_styles/hover = SubResource( 1 )
custom_styles/normal = SubResource( 1 )
text = "File"
flat = false
items = [ "Save File", null, 0, false, false, 0, 0, null, "", false, "Save file As...", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Normal Preview", null, 0, false, false, 2, 0, null, "", false, "BBCode Preview", null, 0, false, false, 3, 0, null, "", false, "Markdown Preview (DEMO)", null, 0, false, false, 4, 0, null, "", false ]
items = [ "Save File", null, 0, false, false, 0, 0, null, "", false, "Save file As...", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Normal Preview", null, 0, false, false, 2, 0, null, "", false, "BBCode Preview", null, 0, false, false, 3, 0, null, "", false, "Markdown Preview", null, 0, false, false, 4, 0, null, "", false, "HTML Preview", null, 0, false, false, 5, 0, null, "", false ]
[node name="filepath" type="Label" parent="TopBar"]
margin_left = 519.0
margin_left = 523.0
margin_top = 3.0
margin_right = 519.0
margin_right = 523.0
margin_bottom = 17.0
size_flags_horizontal = 6
[node name="close_btn" type="Button" parent="TopBar"]
margin_left = 988.0
margin_right = 1008.0
margin_left = 996.0
margin_right = 1016.0
margin_bottom = 20.0
size_flags_horizontal = 8
text = "X"
[node name="VSeparator2" type="VSeparator" parent="TopBar"]
margin_left = 1012.0
margin_right = 1016.0
margin_left = 1020.0
margin_right = 1024.0
margin_bottom = 20.0
[node name="TextEditor" type="TextEdit" parent="."]
margin_top = 32.0
margin_right = 1016.0
margin_bottom = 541.0
margin_right = 1024.0
margin_bottom = 577.0
size_flags_vertical = 3
syntax_highlighting = true
show_line_numbers = true
@ -93,30 +89,41 @@ caret_blink_speed = 1.0
caret_moving_by_right_click = false
[node name="FileInfo" type="HBoxContainer" parent="."]
editor/display_folded = true
margin_top = 545.0
margin_right = 1016.0
margin_bottom = 564.0
margin_top = 581.0
margin_right = 1024.0
margin_bottom = 600.0
custom_constants/separation = 2
[node name="VSeparator4" type="VSeparator" parent="FileInfo"]
margin_right = 5.0
margin_bottom = 19.0
rect_min_size = Vector2( 5, 0 )
custom_styles/separator = SubResource( 9 )
[node name="lastmodified_icon" type="TextureRect" parent="FileInfo"]
margin_left = 7.0
margin_right = 7.0
margin_bottom = 19.0
stretch_mode = 4
[node name="Label" type="Label" parent="FileInfo"]
margin_left = 9.0
margin_top = 2.0
margin_right = 125.0
margin_right = 134.0
margin_bottom = 16.0
text = "Last modified time:"
[node name="lastmodified" type="Label" parent="FileInfo"]
margin_left = 129.0
margin_left = 136.0
margin_top = 2.0
margin_right = 129.0
margin_right = 136.0
margin_bottom = 16.0
[node name="Readonly" type="CheckBox" parent="FileInfo"]
margin_left = 929.0
margin_right = 1008.0
margin_left = 939.0
margin_right = 1018.0
margin_bottom = 19.0
size_flags_horizontal = 10
custom_icons/checked = ExtResource( 2 )
custom_icons/unchecked = ExtResource( 3 )
custom_styles/hover = SubResource( 2 )
custom_styles/pressed = SubResource( 3 )
custom_styles/focus = SubResource( 4 )
@ -130,6 +137,8 @@ text = "Can Edit"
flat = true
[node name="VSeparator3" type="VSeparator" parent="FileInfo"]
margin_left = 1012.0
margin_right = 1016.0
margin_left = 1020.0
margin_right = 1024.0
margin_bottom = 19.0
rect_min_size = Vector2( 4, 0 )
[connection signal="text_changed" from="TextEditor" to="." method="_on_TextEditor_text_changed"]

View File

@ -7,21 +7,21 @@
[ext_resource path="res://addons/file-editor/fonts/Carlito-Bold.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://addons/file-editor/fonts/Carlito-Regular.ttf" type="DynamicFontData" id=6]
[sub_resource type="DynamicFont" id=5]
[sub_resource type="DynamicFont" id=1]
use_mipmaps = true
use_filter = true
font_data = ExtResource( 2 )
[sub_resource type="DynamicFont" id=1]
[sub_resource type="DynamicFont" id=2]
font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=2]
[sub_resource type="DynamicFont" id=3]
font_data = ExtResource( 4 )
[sub_resource type="DynamicFont" id=3]
[sub_resource type="DynamicFont" id=4]
font_data = ExtResource( 5 )
[sub_resource type="DynamicFont" id=4]
[sub_resource type="DynamicFont" id=5]
font_data = ExtResource( 6 )
[node name="Preview" type="WindowDialog"]
@ -43,11 +43,11 @@ anchor_bottom = 1.0
margin_right = 863.0
margin_bottom = 505.0
size_flags_vertical = 3
custom_fonts/mono_font = SubResource( 5 )
custom_fonts/bold_italics_font = SubResource( 1 )
custom_fonts/italics_font = SubResource( 2 )
custom_fonts/bold_font = SubResource( 3 )
custom_fonts/normal_font = SubResource( 4 )
custom_fonts/mono_font = SubResource( 1 )
custom_fonts/bold_italics_font = SubResource( 2 )
custom_fonts/italics_font = SubResource( 3 )
custom_fonts/bold_font = SubResource( 4 )
custom_fonts/normal_font = SubResource( 5 )
bbcode_enabled = true
scroll_following = true
[connection signal="popup_hide" from="." to="." method="_on_Preview_popup_hide"]

View File

@ -31,7 +31,8 @@ var EXTENSIONS : PoolStringArray = [
"*.dat ; Data File",
"*.xml ; XML File",
"*.sql ; SQL database file",
"*.json ; JavaScript Object Notation File"
"*.json ; JavaScript Object Notation File",
"*.html ; HyperText Markup Language",
]
var directories = []
@ -42,6 +43,10 @@ func _ready():
NewFile.connect("pressed",self,"open_newfiledialogue")
DeleteFile.connect("pressed",self,"delete_selected_file")
NewFile.icon = IconLoader.load_icon_from_name("new")
OpenFile.icon = IconLoader.load_icon_from_name("file")
DeleteFile.icon = IconLoader.load_icon_from_name("delete")
NewFileDialogue.connect("confirmed",self,"create_new_file")
@ -83,12 +88,15 @@ func open_newfiledialogue():
NewFileDialogue.set_position(OS.get_screen_size()/2 - NewFileDialogue.get_size()/2)
func create_new_file():
NewFileDialogue.hide()
var new_file_tab = FileScene.instance()
Editor.add_child(new_file_tab)
new_file_tab.new_file_create(NewFileDialogue_name.get_text())
Editor.show()
update_list()
if NewFileDialogue_name.get_text():
NewFileDialogue.hide()
var new_file_tab = FileScene.instance()
Editor.add_child(new_file_tab)
new_file_tab.new_file_create(NewFileDialogue_name.get_text())
Editor.show()
update_list()
else:
print("<filename> cannot be empty! Please, give your file a name.")
func open_filelist():
update_list()

View File

@ -0,0 +1,19 @@
tool
extends ToolButton
var fileditor_workspace
var fileditor
func _ready():
connect("pressed",self,"show_fileditor")
func show_fileditor():
fileditor_workspace.get_children()[0].hide()
fileditor_workspace.get_children()[1].hide()
fileditor_workspace.get_children()[2].hide()
fileditor_workspace.add_child(fileditor)
fileditor.show()
func load_values(fi, fe):
fileditor_workspace = fi
fileditor = fe

View File

@ -12,19 +12,28 @@ onready var LastModified = $FileInfo/lastmodified
onready var FileList = get_parent().get_parent().get_parent().get_node("FileList")
onready var ClosingFile = get_parent().get_parent().get_parent().get_node("ConfirmationDialog")
onready var FilePath = $TopBar/filepath
onready var LastModifiedIcon = $FileInfo/lastmodified_icon
var current_path = ""
var current_filename = ""
var old_file_content = ""
var Preview = load("res://addons/file-editor/scenes/Preview.tscn")
func _ready():
FileButton.connect("id_pressed",self,"button_pressed")
ClosingFile.connect("confirmed",self,"queue_free")
CloseFile.connect("pressed",self,"close_editor")
ReadOnly.connect("toggled",self,"_on_Readonly_toggled")
ReadOnly.set("custom_icons/checked",IconLoader.load_icon_from_name("read"))
ReadOnly.set("custom_icons/unchecked",IconLoader.load_icon_from_name("edit"))
func new_file_open(file_path, file_content, last_modified) :
current_path = file_path
@ -37,7 +46,10 @@ func new_file_open(file_path, file_content, last_modified) :
else:
set_name(filename_)
current_filename = filename_
old_file_content = file_content
TextEditor.set_text(file_content)
LastModifiedIcon.texture = IconLoader.load_icon_from_name("saveas")
LastModified.set_text(str(last_modified.hour)+":"+str(last_modified.minute)+" "+str(last_modified.day)+"/"+str(last_modified.month)+"/"+str(last_modified.year))
FileList.invalidate()
@ -57,10 +69,11 @@ func save_file(current_path : String):
current_content = ""
current_file.store_line(current_content)
current_file.close()
old_file_content = current_content
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_path))
LastModified.set_text(str(last_modified.hour)+":"+str(last_modified.minute)+" "+str(last_modified.day)+"/"+str(last_modified.month)+"/"+str(last_modified.year))
LastModifiedIcon.texture = IconLoader.load_icon_from_name("save")
FilePath.set_text(current_path)
FileList.invalidate()
@ -75,6 +88,7 @@ func save_file_as():
FileList.connect("file_selected",self,"save_file")
FileList.current_file = current_filename.replace("-",".")
open_filelist()
old_file_content = current_content
FileList.invalidate()
@ -93,27 +107,42 @@ func button_pressed(id : int):
bbcode_preview()
elif id == 4:
markdown_preview()
elif id == 5:
html_preview()
func open_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_preview(TextEditor.get_text())
func bbcode_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_bb(TextEditor.get_text())
func markdown_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_markdown(TextEditor.get_text())
func html_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_html(TextEditor.get_text())
func close_editor():
queue_free()
if old_file_content != TextEditor.get_text():
ClosingFile.popup()
else:
queue_free()
func _on_Readonly_toggled(button_pressed):
if button_pressed:
@ -121,4 +150,7 @@ func _on_Readonly_toggled(button_pressed):
TextEditor.readonly = (true)
else:
ReadOnly.set_text("Can Edit")
TextEditor.readonly = (false)
TextEditor.readonly = (false)
func _on_TextEditor_text_changed():
LastModifiedIcon.texture = IconLoader.load_icon_from_name("saveas")

View File

@ -0,0 +1,15 @@
tool
extends Node
func load_icon_from_name(icon_name : String) -> ImageTexture:
var file = File.new()
var image = Image.new()
var texture = ImageTexture.new()
file.open("res://addons/file-editor/icons.pngs/"+icon_name+".png.buttonicon", File.READ)
var buffer = file.get_buffer(file.get_len())
file.close()
image.load_png_from_buffer(buffer)
texture.create_from_image(image)
return texture

View File

@ -13,17 +13,102 @@ func print_bb(content : String):
TextPreview.append_bbcode(content)
func print_markdown(content : String):
content = content.replace(" **"," [b]")
content = content.replace("**","[/b]")
var result = ""
var bolded = []
var italics = []
var striked = []
var coded = []
var linknames = []
var images = []
var links = []
var lists = []
content = content.replace(" *"," [i]")
content = content.replace("*","[/i] ")
var regex = RegEx.new()
regex.compile('\\*\\*(?<boldtext>.*)\\*\\*')
result = regex.search_all(content)
if result:
for res in result:
bolded.append(res.get_string("boldtext"))
content = content.replace(" ~~","[s] ")
content = content.replace("~~","[/s]")
content = content.replace(" `"," [code]")
content = content.replace("`","[/code]")
regex.compile("\\*(?<italictext>.*)\\*")
result = regex.search_all(content)
if result:
for res in result:
italics.append(res.get_string("italictext"))
regex.compile("~~(?<strikedtext>.*)~~")
result = regex.search_all(content)
if result:
for res in result:
striked.append(res.get_string("strikedtext"))
regex.compile("`(?<coded>.*)`")
result = regex.search_all(content)
if result:
for res in result:
coded.append(res.get_string("coded"))
regex.compile("[+-](?<element>\\s.*)")
result = regex.search_all(content)
if result:
for res in result:
lists.append(res.get_string("element"))
regex.compile("(?<img>!\\[.*?\\))")
result = regex.search_all(content)
if result:
for res in result:
images.append(res.get_string("img"))
regex.compile("\\[(?<linkname>.*?)\\]|\\((?<link>[h\\.]\\S*?)\\)")
result = regex.search_all(content)
if result:
for res in result:
if res.get_string("link")!="":
links.append(res.get_string("link"))
if res.get_string("linkname")!="":
linknames.append(res.get_string("linkname"))
for bold in bolded:
content = content.replace("**"+bold+"**","[b]"+bold+"[/b]")
for italic in italics:
content = content.replace("*"+italic+"*","[i]"+italic+"[/i]")
for strik in striked:
content = content.replace("~~"+strik+"~~","[s]"+strik+"[/s]")
for code in coded:
content = content.replace("`"+code+"`","[code]"+code+"[/code]")
for image in images:
var substr = image.split("(")
var imglink = substr[1].rstrip(")")
content = content.replace(image,"[img]"+imglink+"[/img]")
for i in links.size():
content = content.replace("["+linknames[i]+"]("+links[i]+")","[url="+links[i]+"]"+linknames[i]+"[/url]")
for element in lists:
if content.find("- "+element):
content = content.replace("-"+element,"[indent]-"+element+"[/indent]")
if content.find("+ "+element):
content = content.replace("+"+element,"[indent]-"+element+"[/indent]")
TextPreview.append_bbcode(content)
func print_html(content : String):
content = content.replace("<i>","[i]")
content = content.replace("</i>","[/i]")
content = content.replace("<b>","[b]")
content = content.replace("</b>","[/b]")
content = content.replace("<u>","[u]")
content = content.replace("</u>","[/u]")
content = content.replace('<a href="',"[url=")
content = content.replace('">',"]")
content = content.replace("</a>","[/url]")
content = content.replace('<img src="',"[img]")
content = content.replace('" />',"[/img]")
content = content.replace('"/>',"[/img]")
content = content.replace("<pre>","[code]")
content = content.replace("</pre>","[/code]")
content = content.replace("<center>","[center]")
content = content.replace("</center>","[/center]")
TextPreview.append_bbcode(content)

View File

@ -1,14 +1,29 @@
tool
extends EditorPlugin
var doc
var doc = preload("../scenes/FileEditor.tscn").instance()
var plugin_version
var toolbar
var fileditorbutton
var IconLoader = preload("res://addons/file-editor/scripts/IconLoader.gd")
func _enter_tree():
doc = preload("../scenes/FileEditor.tscn").instance()
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR,doc)
add_autoload_singleton("IconLoader","res://addons/file-editor/scripts/IconLoader.gd")
get_editor_interface().get_editor_viewport().add_child(doc)
doc.hide()
func _exit_tree():
remove_control_from_docks(doc)
doc.queue_free()
get_editor_interface().get_editor_viewport().remove_child(doc)
remove_autoload_singleton("IconLoader")
func has_main_screen():
return true
func get_plugin_name():
return "File"
func get_plugin_icon():
return IconLoader.load_icon_from_name("file")
func make_visible(visible):
doc.visible = visible