-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Godot Text Editor | ||
A little plugin to easy-way manage your text files inside your project folder. | ||
|
||
Author: *"Nicolo (fenix) Santilio"* | ||
Version: *0.1.0* | ||
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? | ||
Building... | ||
|
||
## How does it work? | ||
Building... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### to do (v-0.x.x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**version 0.1.0** | ||
|
||
|
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[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.1.0" | ||
script="scripts/file-editor.gd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
[gd_scene load_steps=18 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/icons/read.svg" type="Texture" id=6] | ||
[ext_resource path="res://addons/file-editor/icons/edit.png" type="Texture" id=7] | ||
[ext_resource path="res://addons/file-editor/icons/save.svg" type="Texture" id=8] | ||
[ext_resource path="res://addons/file-editor/icons/saveas.png" type="Texture" id=9] | ||
|
||
[sub_resource type="DynamicFont" id=1] | ||
outline_size = 3 | ||
outline_color = Color( 0.168627, 0.160784, 0.192157, 1 ) | ||
font_data = ExtResource( 5 ) | ||
|
||
[sub_resource type="StyleBoxEmpty" id=2] | ||
|
||
[sub_resource type="StyleBoxEmpty" id=3] | ||
|
||
[sub_resource type="StyleBoxEmpty" id=4] | ||
|
||
[sub_resource type="StyleBoxEmpty" id=5] | ||
|
||
[sub_resource type="StyleBoxEmpty" id=6] | ||
|
||
[sub_resource type="StyleBoxEmpty" id=7] | ||
|
||
[sub_resource type="DynamicFont" id=8] | ||
font_data = ExtResource( 5 ) | ||
|
||
[node name="FileEditor" type="Control"] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
script = ExtResource( 1 ) | ||
|
||
[node name="Container" type="VBoxContainer" parent="."] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
|
||
[node name="Buttons" type="HBoxContainer" parent="Container"] | ||
editor/display_folded = true | ||
margin_right = 1024.0 | ||
margin_bottom = 22.0 | ||
|
||
[node name="newfile_btn" type="Button" parent="Container/Buttons"] | ||
margin_right = 338.0 | ||
margin_bottom = 22.0 | ||
size_flags_horizontal = 3 | ||
text = "Create new File" | ||
icon = ExtResource( 2 ) | ||
|
||
[node name="openfile_btn" type="Button" parent="Container/Buttons"] | ||
margin_left = 342.0 | ||
margin_right = 680.0 | ||
margin_bottom = 22.0 | ||
size_flags_horizontal = 3 | ||
text = "Open File" | ||
icon = ExtResource( 3 ) | ||
|
||
[node name="deletefile_btn" type="Button" parent="Container/Buttons"] | ||
margin_left = 684.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 22.0 | ||
size_flags_horizontal = 3 | ||
text = "Delete File" | ||
icon = ExtResource( 4 ) | ||
|
||
[node name="HSeparator" type="HSeparator" parent="Container"] | ||
margin_top = 26.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 30.0 | ||
|
||
[node name="Label" type="Label" parent="Container"] | ||
margin_top = 34.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 53.0 | ||
custom_fonts/font = SubResource( 1 ) | ||
text = "EDITOR" | ||
align = 1 | ||
|
||
[node name="Editor" type="VBoxContainer" parent="Container"] | ||
margin_top = 57.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 600.0 | ||
size_flags_vertical = 3 | ||
|
||
[node name="TopBar" type="HBoxContainer" parent="Container/Editor"] | ||
margin_right = 1024.0 | ||
margin_bottom = 24.0 | ||
|
||
[node name="Filename" type="LineEdit" parent="Container/Editor/TopBar"] | ||
margin_right = 917.0 | ||
margin_bottom = 24.0 | ||
size_flags_horizontal = 11 | ||
expand_to_text_length = true | ||
|
||
[node name="Readonly" type="CheckBox" parent="Container/Editor/TopBar"] | ||
margin_left = 921.0 | ||
margin_right = 1000.0 | ||
margin_bottom = 24.0 | ||
custom_icons/checked = ExtResource( 6 ) | ||
custom_icons/unchecked = ExtResource( 7 ) | ||
custom_styles/hover = SubResource( 2 ) | ||
custom_styles/pressed = SubResource( 3 ) | ||
custom_styles/focus = SubResource( 4 ) | ||
custom_styles/disabled = SubResource( 5 ) | ||
custom_styles/hover_pressed = SubResource( 6 ) | ||
custom_styles/normal = SubResource( 7 ) | ||
custom_fonts/font = SubResource( 8 ) | ||
custom_colors/font_color = Color( 0.145098, 0.172549, 0.231373, 1 ) | ||
custom_colors/font_color_pressed = Color( 1, 1, 1, 1 ) | ||
text = "Can Edit" | ||
flat = true | ||
|
||
[node name="close_btn" type="Button" parent="Container/Editor/TopBar"] | ||
margin_left = 1004.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 24.0 | ||
text = "X" | ||
|
||
[node name="TextEditor" type="TextEdit" parent="Container/Editor"] | ||
margin_top = 28.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 517.0 | ||
size_flags_vertical = 3 | ||
syntax_highlighting = true | ||
show_line_numbers = true | ||
breakpoint_gutter = true | ||
highlight_all_occurrences = true | ||
smooth_scrolling = true | ||
caret_blink = true | ||
caret_blink_speed = 0.1 | ||
|
||
[node name="EditorButtons" type="HBoxContainer" parent="Container/Editor"] | ||
margin_top = 521.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 543.0 | ||
|
||
[node name="savefile_btn" type="Button" parent="Container/Editor/EditorButtons"] | ||
margin_right = 510.0 | ||
margin_bottom = 22.0 | ||
size_flags_horizontal = 3 | ||
text = "Save File" | ||
icon = ExtResource( 8 ) | ||
|
||
[node name="savefileas_btn" type="Button" parent="Container/Editor/EditorButtons"] | ||
margin_left = 514.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 22.0 | ||
size_flags_horizontal = 3 | ||
text = "Save File as..." | ||
icon = ExtResource( 9 ) | ||
|
||
[node name="FileList" type="FileDialog" parent="."] | ||
margin_top = 24.0 | ||
margin_right = 1024.0 | ||
margin_bottom = 600.0 | ||
size_flags_vertical = 3 | ||
popup_exclusive = true | ||
dialog_hide_on_ok = true | ||
[connection signal="toggled" from="Container/Editor/TopBar/Readonly" to="." method="_on_Readonly_toggled"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
tool | ||
extends Control | ||
|
||
onready var FileList = $FileList | ||
|
||
onready var TextEditor = $Container/Editor/TextEditor | ||
onready var Filename = $Container/Editor/TopBar/Filename | ||
onready var CloseFile = $Container/Editor/TopBar/close_btn | ||
onready var Editor = $Container/Editor | ||
|
||
onready var OpenFile = $Container/Buttons/openfile_btn | ||
onready var NewFile = $Container/Buttons/newfile_btn | ||
onready var DeleteFile = $Container/Buttons/deletefile_btn | ||
|
||
onready var SaveFile = $Container/Editor/EditorButtons/savefile_btn | ||
onready var SaveFileAs = $Container/Editor/EditorButtons/savefileas_btn | ||
|
||
onready var ReadOnly = $Container/Editor/TopBar/Readonly | ||
|
||
var DIRECTORY : String = "res://" | ||
var EXCEPTIONS : String = "addons" | ||
var EXTENSIONS : 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", | ||
] | ||
|
||
var directories = [] | ||
var files = [] | ||
|
||
# ----- | ||
var current_file : File = File.new() | ||
var current_path : String = "" | ||
var current_content : String = "" | ||
# ----- | ||
|
||
func _ready(): | ||
OpenFile.connect("pressed",self,"open_selected_file") | ||
NewFile.connect("pressed",self,"create_new_file") | ||
DeleteFile.connect("pressed",self,"delete_selected_file") | ||
|
||
SaveFile.connect("pressed",self,"save_file") | ||
SaveFileAs.connect("pressed",self,"save_file_as") | ||
|
||
CloseFile.connect("pressed",self,"close_editor") | ||
|
||
Filename.set_editable(false) | ||
SaveFile.set_disabled(true) | ||
|
||
FileList.set_filters(EXTENSIONS) | ||
|
||
Editor.hide() | ||
|
||
func close_editor(): | ||
Editor.hide() | ||
Filename.set_text("") | ||
TextEditor.set_text("") | ||
current_file.close() | ||
current_file = File.new() | ||
current_path = "" | ||
current_content = "" | ||
|
||
func clear_editor(): | ||
TextEditor.set_text("") | ||
Filename.set_text("") | ||
current_file = File.new() | ||
|
||
func create_new_file(): | ||
close_editor() | ||
SaveFile.set_disabled(true) | ||
Editor.show() | ||
|
||
func open_filelist(): | ||
FileList.update() | ||
FileList.popup() | ||
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2) | ||
|
||
func save_file_as(): | ||
current_content = TextEditor.get_text() | ||
FileList.mode = FileDialog.MODE_SAVE_FILE | ||
FileList.set_title("Save this file as...") | ||
if FileList.is_connected("file_selected",self,"delete_file"): | ||
FileList.disconnect("file_selected",self,"delete_file") | ||
if not FileList.is_connected("file_selected",self,"open_file"): | ||
FileList.connect("file_selected",self,"open_file",[current_content]) | ||
else: | ||
FileList.disconnect("file_selected",self,"open_file") | ||
FileList.connect("file_selected",self,"open_file",[current_content]) | ||
open_filelist() | ||
|
||
func open_selected_file(): | ||
clear_editor() | ||
FileList.mode = FileDialog.MODE_OPEN_FILE | ||
FileList.set_title("Select a file you want to edit") | ||
if FileList.is_connected("file_selected",self,"delete_file"): | ||
FileList.disconnect("file_selected",self,"delete_file") | ||
if not FileList.is_connected("file_selected",self,"open_file"): | ||
FileList.connect("file_selected",self,"open_file",[""]) | ||
else: | ||
FileList.disconnect("file_selected",self,"open_file") | ||
FileList.connect("file_selected",self,"open_file",[""]) | ||
open_filelist() | ||
|
||
func delete_selected_file(): | ||
FileList.mode = FileDialog.MODE_OPEN_FILE | ||
FileList.set_title("Select a file you want to delete") | ||
if FileList.is_connected("file_selected",self,"open_file"): | ||
FileList.disconnect("file_selected",self,"open_file") | ||
if not FileList.is_connected("file_selected",self,"delete_file"): | ||
FileList.connect("file_selected",self,"delete_file") | ||
else: | ||
FileList.disconnect("file_selected",self,"delete_file") | ||
FileList.connect("file_selected",self,"delete_file") | ||
open_filelist() | ||
|
||
func open_file(path : String, content_file : String): | ||
var content = "" | ||
if content_file == "" or content_file == null: | ||
current_file.open(path,File.READ) | ||
content = current_file.get_as_text() | ||
else: | ||
content = content_file | ||
current_file.open(path,File.WRITE) | ||
current_file.store_line(content) | ||
|
||
TextEditor.set_text(content) | ||
Filename.set_text(path) | ||
|
||
current_file.close() | ||
|
||
current_path = path | ||
current_content = content | ||
|
||
Editor.show() | ||
SaveFile.set_disabled(false) | ||
|
||
func save_file(): | ||
if current_path == "" or current_path == null: | ||
save_file_as() | ||
else: | ||
current_file.open(current_path,File.WRITE) | ||
current_content = TextEditor.get_text() | ||
if current_content == null: | ||
current_content = "" | ||
current_file.store_line(current_content) | ||
current_file.close() | ||
|
||
func delete_file(path : String): | ||
clear_editor() | ||
var dir = Directory.new() | ||
dir.remove(path) | ||
|
||
func _on_Readonly_toggled(button_pressed): | ||
if button_pressed: | ||
ReadOnly.set_text("Read Only") | ||
TextEditor.readonly = (true) | ||
else: | ||
ReadOnly.set_text("Can Edit") | ||
TextEditor.readonly = (false) |
Oops, something went wrong.