Merge pull request #6 from fenix-hub/v1.2.1

V1.2.1
This commit is contained in:
fenix-hub 2019-10-03 16:11:17 +02:00 committed by GitHub
commit 445caaf27b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 512 additions and 541 deletions

View File

@ -1,11 +1,11 @@
📣 Check my **[Discord](https://discord.gg/KnJGY9S)** to stay updated on this repository. Check my **[Discord](https://discord.gg/KnJGY9S)** to stay updated on this repository.
*(Recommended since the AssetLibrary is not automatically updated)* *(Recommended since the AssetLibrary is not automatically updated)*
# Godot Text Editor # Godot Text Editor
A little plugin to easy-way manage your text files inside your project folder. A little plugin to easy-way manage your text files inside your project folder.
Author: *"Nicolo (fenix) Santilio"* Author: *"Nicolo (fenix) Santilio"*
Version: *0.3.3* Version: *1.2.1*
Godot Version: *3.1.1-stable* 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)!** **This repository was pushed directly from Godot Engine Editor thanks to [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integration)!**
@ -19,8 +19,7 @@ When opening / creating a file, the editor will open and you will be able to edi
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 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. 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. Multiple files can be opened in different tabs.
Always remember to save your file when you close the tab! ![preview](https://i.imgur.com/LcrGCGS.png)
![preview](https://i.imgur.com/RLQoWt8.png)![preview2](https://i.imgur.com/A3kHV1k.png)
## How do I install it? ## How do I install it?
**Manual** **Manual**
@ -44,7 +43,8 @@ You can find this plugin in the AssetLib of Godot Engine Editor. Just download i
+ "*.dat ; Data File", + "*.dat ; Data File",
+ "*.xml ; XML File", + "*.xml ; XML File",
+ "*.sql ; SQL database file", + "*.sql ; SQL database file",
+ "*.json ; JavaScript Object Notation File" + "*.json ; JavaScript Object Notation File",
+ "*.html ; HyperText Markup Language"
#### Current version #### Current version
To check all the features included in the current version, please read the [VERSION file](./VERSION.md) To check all the features included in the current version, please read the [VERSION file](./VERSION.md)
@ -52,7 +52,7 @@ To check all the features included in the current version, please read the [VERS
#### Upcoming features #### Upcoming features
To check all the features I'm currently working on, please read the [TODO file](./TODO.md) To check all the features I'm currently working on, please read the [TODO file](./TODO.md)
# ⚠️ Disclaimer # 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. 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. 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. 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

@ -41,9 +41,25 @@
----------------------- -----------------------
**version 0.3.3** **version 1.2.1**
*added* file support: *removed*
+ "*.dat ; Data File", - Old layout, the plugin won't appear in docs
+ "*.xml ; XML File", - Icons file extensions, plugin size reduced
+ "*.sql ; SQL database file", - Old Mardkwon preview method
+ "*.json ; JavaScript Object Notation File"
*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
-----------------------

View File

@ -1,8 +1,11 @@
Check my **[Discord](https://discord.gg/KnJGY9S)** to stay updated on this repository.
*(Recommended since the AssetLibrary is not automatically updated)*
# Godot Text Editor # Godot Text Editor
A little plugin to easy-way manage your text files inside your project folder. A little plugin to easy-way manage your text files inside your project folder.
Author: *"Nicolo (fenix) Santilio"* Author: *"Nicolo (fenix) Santilio"*
Version: *0.3.3* Version: *1.2.1*
Godot Version: *3.1.1-stable* 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)!** **This repository was pushed directly from Godot Engine Editor thanks to [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integration)!**
@ -16,8 +19,7 @@ When opening / creating a file, the editor will open and you will be able to edi
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 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. 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. Multiple files can be opened in different tabs.
Always remember to save your file when you close the tab! ![preview](https://i.imgur.com/LcrGCGS.png)
![preview](https://i.imgur.com/RLQoWt8.png)![preview2](https://i.imgur.com/A3kHV1k.png)
## How do I install it? ## How do I install it?
**Manual** **Manual**
@ -41,7 +43,8 @@ You can find this plugin in the AssetLib of Godot Engine Editor. Just download i
+ "*.dat ; Data File", + "*.dat ; Data File",
+ "*.xml ; XML File", + "*.xml ; XML File",
+ "*.sql ; SQL database file", + "*.sql ; SQL database file",
+ "*.json ; JavaScript Object Notation File" + "*.json ; JavaScript Object Notation File",
+ "*.html ; HyperText Markup Language"
#### Current version #### Current version
To check all the features included in the current version, please read the [VERSION file](./VERSION.md) To check all the features included in the current version, please read the [VERSION file](./VERSION.md)
@ -49,10 +52,7 @@ To check all the features included in the current version, please read the [VERS
#### Upcoming features #### Upcoming features
To check all the features I'm currently working on, please read the [TODO file](./TODO.md) To check all the features I'm currently working on, please read the [TODO file](./TODO.md)
# ?? Disclaimer # 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. 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. 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. 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*

View File

@ -41,9 +41,25 @@
----------------------- -----------------------
**version 0.3.3** **version 1.2.1**
*added* file support: *removed*
+ "*.dat ; Data File", - Old layout, the plugin won't appear in docs
+ "*.xml ; XML File", - Icons file extensions, plugin size reduced
+ "*.sql ; SQL database file", - Old Mardkwon preview method
+ "*.json ; JavaScript Object Notation File"
*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

View File

Before

Width:  |  Height:  |  Size: 244 B

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

View File

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 250 B

View File

@ -1,5 +0,0 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
<path transform="translate(0 1036.4)" d="m5 1v1h-4v2h14v-2h-4v-1h-6zm-3 4v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2v-8h-12zm1 2h2v6h-2v-6zm4 0h2v6h-2v-6zm4 0h2v6h-2v-6z" fill="#e0e0e0" fill-opacity=".99608"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 347 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/delete.svg-0efeb58fb7257d229e82eb8253343745.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/delete.svg"
dest_files=[ "res://.import/delete.svg-0efeb58fb7257d229e82eb8253343745.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/edit.png-c0b04b667ee731a000c4a499c15ed43a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/edit.png"
dest_files=[ "res://.import/edit.png-c0b04b667ee731a000c4a499c15ed43a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,7 +0,0 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
<g transform="translate(0 -1.6949e-5)">
<path transform="translate(0 1036.4)" d="m2 1v14h12v-9h-5v-5zm8 0v4h4z" fill="#e0e0e0"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 281 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/file.svg-6afa1797254aefd711752062106ab4e3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/file.svg"
dest_files=[ "res://.import/file.svg-6afa1797254aefd711752062106ab4e3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,8 +0,0 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
<g transform="translate(0 -1.6949e-5)">
<path transform="translate(0 1036.4)" d="m2 1v14h8v-1h-2v-4h2v-2h4v-2h-5v-5zm8 0v4h4z" fill="#e0e0e0"/>
<path d="m11 1045.4v2h-2v2h2v2h2v-2h2v-2h-2v-2z" fill="#84ffb1"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 362 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/new.svg-68beb54e3911133b4db07f64faa2c437.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/new.svg"
dest_files=[ "res://.import/new.svg-68beb54e3911133b4db07f64faa2c437.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,3 +0,0 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path d="m8 2c-2.5567 0-5.7907 1.9477-6.9551 5.7051a1.0001 1.0001 0 0 0 -0.00586 0.57031c1.1244 3.9354 4.4609 5.7246 6.9609 5.7246s5.8365-1.7892 6.9609-5.7246a1.0001 1.0001 0 0 0 0 -0.55273c-1.1003-3.7876-4.4066-5.7227-6.9609-5.7227zm0 2a4 4 0 0 1 4 4 4 4 0 0 1 -4 4 4 4 0 0 1 -4 -4 4 4 0 0 1 4 -4zm0 2a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -2 -2z" color="#000000" color-rendering="auto" fill="#e0e0e0" fill-opacity=".99608" fill-rule="evenodd" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="isolation:auto;mix-blend-mode:normal;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-transform:none;white-space:normal"/>
</svg>

Before

Width:  |  Height:  |  Size: 818 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/read.svg-9c5e481c14e26895473d130311546757.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/read.svg"
dest_files=[ "res://.import/read.svg-9c5e481c14e26895473d130311546757.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,5 +0,0 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
<path transform="translate(0 1036.4)" d="m3 1c-1.1046 0-2 0.89543-2 2v10c0 1.1046 0.89543 2 2 2h10c1.1046 0 2-0.89543 2-2v-7-1-1l-3-3h-1v5 1h-8v-6zm1 0v5h3v-5h-3zm4 8c1.1046 0 2 0.89543 2 2 0 1.1046-0.89543 2-2 2s-2-0.89543-2-2c0-1.1046 0.89543-2 2-2z" fill="#e0e0e0"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 417 B

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/save.svg-e5fc4f4526e17e49182b618305178f4b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/save.svg"
dest_files=[ "res://.import/save.svg-e5fc4f4526e17e49182b618305178f4b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/saveas.png-ea1b6fd971b87c526f8f37d0352c90c6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/file-editor/icons/saveas.png"
dest_files=[ "res://.import/saveas.png-ea1b6fd971b87c526f8f37d0352c90c6.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,7 +1,7 @@
[plugin] [plugin]
name="File Editor" name="File Editor"
description="An internal file editor to view and edit text files in your project folder." description="An internal file editor to view and edit text files in your project folder."
author="Nicolò 'fenix' Santilio" author="Nicolo 'fenix' Santilio"
version="0.3.3" version="1.2.1"
script="scripts/file-editor.gd" 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/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/fonts/Roboto-Black.ttf" type="DynamicFontData" 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]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=6]
size = 13 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_left = 10.0
content_margin_right = 10.0 content_margin_right = 10.0
bg_color = Color( 0.196078, 0.231373, 0.309804, 1 ) 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 ) border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0 expand_margin_bottom = 1.0
[sub_resource type="StyleBoxFlat" id=3] [sub_resource type="StyleBoxFlat" id=8]
content_margin_left = 10.0 content_margin_left = 10.0
content_margin_right = 10.0 content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 ) 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 ) border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0 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 ) bg_color = Color( 0.121569, 0.145098, 0.192157, 1 )
draw_center = false draw_center = false
border_width_left = 1 border_width_left = 1
@ -42,57 +39,64 @@ border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
[node name="FileEditor" type="Control"] [node name="FileEditor" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Container" type="VBoxContainer" parent="."] [node name="Container" type="VBoxContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 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"] [node name="Buttons" type="HBoxContainer" parent="Container"]
margin_right = 1024.0 margin_right = 1013.0
margin_bottom = 22.0 margin_bottom = 20.0
[node name="newfile_btn" type="Button" parent="Container/Buttons"] [node name="newfile_btn" type="Button" parent="Container/Buttons"]
margin_right = 337.0 margin_right = 110.0
margin_bottom = 22.0 margin_bottom = 20.0
size_flags_horizontal = 3
text = "Create new File" text = "Create new File"
icon = ExtResource( 2 ) flat = true
[node name="openfile_btn" type="Button" parent="Container/Buttons"] [node name="openfile_btn" type="Button" parent="Container/Buttons"]
margin_left = 341.0 margin_left = 114.0
margin_right = 678.0 margin_right = 188.0
margin_bottom = 22.0 margin_bottom = 20.0
size_flags_horizontal = 3
text = "Open File" text = "Open File"
icon = ExtResource( 3 ) flat = true
[node name="deletefile_btn" type="Button" parent="Container/Buttons"] [node name="deletefile_btn" type="Button" parent="Container/Buttons"]
margin_left = 682.0 margin_left = 192.0
margin_right = 1019.0 margin_right = 274.0
margin_bottom = 22.0 margin_bottom = 20.0
size_flags_horizontal = 3
text = "Delete File" text = "Delete File"
icon = ExtResource( 4 ) flat = true
[node name="version" type="Label" parent="Container/Buttons"] [node name="version" type="Label" parent="Container/Buttons"]
margin_left = 1023.0 margin_left = 974.0
margin_top = 2.0 margin_top = 1.0
margin_right = 1023.0 margin_right = 1013.0
margin_bottom = 19.0 margin_bottom = 18.0
custom_fonts/font = SubResource( 1 ) size_flags_horizontal = 10
custom_fonts/font = SubResource( 6 )
custom_colors/font_color = Color( 0.121569, 0.145098, 0.192157, 1 ) custom_colors/font_color = Color( 0.121569, 0.145098, 0.192157, 1 )
text = "v1.2.1"
align = 1 align = 1
[node name="Editor" type="TabContainer" parent="Container"] [node name="Editor" type="TabContainer" parent="Container"]
visible = false visible = false
margin_top = 32.0 margin_top = 26.0
margin_right = 1024.0 margin_right = 1000.0
margin_bottom = 600.0 margin_bottom = 600.0
size_flags_vertical = 3 size_flags_horizontal = 3
custom_styles/tab_fg = SubResource( 2 ) size_flags_vertical = 11
custom_styles/tab_bg = SubResource( 3 ) custom_styles/tab_fg = SubResource( 7 )
custom_styles/panel = SubResource( 4 ) custom_styles/tab_bg = SubResource( 8 )
custom_styles/panel = SubResource( 9 )
custom_colors/font_color_fg = Color( 1, 1, 1, 1 ) custom_colors/font_color_fg = Color( 1, 1, 1, 1 )
tab_align = 0 tab_align = 0
drag_to_rearrange_enabled = true drag_to_rearrange_enabled = true
@ -104,7 +108,7 @@ margin_bottom = 600.0
size_flags_vertical = 3 size_flags_vertical = 3
popup_exclusive = true popup_exclusive = true
dialog_hide_on_ok = 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="."] [node name="NewFileDialogue" type="AcceptDialog" parent="."]
editor/display_folded = true editor/display_folded = true
@ -124,7 +128,7 @@ margin_bottom = -36.0
[node name="Label" type="Label" parent="NewFileDialogue/VBoxContainer"] [node name="Label" type="Label" parent="NewFileDialogue/VBoxContainer"]
margin_right = 280.0 margin_right = 280.0
margin_bottom = 17.0 margin_bottom = 16.0
size_flags_vertical = 3 size_flags_vertical = 3
text = "Insert file name (no extension needed)" text = "Insert file name (no extension needed)"
align = 1 align = 1
@ -132,11 +136,29 @@ valign = 1
[node name="new_filename" type="LineEdit" parent="NewFileDialogue/VBoxContainer"] [node name="new_filename" type="LineEdit" parent="NewFileDialogue/VBoxContainer"]
margin_left = 40.0 margin_left = 40.0
margin_top = 21.0 margin_top = 20.0
margin_right = 240.0 margin_right = 240.0
margin_bottom = 45.0 margin_bottom = 44.0
rect_min_size = Vector2( 200, 0 ) rect_min_size = Vector2( 200, 0 )
size_flags_horizontal = 6 size_flags_horizontal = 6
size_flags_vertical = 3 size_flags_vertical = 3
clear_button_enabled = true clear_button_enabled = true
placeholder_text = "example" 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/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/fonts/Roboto-Black.ttf" type="DynamicFontData" 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]
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="StyleBoxFlat" id=1]
content_margin_left = 10.0 content_margin_left = 10.0
content_margin_right = 10.0 content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 ) 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=2]
[sub_resource type="StyleBoxEmpty" id=3] [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="StyleBoxEmpty" id=7]
[sub_resource type="DynamicFont" id=8] [sub_resource type="DynamicFont" id=8]
font_data = ExtResource( 4 ) font_data = ExtResource( 2 )
[node name="filename" type="VBoxContainer"] [node name="filename" type="VBoxContainer"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 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 size_flags_vertical = 3
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="HSeparator" type="HSeparator" parent="."] [node name="HSeparator" type="HSeparator" parent="."]
margin_right = 1016.0 margin_right = 1024.0
margin_bottom = 4.0 margin_bottom = 4.0
[node name="TopBar" type="HBoxContainer" parent="."] [node name="TopBar" type="HBoxContainer" parent="."]
margin_top = 8.0 margin_top = 8.0
margin_right = 1016.0 margin_right = 1024.0
margin_bottom = 28.0 margin_bottom = 28.0
[node name="VSeparator" type="VSeparator" parent="TopBar"] [node name="VSeparator" type="VSeparator" parent="TopBar"]
@ -56,31 +52,31 @@ custom_styles/hover = SubResource( 1 )
custom_styles/normal = SubResource( 1 ) custom_styles/normal = SubResource( 1 )
text = "File" text = "File"
flat = false 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"] [node name="filepath" type="Label" parent="TopBar"]
margin_left = 519.0 margin_left = 523.0
margin_top = 3.0 margin_top = 3.0
margin_right = 519.0 margin_right = 523.0
margin_bottom = 17.0 margin_bottom = 17.0
size_flags_horizontal = 6 size_flags_horizontal = 6
[node name="close_btn" type="Button" parent="TopBar"] [node name="close_btn" type="Button" parent="TopBar"]
margin_left = 988.0 margin_left = 996.0
margin_right = 1008.0 margin_right = 1016.0
margin_bottom = 20.0 margin_bottom = 20.0
size_flags_horizontal = 8 size_flags_horizontal = 8
text = "X" text = "X"
[node name="VSeparator2" type="VSeparator" parent="TopBar"] [node name="VSeparator2" type="VSeparator" parent="TopBar"]
margin_left = 1012.0 margin_left = 1020.0
margin_right = 1016.0 margin_right = 1024.0
margin_bottom = 20.0 margin_bottom = 20.0
[node name="TextEditor" type="TextEdit" parent="."] [node name="TextEditor" type="TextEdit" parent="."]
margin_top = 32.0 margin_top = 32.0
margin_right = 1016.0 margin_right = 1024.0
margin_bottom = 541.0 margin_bottom = 577.0
size_flags_vertical = 3 size_flags_vertical = 3
syntax_highlighting = true syntax_highlighting = true
show_line_numbers = true show_line_numbers = true
@ -93,30 +89,41 @@ caret_blink_speed = 1.0
caret_moving_by_right_click = false caret_moving_by_right_click = false
[node name="FileInfo" type="HBoxContainer" parent="."] [node name="FileInfo" type="HBoxContainer" parent="."]
editor/display_folded = true margin_top = 581.0
margin_top = 545.0 margin_right = 1024.0
margin_right = 1016.0 margin_bottom = 600.0
margin_bottom = 564.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"] [node name="Label" type="Label" parent="FileInfo"]
margin_left = 9.0
margin_top = 2.0 margin_top = 2.0
margin_right = 125.0 margin_right = 134.0
margin_bottom = 16.0 margin_bottom = 16.0
text = "Last modified time:" text = "Last modified time:"
[node name="lastmodified" type="Label" parent="FileInfo"] [node name="lastmodified" type="Label" parent="FileInfo"]
margin_left = 129.0 margin_left = 136.0
margin_top = 2.0 margin_top = 2.0
margin_right = 129.0 margin_right = 136.0
margin_bottom = 16.0 margin_bottom = 16.0
[node name="Readonly" type="CheckBox" parent="FileInfo"] [node name="Readonly" type="CheckBox" parent="FileInfo"]
margin_left = 929.0 margin_left = 939.0
margin_right = 1008.0 margin_right = 1018.0
margin_bottom = 19.0 margin_bottom = 19.0
size_flags_horizontal = 10 size_flags_horizontal = 10
custom_icons/checked = ExtResource( 2 )
custom_icons/unchecked = ExtResource( 3 )
custom_styles/hover = SubResource( 2 ) custom_styles/hover = SubResource( 2 )
custom_styles/pressed = SubResource( 3 ) custom_styles/pressed = SubResource( 3 )
custom_styles/focus = SubResource( 4 ) custom_styles/focus = SubResource( 4 )
@ -130,6 +137,8 @@ text = "Can Edit"
flat = true flat = true
[node name="VSeparator3" type="VSeparator" parent="FileInfo"] [node name="VSeparator3" type="VSeparator" parent="FileInfo"]
margin_left = 1012.0 margin_left = 1020.0
margin_right = 1016.0 margin_right = 1024.0
margin_bottom = 19.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-Bold.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://addons/file-editor/fonts/Carlito-Regular.ttf" type="DynamicFontData" id=6] [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_mipmaps = true
use_filter = true use_filter = true
font_data = ExtResource( 2 ) font_data = ExtResource( 2 )
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=2]
font_data = ExtResource( 3 ) font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=2] [sub_resource type="DynamicFont" id=3]
font_data = ExtResource( 4 ) font_data = ExtResource( 4 )
[sub_resource type="DynamicFont" id=3] [sub_resource type="DynamicFont" id=4]
font_data = ExtResource( 5 ) font_data = ExtResource( 5 )
[sub_resource type="DynamicFont" id=4] [sub_resource type="DynamicFont" id=5]
font_data = ExtResource( 6 ) font_data = ExtResource( 6 )
[node name="Preview" type="WindowDialog"] [node name="Preview" type="WindowDialog"]
@ -43,11 +43,11 @@ anchor_bottom = 1.0
margin_right = 863.0 margin_right = 863.0
margin_bottom = 505.0 margin_bottom = 505.0
size_flags_vertical = 3 size_flags_vertical = 3
custom_fonts/mono_font = SubResource( 5 ) custom_fonts/mono_font = SubResource( 1 )
custom_fonts/bold_italics_font = SubResource( 1 ) custom_fonts/bold_italics_font = SubResource( 2 )
custom_fonts/italics_font = SubResource( 2 ) custom_fonts/italics_font = SubResource( 3 )
custom_fonts/bold_font = SubResource( 3 ) custom_fonts/bold_font = SubResource( 4 )
custom_fonts/normal_font = SubResource( 4 ) custom_fonts/normal_font = SubResource( 5 )
bbcode_enabled = true bbcode_enabled = true
scroll_following = true scroll_following = true
[connection signal="popup_hide" from="." to="." method="_on_Preview_popup_hide"] [connection signal="popup_hide" from="." to="." method="_on_Preview_popup_hide"]

View File

@ -31,7 +31,8 @@ var EXTENSIONS : PoolStringArray = [
"*.dat ; Data File", "*.dat ; Data File",
"*.xml ; XML File", "*.xml ; XML File",
"*.sql ; SQL database file", "*.sql ; SQL database file",
"*.json ; JavaScript Object Notation File" "*.json ; JavaScript Object Notation File",
"*.html ; HyperText Markup Language",
] ]
var directories = [] var directories = []
@ -42,6 +43,10 @@ func _ready():
NewFile.connect("pressed",self,"open_newfiledialogue") NewFile.connect("pressed",self,"open_newfiledialogue")
DeleteFile.connect("pressed",self,"delete_selected_file") 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") 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) NewFileDialogue.set_position(OS.get_screen_size()/2 - NewFileDialogue.get_size()/2)
func create_new_file(): func create_new_file():
if NewFileDialogue_name.get_text():
NewFileDialogue.hide() NewFileDialogue.hide()
var new_file_tab = FileScene.instance() var new_file_tab = FileScene.instance()
Editor.add_child(new_file_tab) Editor.add_child(new_file_tab)
new_file_tab.new_file_create(NewFileDialogue_name.get_text()) new_file_tab.new_file_create(NewFileDialogue_name.get_text())
Editor.show() Editor.show()
update_list() update_list()
else:
print("<filename> cannot be empty! Please, give your file a name.")
func open_filelist(): func open_filelist():
update_list() 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,20 +12,29 @@ onready var LastModified = $FileInfo/lastmodified
onready var FileList = get_parent().get_parent().get_parent().get_node("FileList") 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 FilePath = $TopBar/filepath
onready var LastModifiedIcon = $FileInfo/lastmodified_icon
var current_path = "" var current_path = ""
var current_filename = "" var current_filename = ""
var old_file_content = ""
var Preview = load("res://addons/file-editor/scenes/Preview.tscn") var Preview = load("res://addons/file-editor/scenes/Preview.tscn")
func _ready(): func _ready():
FileButton.connect("id_pressed",self,"button_pressed") FileButton.connect("id_pressed",self,"button_pressed")
ClosingFile.connect("confirmed",self,"queue_free")
CloseFile.connect("pressed",self,"close_editor") CloseFile.connect("pressed",self,"close_editor")
ReadOnly.connect("toggled",self,"_on_Readonly_toggled") 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) : func new_file_open(file_path, file_content, last_modified) :
current_path = file_path current_path = file_path
var filename_ = file_path.get_file().replace(".","-") var filename_ = file_path.get_file().replace(".","-")
@ -37,7 +46,10 @@ func new_file_open(file_path, file_content, last_modified) :
else: else:
set_name(filename_) set_name(filename_)
current_filename = filename_ current_filename = filename_
old_file_content = file_content
TextEditor.set_text(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)) 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() FileList.invalidate()
@ -57,10 +69,11 @@ func save_file(current_path : String):
current_content = "" current_content = ""
current_file.store_line(current_content) current_file.store_line(current_content)
current_file.close() current_file.close()
old_file_content = current_content
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_path)) 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)) 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) FilePath.set_text(current_path)
FileList.invalidate() FileList.invalidate()
@ -75,6 +88,7 @@ func save_file_as():
FileList.connect("file_selected",self,"save_file") FileList.connect("file_selected",self,"save_file")
FileList.current_file = current_filename.replace("-",".") FileList.current_file = current_filename.replace("-",".")
open_filelist() open_filelist()
old_file_content = current_content
FileList.invalidate() FileList.invalidate()
@ -93,26 +107,41 @@ func button_pressed(id : int):
bbcode_preview() bbcode_preview()
elif id == 4: elif id == 4:
markdown_preview() markdown_preview()
elif id == 5:
html_preview()
func open_preview(): func open_preview():
var preview = Preview.instance() var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview) get_parent().get_parent().get_parent().add_child(preview)
preview.popup() preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_preview(TextEditor.get_text()) preview.print_preview(TextEditor.get_text())
func bbcode_preview(): func bbcode_preview():
var preview = Preview.instance() var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview) get_parent().get_parent().get_parent().add_child(preview)
preview.popup() preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_bb(TextEditor.get_text()) preview.print_bb(TextEditor.get_text())
func markdown_preview(): func markdown_preview():
var preview = Preview.instance() var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview) get_parent().get_parent().get_parent().add_child(preview)
preview.popup() preview.popup()
preview.window_title += " ("+current_filename+")"
preview.print_markdown(TextEditor.get_text()) 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(): func close_editor():
if old_file_content != TextEditor.get_text():
ClosingFile.popup()
else:
queue_free() queue_free()
func _on_Readonly_toggled(button_pressed): func _on_Readonly_toggled(button_pressed):
@ -122,3 +151,6 @@ func _on_Readonly_toggled(button_pressed):
else: else:
ReadOnly.set_text("Can Edit") 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) TextPreview.append_bbcode(content)
func print_markdown(content : String): func print_markdown(content : String):
content = content.replace(" **"," [b]") var result = ""
content = content.replace("**","[/b]") var bolded = []
var italics = []
var striked = []
var coded = []
var linknames = []
var images = []
var links = []
var lists = []
content = content.replace(" *"," [i]") var regex = RegEx.new()
content = content.replace("*","[/i] ") 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]") regex.compile("\\*(?<italictext>.*)\\*")
content = content.replace("`","[/code]") 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) TextPreview.append_bbcode(content)

View File

@ -1,14 +1,29 @@
tool tool
extends EditorPlugin extends EditorPlugin
var doc var doc = preload("../scenes/FileEditor.tscn").instance()
var plugin_version var plugin_version
var toolbar
var fileditorbutton
var IconLoader = preload("res://addons/file-editor/scripts/IconLoader.gd")
func _enter_tree(): func _enter_tree():
doc = preload("../scenes/FileEditor.tscn").instance() add_autoload_singleton("IconLoader","res://addons/file-editor/scripts/IconLoader.gd")
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR,doc) get_editor_interface().get_editor_viewport().add_child(doc)
doc.hide()
func _exit_tree(): func _exit_tree():
remove_control_from_docks(doc) get_editor_interface().get_editor_viewport().remove_child(doc)
doc.queue_free() 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