mirror of
https://github.com/Relintai/godot-engine.file-editor.git
synced 2024-11-12 22:27:22 +01:00
rebase
This commit is contained in:
parent
10a5b7d829
commit
d31245b724
@ -67,534 +67,534 @@ var current_csv_editor : CSVEditor
|
|||||||
var current_font : DynamicFont
|
var current_font : DynamicFont
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if not Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
clean_editor()
|
clean_editor()
|
||||||
update_version()
|
update_version()
|
||||||
connect_signals()
|
connect_signals()
|
||||||
create_shortcuts()
|
create_shortcuts()
|
||||||
load_icons()
|
load_icons()
|
||||||
|
|
||||||
var opened_files : Array = LastOpenedFiles.load_opened_files()
|
var opened_files : Array = LastOpenedFiles.load_opened_files()
|
||||||
for opened_file in opened_files:
|
for opened_file in opened_files:
|
||||||
open_file(opened_file[1], opened_file[2])
|
open_file(opened_file[1], opened_file[2])
|
||||||
FileList.set_filters(EXTENSIONS)
|
FileList.set_filters(EXTENSIONS)
|
||||||
|
|
||||||
func create_shortcuts():
|
func create_shortcuts():
|
||||||
var hotkey
|
var hotkey
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_S
|
hotkey.scancode = KEY_S
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(4,hotkey.get_scancode_with_modifiers()) # save file
|
FileBTN.set_item_accelerator(4,hotkey.get_scancode_with_modifiers()) # save file
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_N
|
hotkey.scancode = KEY_N
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # new file
|
FileBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # new file
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_O
|
hotkey.scancode = KEY_O
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # open file
|
FileBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # open file
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_D
|
hotkey.scancode = KEY_D
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(6,hotkey.get_scancode_with_modifiers()) # delete file
|
FileBTN.set_item_accelerator(6,hotkey.get_scancode_with_modifiers()) # delete file
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_S
|
hotkey.scancode = KEY_S
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
hotkey.alt = true
|
hotkey.alt = true
|
||||||
FileBTN.set_item_accelerator(5,hotkey.get_scancode_with_modifiers()) #save file as
|
FileBTN.set_item_accelerator(5,hotkey.get_scancode_with_modifiers()) #save file as
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_C
|
hotkey.scancode = KEY_C
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
hotkey.alt = true
|
hotkey.alt = true
|
||||||
FileBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # close file
|
FileBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # close file
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_F
|
hotkey.scancode = KEY_F
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(8,hotkey.get_scancode_with_modifiers()) # search
|
FileBTN.set_item_accelerator(8,hotkey.get_scancode_with_modifiers()) # search
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_R
|
hotkey.scancode = KEY_R
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
FileBTN.set_item_accelerator(9,hotkey.get_scancode_with_modifiers()) # replace
|
FileBTN.set_item_accelerator(9,hotkey.get_scancode_with_modifiers()) # replace
|
||||||
|
|
||||||
# vanilla editor -----------------------
|
# vanilla editor -----------------------
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_1
|
hotkey.scancode = KEY_1
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
EditorBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # vanilla editor
|
EditorBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # vanilla editor
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_2
|
hotkey.scancode = KEY_2
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
EditorBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # csv editor
|
EditorBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # csv editor
|
||||||
|
|
||||||
hotkey = InputEventKey.new()
|
hotkey = InputEventKey.new()
|
||||||
hotkey.scancode = KEY_3
|
hotkey.scancode = KEY_3
|
||||||
hotkey.control = true
|
hotkey.control = true
|
||||||
EditorBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # inieditor editor
|
EditorBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # inieditor editor
|
||||||
|
|
||||||
func load_icons():
|
func load_icons():
|
||||||
$FileEditorContainer/TobBar/file_btn.icon = IconLoader.load_icon_from_name("file")
|
$FileEditorContainer/TobBar/file_btn.icon = IconLoader.load_icon_from_name("file")
|
||||||
$FileEditorContainer/TobBar/preview_btn.icon = IconLoader.load_icon_from_name("read")
|
$FileEditorContainer/TobBar/preview_btn.icon = IconLoader.load_icon_from_name("read")
|
||||||
$FileEditorContainer/TobBar/editor_btn.icon = IconLoader.load_icon_from_name("edit_")
|
$FileEditorContainer/TobBar/editor_btn.icon = IconLoader.load_icon_from_name("edit_")
|
||||||
$FileEditorContainer/TobBar/SettingsBtn.icon = IconLoader.load_icon_from_name("settings")
|
$FileEditorContainer/TobBar/SettingsBtn.icon = IconLoader.load_icon_from_name("settings")
|
||||||
|
|
||||||
func connect_signals():
|
func connect_signals():
|
||||||
FileList.connect("confirmed",self,"update_list")
|
FileList.connect("confirmed",self,"update_list")
|
||||||
FileBTN.connect("id_pressed",self,"_on_filebtn_pressed")
|
FileBTN.connect("id_pressed",self,"_on_filebtn_pressed")
|
||||||
PreviewBTN.connect("id_pressed",self,"_on_previewbtn_pressed")
|
PreviewBTN.connect("id_pressed",self,"_on_previewbtn_pressed")
|
||||||
EditorBTN.connect("id_pressed",self,"_on_editorbtn_pressed")
|
EditorBTN.connect("id_pressed",self,"_on_editorbtn_pressed")
|
||||||
SettingsBTN.connect("id_pressed",self,"_on_settingsbtn_pressed")
|
SettingsBTN.connect("id_pressed",self,"_on_settingsbtn_pressed")
|
||||||
|
|
||||||
OpenFileList.connect("item_selected",self,"_on_fileitem_pressed")
|
OpenFileList.connect("item_selected",self,"_on_fileitem_pressed")
|
||||||
WrapBTN.connect("item_selected",self,"on_wrap_button")
|
WrapBTN.connect("item_selected",self,"on_wrap_button")
|
||||||
MapBTN.connect("item_selected",self,"on_minimap_button")
|
MapBTN.connect("item_selected",self,"on_minimap_button")
|
||||||
|
|
||||||
SelectFontDialog.connect("file_selected",self,"_on_font_selected")
|
SelectFontDialog.connect("file_selected",self,"_on_font_selected")
|
||||||
|
|
||||||
func update_version():
|
func update_version():
|
||||||
var plugin_version = ""
|
var plugin_version = ""
|
||||||
var config = ConfigFile.new()
|
var config = ConfigFile.new()
|
||||||
var err = config.load("res://addons/file-editor/plugin.cfg")
|
var err = config.load("res://addons/file-editor/plugin.cfg")
|
||||||
if err == OK:
|
if err == OK:
|
||||||
plugin_version = config.get_value("plugin","version")
|
plugin_version = config.get_value("plugin","version")
|
||||||
Version.set_text("v"+plugin_version)
|
Version.set_text("v"+plugin_version)
|
||||||
|
|
||||||
func create_selected_file():
|
func create_selected_file():
|
||||||
update_list()
|
update_list()
|
||||||
FileList.mode = FileDialog.MODE_SAVE_FILE
|
FileList.mode = FileDialog.MODE_SAVE_FILE
|
||||||
FileList.set_title("Create a new File")
|
FileList.set_title("Create a new File")
|
||||||
if FileList.is_connected("file_selected",self,"delete_file"):
|
if FileList.is_connected("file_selected",self,"delete_file"):
|
||||||
FileList.disconnect("file_selected",self,"delete_file")
|
FileList.disconnect("file_selected",self,"delete_file")
|
||||||
if FileList.is_connected("file_selected",self,"open_file"):
|
if FileList.is_connected("file_selected",self,"open_file"):
|
||||||
FileList.disconnect("file_selected",self,"open_file")
|
FileList.disconnect("file_selected",self,"open_file")
|
||||||
if not FileList.is_connected("file_selected",self,"create_new_file"):
|
if not FileList.is_connected("file_selected",self,"create_new_file"):
|
||||||
FileList.connect("file_selected",self,"create_new_file")
|
FileList.connect("file_selected",self,"create_new_file")
|
||||||
open_filelist()
|
open_filelist()
|
||||||
|
|
||||||
func open_selected_file():
|
func open_selected_file():
|
||||||
update_list()
|
update_list()
|
||||||
FileList.mode = FileDialog.MODE_OPEN_FILE
|
FileList.mode = FileDialog.MODE_OPEN_FILE
|
||||||
FileList.set_title("Select a File you want to edit")
|
FileList.set_title("Select a File you want to edit")
|
||||||
if FileList.is_connected("file_selected",self,"delete_file"):
|
if FileList.is_connected("file_selected",self,"delete_file"):
|
||||||
FileList.disconnect("file_selected",self,"delete_file")
|
FileList.disconnect("file_selected",self,"delete_file")
|
||||||
if FileList.is_connected("file_selected",self,"create_new_file"):
|
if FileList.is_connected("file_selected",self,"create_new_file"):
|
||||||
FileList.disconnect("file_selected",self,"create_new_file")
|
FileList.disconnect("file_selected",self,"create_new_file")
|
||||||
if not FileList.is_connected("file_selected",self,"open_file"):
|
if not FileList.is_connected("file_selected",self,"open_file"):
|
||||||
FileList.connect("file_selected",self,"open_file")
|
FileList.connect("file_selected",self,"open_file")
|
||||||
open_filelist()
|
open_filelist()
|
||||||
|
|
||||||
func delete_selected_file():
|
func delete_selected_file():
|
||||||
update_list()
|
update_list()
|
||||||
FileList.mode = FileDialog.MODE_OPEN_FILES
|
FileList.mode = FileDialog.MODE_OPEN_FILES
|
||||||
FileList.set_title("Select one or more Files you want to delete")
|
FileList.set_title("Select one or more Files you want to delete")
|
||||||
if FileList.is_connected("file_selected",self,"open_file"):
|
if FileList.is_connected("file_selected",self,"open_file"):
|
||||||
FileList.disconnect("file_selected",self,"open_file")
|
FileList.disconnect("file_selected",self,"open_file")
|
||||||
if FileList.is_connected("file_selected",self,"create_new_file"):
|
if FileList.is_connected("file_selected",self,"create_new_file"):
|
||||||
FileList.disconnect("file_selected",self,"create_new_file")
|
FileList.disconnect("file_selected",self,"create_new_file")
|
||||||
if not FileList.is_connected("files_selected",self,"delete_file"):
|
if not FileList.is_connected("files_selected",self,"delete_file"):
|
||||||
FileList.connect("files_selected",self,"delete_file")
|
FileList.connect("files_selected",self,"delete_file")
|
||||||
open_filelist()
|
open_filelist()
|
||||||
|
|
||||||
func save_current_file_as():
|
func save_current_file_as():
|
||||||
update_list()
|
update_list()
|
||||||
FileList.mode = FileDialog.MODE_SAVE_FILE
|
FileList.mode = FileDialog.MODE_SAVE_FILE
|
||||||
FileList.set_title("Save this File as...")
|
FileList.set_title("Save this File as...")
|
||||||
if FileList.is_connected("file_selected",self,"delete_file"):
|
if FileList.is_connected("file_selected",self,"delete_file"):
|
||||||
FileList.disconnect("file_selected",self,"delete_file")
|
FileList.disconnect("file_selected",self,"delete_file")
|
||||||
if FileList.is_connected("file_selected",self,"open_file"):
|
if FileList.is_connected("file_selected",self,"open_file"):
|
||||||
FileList.disconnect("file_selected",self,"open_file")
|
FileList.disconnect("file_selected",self,"open_file")
|
||||||
if not FileList.is_connected("file_selected",self,"create_new_file"):
|
if not FileList.is_connected("file_selected",self,"create_new_file"):
|
||||||
FileList.connect("file_selected",self,"create_new_file")
|
FileList.connect("file_selected",self,"create_new_file")
|
||||||
open_filelist()
|
open_filelist()
|
||||||
|
|
||||||
func _on_filebtn_pressed(index : int):
|
func _on_filebtn_pressed(index : int):
|
||||||
match index:
|
match index:
|
||||||
0:
|
0:
|
||||||
create_selected_file()
|
create_selected_file()
|
||||||
1:
|
1:
|
||||||
open_selected_file()
|
open_selected_file()
|
||||||
2:
|
2:
|
||||||
if current_file_index!=-1 and current_file_path != "":
|
if current_file_index!=-1 and current_file_path != "":
|
||||||
close_file(current_file_index)
|
close_file(current_file_index)
|
||||||
|
|
||||||
3:
|
3:
|
||||||
if current_file_index!=-1 and current_file_path != "":
|
if current_file_index!=-1 and current_file_path != "":
|
||||||
save_as = false
|
save_as = false
|
||||||
if current_csv_editor and current_csv_editor.visible:
|
if current_csv_editor and current_csv_editor.visible:
|
||||||
current_csv_editor.save_table()
|
current_csv_editor.save_table()
|
||||||
save_file(current_file_path)
|
save_file(current_file_path)
|
||||||
4:
|
4:
|
||||||
if current_file_index!=-1 and current_file_path != "":
|
if current_file_index!=-1 and current_file_path != "":
|
||||||
save_as = true
|
save_as = true
|
||||||
save_file(current_file_path)
|
save_file(current_file_path)
|
||||||
save_current_file_as()
|
save_current_file_as()
|
||||||
5:
|
5:
|
||||||
delete_selected_file()
|
delete_selected_file()
|
||||||
6:
|
6:
|
||||||
current_editor.open_searchbox()
|
current_editor.open_searchbox()
|
||||||
7:
|
7:
|
||||||
current_editor.open_replacebox()
|
current_editor.open_replacebox()
|
||||||
|
|
||||||
func _on_previewbtn_pressed(id : int):
|
func _on_previewbtn_pressed(id : int):
|
||||||
if id == 0:
|
if id == 0:
|
||||||
bbcode_preview()
|
bbcode_preview()
|
||||||
elif id == 1:
|
elif id == 1:
|
||||||
markdown_preview()
|
markdown_preview()
|
||||||
elif id == 2:
|
elif id == 2:
|
||||||
html_preview()
|
html_preview()
|
||||||
elif id == 3:
|
elif id == 3:
|
||||||
csv_preview()
|
csv_preview()
|
||||||
elif id == 4:
|
elif id == 4:
|
||||||
xml_preview()
|
xml_preview()
|
||||||
elif id == 5:
|
elif id == 5:
|
||||||
json_preview()
|
json_preview()
|
||||||
|
|
||||||
func _on_editorbtn_pressed(index : int):
|
func _on_editorbtn_pressed(index : int):
|
||||||
match index:
|
match index:
|
||||||
0:
|
0:
|
||||||
if not current_editor.visible:
|
if not current_editor.visible:
|
||||||
current_editor.show()
|
current_editor.show()
|
||||||
if current_csv_editor:
|
if current_csv_editor:
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
if current_ini_editor:
|
if current_ini_editor:
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
1:
|
1:
|
||||||
if current_csv_editor and not current_csv_editor.visible:
|
if current_csv_editor and not current_csv_editor.visible:
|
||||||
if current_ini_editor:
|
if current_ini_editor:
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
current_csv_editor.show()
|
current_csv_editor.show()
|
||||||
2:
|
2:
|
||||||
if current_ini_editor and not current_ini_editor.visible:
|
if current_ini_editor and not current_ini_editor.visible:
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
if current_csv_editor:
|
if current_csv_editor:
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
current_ini_editor.show()
|
current_ini_editor.show()
|
||||||
|
|
||||||
func _on_settingsbtn_pressed(index : int):
|
func _on_settingsbtn_pressed(index : int):
|
||||||
match index:
|
match index:
|
||||||
0:
|
0:
|
||||||
SelectFontDialog.popup()
|
SelectFontDialog.popup()
|
||||||
|
|
||||||
func _on_font_selected(font_path : String):
|
func _on_font_selected(font_path : String):
|
||||||
current_editor.set_font(font_path)
|
current_editor.set_font(font_path)
|
||||||
LastOpenedFiles.store_editor_fonts(current_file_path.get_file(), font_path)
|
LastOpenedFiles.store_editor_fonts(current_file_path.get_file(), font_path)
|
||||||
# Enable this part of code to apply the new font to all Vanilla Editors opened
|
# Enable this part of code to apply the new font to all Vanilla Editors opened
|
||||||
# for file in [0,OpenFileList.get_child_count()]:
|
# for file in [0,OpenFileList.get_child_count()]:
|
||||||
# OpenFileList.get_item_metadata(file)[0].set_font(dynamic_font)
|
# OpenFileList.get_item_metadata(file)[0].set_font(dynamic_font)
|
||||||
# current_font = dynamic_font
|
# current_font = dynamic_font
|
||||||
|
|
||||||
func _on_fileitem_pressed(index : int):
|
func _on_fileitem_pressed(index : int):
|
||||||
current_file_index = index
|
current_file_index = index
|
||||||
var selected_item_metadata = OpenFileList.get_item_metadata(current_file_index)
|
var selected_item_metadata = OpenFileList.get_item_metadata(current_file_index)
|
||||||
var extension = selected_item_metadata[0].current_path.get_file().get_extension()
|
var extension = selected_item_metadata[0].current_path.get_file().get_extension()
|
||||||
|
|
||||||
current_file_path = selected_item_metadata[0].current_path
|
current_file_path = selected_item_metadata[0].current_path
|
||||||
if current_editor.visible:
|
if current_editor.visible:
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
current_editor = selected_item_metadata[0]
|
current_editor = selected_item_metadata[0]
|
||||||
current_editor.show()
|
current_editor.show()
|
||||||
OpenFileName.set_text(current_editor.current_path)
|
OpenFileName.set_text(current_editor.current_path)
|
||||||
current_csv_editor = selected_item_metadata[2]
|
current_csv_editor = selected_item_metadata[2]
|
||||||
current_ini_editor = selected_item_metadata[1]
|
current_ini_editor = selected_item_metadata[1]
|
||||||
if WrapBTN.get_selected_id() == 1:
|
if WrapBTN.get_selected_id() == 1:
|
||||||
current_editor.set_wrap_enabled(true)
|
current_editor.set_wrap_enabled(true)
|
||||||
else:
|
else:
|
||||||
current_editor.set_wrap_enabled(false)
|
current_editor.set_wrap_enabled(false)
|
||||||
if MapBTN.get_selected_id() == 1:
|
if MapBTN.get_selected_id() == 1:
|
||||||
current_editor.draw_minimap(true)
|
current_editor.draw_minimap(true)
|
||||||
else:
|
else:
|
||||||
current_editor.draw_minimap(false)
|
current_editor.draw_minimap(false)
|
||||||
elif current_csv_editor and current_csv_editor.visible:
|
elif current_csv_editor and current_csv_editor.visible:
|
||||||
if extension == "csv":
|
if extension == "csv":
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
current_csv_editor = selected_item_metadata[2]
|
current_csv_editor = selected_item_metadata[2]
|
||||||
current_csv_editor.show()
|
current_csv_editor.show()
|
||||||
OpenFileName.set_text(current_csv_editor.current_file_path)
|
OpenFileName.set_text(current_csv_editor.current_file_path)
|
||||||
current_editor = selected_item_metadata[0]
|
current_editor = selected_item_metadata[0]
|
||||||
current_ini_editor = selected_item_metadata[1]
|
current_ini_editor = selected_item_metadata[1]
|
||||||
else:
|
else:
|
||||||
if current_csv_editor:
|
if current_csv_editor:
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
current_csv_editor = selected_item_metadata[2]
|
current_csv_editor = selected_item_metadata[2]
|
||||||
if current_ini_editor:
|
if current_ini_editor:
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
current_ini_editor = selected_item_metadata[1]
|
current_ini_editor = selected_item_metadata[1]
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
current_editor = selected_item_metadata[0]
|
current_editor = selected_item_metadata[0]
|
||||||
current_editor.show()
|
current_editor.show()
|
||||||
OpenFileName.set_text(current_editor.current_path)
|
OpenFileName.set_text(current_editor.current_path)
|
||||||
elif current_ini_editor and current_ini_editor.visible:
|
elif current_ini_editor and current_ini_editor.visible:
|
||||||
if extension == "cfg" or extension == "ini":
|
if extension == "cfg" or extension == "ini":
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
current_ini_editor = selected_item_metadata[1]
|
current_ini_editor = selected_item_metadata[1]
|
||||||
current_ini_editor.show()
|
current_ini_editor.show()
|
||||||
OpenFileName.set_text(current_ini_editor.current_file_path)
|
OpenFileName.set_text(current_ini_editor.current_file_path)
|
||||||
else:
|
else:
|
||||||
if current_ini_editor:
|
if current_ini_editor:
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
current_ini_editor = selected_item_metadata[1]
|
current_ini_editor = selected_item_metadata[1]
|
||||||
if current_csv_editor:
|
if current_csv_editor:
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
current_csv_editor = selected_item_metadata[2]
|
current_csv_editor = selected_item_metadata[2]
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
current_editor = selected_item_metadata[0]
|
current_editor = selected_item_metadata[0]
|
||||||
current_editor.show()
|
current_editor.show()
|
||||||
OpenFileName.set_text(current_editor.current_path)
|
OpenFileName.set_text(current_editor.current_path)
|
||||||
|
|
||||||
func open_file(path : String, font : String = "null"):
|
func open_file(path : String, font : String = "null"):
|
||||||
if current_file_path != path:
|
if current_file_path != path:
|
||||||
current_file_path = path
|
current_file_path = path
|
||||||
|
|
||||||
var vanilla_editor = open_in_vanillaeditor(path)
|
var vanilla_editor = open_in_vanillaeditor(path)
|
||||||
if font != "null" and vanilla_editor.get("custom_fonts/font")!=null:
|
if font != "null" and vanilla_editor.get("custom_fonts/font")!=null:
|
||||||
vanilla_editor.set_font(font)
|
vanilla_editor.set_font(font)
|
||||||
var ini_editor = open_in_inieditor(path)
|
var ini_editor = open_in_inieditor(path)
|
||||||
var csv_editor = open_in_csveditor(path)
|
var csv_editor = open_in_csveditor(path)
|
||||||
|
|
||||||
generate_file_item(path,vanilla_editor,ini_editor,csv_editor)
|
generate_file_item(path,vanilla_editor,ini_editor,csv_editor)
|
||||||
|
|
||||||
LastOpenedFiles.store_opened_files(OpenFileList)
|
LastOpenedFiles.store_opened_files(OpenFileList)
|
||||||
current_editor.show()
|
current_editor.show()
|
||||||
|
|
||||||
func generate_file_item(path : String , veditor : Control , inieditor : Control, csveditor : Control):
|
func generate_file_item(path : String , veditor : Control , inieditor : Control, csveditor : Control):
|
||||||
OpenFileName.set_text(path)
|
OpenFileName.set_text(path)
|
||||||
OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true)
|
OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true)
|
||||||
current_file_index = OpenFileList.get_item_count()-1
|
current_file_index = OpenFileList.get_item_count()-1
|
||||||
OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor])
|
OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor])
|
||||||
OpenFileList.select(OpenFileList.get_item_count()-1)
|
OpenFileList.select(OpenFileList.get_item_count()-1)
|
||||||
|
|
||||||
func open_in_vanillaeditor(path : String) -> Control:
|
func open_in_vanillaeditor(path : String) -> Control:
|
||||||
var editor = VanillaEditor.instance()
|
var editor = VanillaEditor.instance()
|
||||||
SplitEditorContainer.add_child(editor,true)
|
SplitEditorContainer.add_child(editor,true)
|
||||||
|
|
||||||
if current_editor and current_editor!=editor:
|
if current_editor and current_editor!=editor:
|
||||||
editor.show()
|
editor.show()
|
||||||
current_editor.hide()
|
current_editor.hide()
|
||||||
if current_csv_editor and current_csv_editor.visible:
|
if current_csv_editor and current_csv_editor.visible:
|
||||||
current_csv_editor.hide()
|
current_csv_editor.hide()
|
||||||
if current_ini_editor and current_ini_editor.visible:
|
if current_ini_editor and current_ini_editor.visible:
|
||||||
current_ini_editor.hide()
|
current_ini_editor.hide()
|
||||||
|
|
||||||
current_editor = editor
|
current_editor = editor
|
||||||
editor.connect("text_changed",self,"_on_vanillaeditor_text_changed")
|
editor.connect("text_changed",self,"_on_vanillaeditor_text_changed")
|
||||||
|
|
||||||
var current_file : File = File.new()
|
var current_file : File = File.new()
|
||||||
current_file.open(path,File.READ)
|
current_file.open(path,File.READ)
|
||||||
var current_content = ""
|
var current_content = ""
|
||||||
current_content = current_file.get_as_text()
|
current_content = current_file.get_as_text()
|
||||||
|
|
||||||
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path))
|
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path))
|
||||||
|
|
||||||
current_file.close()
|
current_file.close()
|
||||||
editor.new_file_open(current_content,last_modified,current_file_path)
|
editor.new_file_open(current_content,last_modified,current_file_path)
|
||||||
update_list()
|
update_list()
|
||||||
|
|
||||||
if WrapBTN.get_selected_id() == 1:
|
if WrapBTN.get_selected_id() == 1:
|
||||||
current_editor.set_wrap_enabled(true)
|
current_editor.set_wrap_enabled(true)
|
||||||
|
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
func open_in_inieditor(path : String) -> Control:
|
func open_in_inieditor(path : String) -> Control:
|
||||||
var extension = path.get_file().get_extension()
|
var extension = path.get_file().get_extension()
|
||||||
if extension == "ini" or extension == "cfg":
|
if extension == "ini" or extension == "cfg":
|
||||||
var inieditor = IniEditor.instance()
|
var inieditor = IniEditor.instance()
|
||||||
SplitEditorContainer.add_child(inieditor)
|
SplitEditorContainer.add_child(inieditor)
|
||||||
inieditor.hide()
|
inieditor.hide()
|
||||||
inieditor.connect("update_file",self,"_on_update_file")
|
inieditor.connect("update_file",self,"_on_update_file")
|
||||||
current_ini_editor = inieditor
|
current_ini_editor = inieditor
|
||||||
inieditor.current_file_path = path
|
inieditor.current_file_path = path
|
||||||
var current_file : ConfigFile = ConfigFile.new()
|
var current_file : ConfigFile = ConfigFile.new()
|
||||||
var err = current_file.load(path)
|
var err = current_file.load(path)
|
||||||
if err == OK:
|
if err == OK:
|
||||||
var sections = current_file.get_sections()
|
var sections = current_file.get_sections()
|
||||||
var filemap = []
|
var filemap = []
|
||||||
for section in sections:
|
for section in sections:
|
||||||
var keys = []
|
var keys = []
|
||||||
var section_keys = current_file.get_section_keys(section)
|
var section_keys = current_file.get_section_keys(section)
|
||||||
for key in section_keys:
|
for key in section_keys:
|
||||||
keys.append([key,current_file.get_value(section,key)])
|
keys.append([key,current_file.get_value(section,key)])
|
||||||
|
|
||||||
filemap.append([section,keys])
|
filemap.append([section,keys])
|
||||||
|
|
||||||
inieditor.open_file(filemap)
|
inieditor.open_file(filemap)
|
||||||
return inieditor
|
return inieditor
|
||||||
else:
|
else:
|
||||||
current_ini_editor = null
|
current_ini_editor = null
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func open_in_csveditor(path : String) -> Control:
|
func open_in_csveditor(path : String) -> Control:
|
||||||
var extension = path.get_file().get_extension()
|
var extension = path.get_file().get_extension()
|
||||||
if extension == "csv":
|
if extension == "csv":
|
||||||
var csveditor = CsvEditor.instance()
|
var csveditor = CsvEditor.instance()
|
||||||
SplitEditorContainer.add_child(csveditor)
|
SplitEditorContainer.add_child(csveditor)
|
||||||
csveditor.hide()
|
csveditor.hide()
|
||||||
csveditor.connect("update_file",self,"_on_update_file")
|
csveditor.connect("update_file",self,"_on_update_file")
|
||||||
csveditor.connect("editing_file",self,"_on_vanillaeditor_text_changed")
|
csveditor.connect("editing_file",self,"_on_vanillaeditor_text_changed")
|
||||||
current_csv_editor = csveditor
|
current_csv_editor = csveditor
|
||||||
csveditor.current_file_path = path
|
csveditor.current_file_path = path
|
||||||
csveditor.open_csv_file(path)
|
csveditor.open_csv_file(path)
|
||||||
return csveditor
|
return csveditor
|
||||||
else:
|
else:
|
||||||
current_csv_editor = null
|
current_csv_editor = null
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func close_file(index):
|
func close_file(index):
|
||||||
LastOpenedFiles.remove_opened_file(index,OpenFileList)
|
LastOpenedFiles.remove_opened_file(index,OpenFileList)
|
||||||
OpenFileList.remove_item(index)
|
OpenFileList.remove_item(index)
|
||||||
OpenFileName.clear()
|
OpenFileName.clear()
|
||||||
current_editor.queue_free()
|
current_editor.queue_free()
|
||||||
|
|
||||||
if index>0:
|
if index>0:
|
||||||
OpenFileList.select(OpenFileList.get_item_count()-1)
|
OpenFileList.select(OpenFileList.get_item_count()-1)
|
||||||
_on_fileitem_pressed(OpenFileList.get_item_count()-1)
|
_on_fileitem_pressed(OpenFileList.get_item_count()-1)
|
||||||
|
|
||||||
func _on_update_file():
|
func _on_update_file():
|
||||||
# current_editor.clean_editor()
|
# current_editor.clean_editor()
|
||||||
var current_file : File = File.new()
|
var current_file : File = File.new()
|
||||||
current_file.open(current_file_path,File.READ)
|
current_file.open(current_file_path,File.READ)
|
||||||
|
|
||||||
var current_content = current_file.get_as_text()
|
var current_content = current_file.get_as_text()
|
||||||
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
|
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
|
||||||
|
|
||||||
current_file.close()
|
current_file.close()
|
||||||
|
|
||||||
current_editor.new_file_open(current_content,last_modified,current_file_path)
|
current_editor.new_file_open(current_content,last_modified,current_file_path)
|
||||||
|
|
||||||
func delete_file(files_selected : PoolStringArray):
|
func delete_file(files_selected : PoolStringArray):
|
||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
for file in files_selected:
|
for file in files_selected:
|
||||||
dir.remove(file)
|
dir.remove(file)
|
||||||
|
|
||||||
update_list()
|
update_list()
|
||||||
|
|
||||||
func open_newfiledialogue():
|
func open_newfiledialogue():
|
||||||
NewFileDialogue.popup()
|
NewFileDialogue.popup()
|
||||||
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 open_filelist():
|
func open_filelist():
|
||||||
update_list()
|
update_list()
|
||||||
FileList.popup()
|
FileList.popup()
|
||||||
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
|
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
|
||||||
|
|
||||||
func create_new_file(given_path : String):
|
func create_new_file(given_path : String):
|
||||||
var current_file = File.new()
|
var current_file = File.new()
|
||||||
current_file.open(given_path,File.WRITE)
|
current_file.open(given_path,File.WRITE)
|
||||||
if save_as :
|
if save_as :
|
||||||
current_file.store_line(current_editor.get_node("TextEditor").get_text())
|
current_file.store_line(current_editor.get_node("TextEditor").get_text())
|
||||||
current_file.close()
|
current_file.close()
|
||||||
|
|
||||||
open_file(given_path)
|
open_file(given_path)
|
||||||
|
|
||||||
func save_file(current_path : String):
|
func save_file(current_path : String):
|
||||||
print("Saving file: ",current_path)
|
print("Saving file: ",current_path)
|
||||||
var current_file = File.new()
|
var current_file = File.new()
|
||||||
current_file.open(current_path,File.WRITE)
|
current_file.open(current_path,File.WRITE)
|
||||||
var current_content = ""
|
var current_content = ""
|
||||||
var lines = current_editor.get_node("TextEditor").get_line_count()
|
var lines = current_editor.get_node("TextEditor").get_line_count()
|
||||||
for line in range(0,lines):
|
for line in range(0,lines):
|
||||||
if current_editor.get_node("TextEditor").get_line(line) == "":
|
if current_editor.get_node("TextEditor").get_line(line) == "":
|
||||||
continue
|
continue
|
||||||
current_content = current_editor.get_node("TextEditor").get_text()
|
current_content = current_editor.get_node("TextEditor").get_text()
|
||||||
current_file.store_line(current_editor.get_node("TextEditor").get_line(line))
|
current_file.store_line(current_editor.get_node("TextEditor").get_line(line))
|
||||||
current_file.close()
|
current_file.close()
|
||||||
|
|
||||||
current_file_path = current_path
|
current_file_path = current_path
|
||||||
|
|
||||||
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
|
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
|
||||||
|
|
||||||
current_editor.update_lastmodified(last_modified,"save")
|
current_editor.update_lastmodified(last_modified,"save")
|
||||||
if current_csv_editor != null and not current_csv_editor.is_visible():
|
if current_csv_editor != null and not current_csv_editor.is_visible():
|
||||||
current_csv_editor.open_csv_file(current_path)
|
current_csv_editor.open_csv_file(current_path)
|
||||||
OpenFileList.set_item_metadata(current_file_index,[current_editor,current_ini_editor,current_csv_editor])
|
OpenFileList.set_item_metadata(current_file_index,[current_editor,current_ini_editor,current_csv_editor])
|
||||||
|
|
||||||
if OpenFileList.get_item_text(current_file_index).begins_with("(*)"):
|
if OpenFileList.get_item_text(current_file_index).begins_with("(*)"):
|
||||||
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index).lstrip("(*)"))
|
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index).lstrip("(*)"))
|
||||||
|
|
||||||
# OpenFileList.set_item_metadata(current_file_index,[current_editor,open_in_inieditor(current_file_path),open_in_csveditor(current_file_path)])
|
# OpenFileList.set_item_metadata(current_file_index,[current_editor,open_in_inieditor(current_file_path),open_in_csveditor(current_file_path)])
|
||||||
|
|
||||||
update_list()
|
update_list()
|
||||||
|
|
||||||
func clean_editor() -> void :
|
func clean_editor() -> void :
|
||||||
for inieditor in get_tree().get_nodes_in_group("ini_editor"):
|
for inieditor in get_tree().get_nodes_in_group("ini_editor"):
|
||||||
inieditor.queue_free()
|
inieditor.queue_free()
|
||||||
for vanillaeditor in get_tree().get_nodes_in_group("vanilla_editor"):
|
for vanillaeditor in get_tree().get_nodes_in_group("vanilla_editor"):
|
||||||
vanillaeditor.queue_free()
|
vanillaeditor.queue_free()
|
||||||
OpenFileName.clear()
|
OpenFileName.clear()
|
||||||
OpenFileList.clear()
|
OpenFileList.clear()
|
||||||
|
|
||||||
|
|
||||||
func csv_preview():
|
func csv_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_file_path.get_file()+")"
|
preview.window_title += " ("+current_file_path.get_file()+")"
|
||||||
var lines = current_editor.get_node("TextEditor").get_line_count()
|
var lines = current_editor.get_node("TextEditor").get_line_count()
|
||||||
var rows = []
|
var rows = []
|
||||||
for i in range(0,lines-1):
|
for i in range(0,lines-1):
|
||||||
rows.append(current_editor.get_node("TextEditor").get_line(i).rsplit(",",false))
|
rows.append(current_editor.get_node("TextEditor").get_line(i).rsplit(",",false))
|
||||||
preview.print_csv(rows)
|
preview.print_csv(rows)
|
||||||
|
|
||||||
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_file_path.get_file()+")"
|
preview.window_title += " ("+current_file_path.get_file()+")"
|
||||||
preview.print_bb(current_editor.get_node("TextEditor").get_text())
|
preview.print_bb(current_editor.get_node("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_file_path.get_file()+")"
|
preview.window_title += " ("+current_file_path.get_file()+")"
|
||||||
preview.print_markdown(current_editor.get_node("TextEditor").get_text())
|
preview.print_markdown(current_editor.get_node("TextEditor").get_text())
|
||||||
|
|
||||||
func html_preview():
|
func html_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_file_path.get_file()+")"
|
preview.window_title += " ("+current_file_path.get_file()+")"
|
||||||
preview.print_html(current_editor.get_node("TextEditor").get_text())
|
preview.print_html(current_editor.get_node("TextEditor").get_text())
|
||||||
|
|
||||||
func xml_preview():
|
func xml_preview():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func json_preview():
|
func json_preview():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _on_vanillaeditor_text_changed():
|
func _on_vanillaeditor_text_changed():
|
||||||
if not OpenFileList.get_item_text(current_file_index).begins_with("(*)"):
|
if not OpenFileList.get_item_text(current_file_index).begins_with("(*)"):
|
||||||
OpenFileList.set_item_text(current_file_index,"(*)"+OpenFileList.get_item_text(current_file_index))
|
OpenFileList.set_item_text(current_file_index,"(*)"+OpenFileList.get_item_text(current_file_index))
|
||||||
|
|
||||||
|
|
||||||
func update_list():
|
func update_list():
|
||||||
FileList.invalidate()
|
FileList.invalidate()
|
||||||
|
|
||||||
func on_wrap_button(index:int):
|
func on_wrap_button(index:int):
|
||||||
match index:
|
match index:
|
||||||
0:
|
0:
|
||||||
current_editor.set_wrap_enabled(false)
|
current_editor.set_wrap_enabled(false)
|
||||||
1:
|
1:
|
||||||
current_editor.set_wrap_enabled(true)
|
current_editor.set_wrap_enabled(true)
|
||||||
|
|
||||||
func on_minimap_button(index:int):
|
func on_minimap_button(index:int):
|
||||||
match index:
|
match index:
|
||||||
0:
|
0:
|
||||||
current_editor.draw_minimap(false)
|
current_editor.draw_minimap(false)
|
||||||
1:
|
1:
|
||||||
current_editor.draw_minimap(true)
|
current_editor.draw_minimap(true)
|
||||||
|
|
||||||
func check_file_preview(file : String):
|
func check_file_preview(file : String):
|
||||||
# check whether the opened file has a corresponding preview session for its extension
|
# check whether the opened file has a corresponding preview session for its extension
|
||||||
pass
|
pass
|
||||||
|
@ -30,198 +30,198 @@ var search_flag = 0
|
|||||||
signal text_changed()
|
signal text_changed()
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
FileList = get_parent().get_parent().get_parent().get_parent().get_node("FileList")
|
FileList = get_parent().get_parent().get_parent().get_parent().get_node("FileList")
|
||||||
ClosingFile = get_parent().get_parent().get_parent().get_parent().get_node("ConfirmationDialog")
|
ClosingFile = get_parent().get_parent().get_parent().get_parent().get_node("ConfirmationDialog")
|
||||||
ClosingFile.connect("confirmed",self,"queue_free")
|
ClosingFile.connect("confirmed",self,"queue_free")
|
||||||
|
|
||||||
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/checked",IconLoader.load_icon_from_name("read"))
|
||||||
ReadOnly.set("custom_icons/unchecked",IconLoader.load_icon_from_name("edit"))
|
ReadOnly.set("custom_icons/unchecked",IconLoader.load_icon_from_name("edit"))
|
||||||
|
|
||||||
add_to_group("vanilla_editor")
|
add_to_group("vanilla_editor")
|
||||||
load_default_font()
|
load_default_font()
|
||||||
|
|
||||||
func set_font(font_path : String) -> void:
|
func set_font(font_path : String) -> void:
|
||||||
var dynamic_font : DynamicFont = DynamicFont.new()
|
var dynamic_font : DynamicFont = DynamicFont.new()
|
||||||
var dynamic_font_data : DynamicFontData = DynamicFontData.new()
|
var dynamic_font_data : DynamicFontData = DynamicFontData.new()
|
||||||
dynamic_font_data.set_font_path(font_path)
|
dynamic_font_data.set_font_path(font_path)
|
||||||
dynamic_font.set_font_data(dynamic_font_data)
|
dynamic_font.set_font_data(dynamic_font_data)
|
||||||
TextEditor.set("custom_fonts/font",dynamic_font)
|
TextEditor.set("custom_fonts/font",dynamic_font)
|
||||||
|
|
||||||
func load_default_font() -> void:
|
func load_default_font() -> void:
|
||||||
var default_font = LastOpenedFiles.get_editor_font()
|
var default_font = LastOpenedFiles.get_editor_font()
|
||||||
if default_font:
|
if default_font:
|
||||||
set_font(default_font)
|
set_font(default_font)
|
||||||
|
|
||||||
func set_wrap_enabled(enabled:bool):
|
func set_wrap_enabled(enabled:bool):
|
||||||
TextEditor.set_wrap_enabled(enabled)
|
TextEditor.set_wrap_enabled(enabled)
|
||||||
TextEditor.update()
|
TextEditor.update()
|
||||||
|
|
||||||
func draw_minimap(value:bool):
|
func draw_minimap(value:bool):
|
||||||
TextEditor.draw_minimap(value)
|
TextEditor.draw_minimap(value)
|
||||||
TextEditor.update()
|
TextEditor.update()
|
||||||
|
|
||||||
func color_region(filextension : String): # -----------------------------> dal momento che voglio creare un editor per ogni file, renderò questa funzione singola in base all'estensione del file
|
func color_region(filextension : String): # -----------------------------> dal momento che voglio creare un editor per ogni file, renderò questa funzione singola in base all'estensione del file
|
||||||
match(filextension):
|
match(filextension):
|
||||||
"bbs":
|
"bbs":
|
||||||
TextEditor.add_color_region("[b]","[/b]",Color8(153,153,255,255),false)
|
TextEditor.add_color_region("[b]","[/b]",Color8(153,153,255,255),false)
|
||||||
TextEditor.add_color_region("[i]","[/i]",Color8(153,255,153,255),false)
|
TextEditor.add_color_region("[i]","[/i]",Color8(153,255,153,255),false)
|
||||||
TextEditor.add_color_region("[s]","[/s]",Color8(255,153,153,255),false)
|
TextEditor.add_color_region("[s]","[/s]",Color8(255,153,153,255),false)
|
||||||
TextEditor.add_color_region("[u]","[/u]",Color8(255,255,102,255),false)
|
TextEditor.add_color_region("[u]","[/u]",Color8(255,255,102,255),false)
|
||||||
TextEditor.add_color_region("[url","[/url]",Color8(153,204,255,255),false)
|
TextEditor.add_color_region("[url","[/url]",Color8(153,204,255,255),false)
|
||||||
TextEditor.add_color_region("[code]","[/code]",Color8(192,192,192,255),false)
|
TextEditor.add_color_region("[code]","[/code]",Color8(192,192,192,255),false)
|
||||||
TextEditor.add_color_region("[img]","[/img]",Color8(255,204,153,255),false)
|
TextEditor.add_color_region("[img]","[/img]",Color8(255,204,153,255),false)
|
||||||
TextEditor.add_color_region("[center]","[/center]",Color8(175,238,238,255),false)
|
TextEditor.add_color_region("[center]","[/center]",Color8(175,238,238,255),false)
|
||||||
TextEditor.add_color_region("[right]","[/right]",Color8(135,206,235,255),false)
|
TextEditor.add_color_region("[right]","[/right]",Color8(135,206,235,255),false)
|
||||||
"html":
|
"html":
|
||||||
TextEditor.add_color_region("<b>","</b>",Color8(153,153,255,255),false)
|
TextEditor.add_color_region("<b>","</b>",Color8(153,153,255,255),false)
|
||||||
TextEditor.add_color_region("<i>","</i>",Color8(153,255,153,255),false)
|
TextEditor.add_color_region("<i>","</i>",Color8(153,255,153,255),false)
|
||||||
TextEditor.add_color_region("<del>","</del>",Color8(255,153,153,255),false)
|
TextEditor.add_color_region("<del>","</del>",Color8(255,153,153,255),false)
|
||||||
TextEditor.add_color_region("<ins>","</ins>",Color8(255,255,102,255),false)
|
TextEditor.add_color_region("<ins>","</ins>",Color8(255,255,102,255),false)
|
||||||
TextEditor.add_color_region("<a","</a>",Color8(153,204,255,255),false)
|
TextEditor.add_color_region("<a","</a>",Color8(153,204,255,255),false)
|
||||||
TextEditor.add_color_region("<img","/>",Color8(255,204,153,255),true)
|
TextEditor.add_color_region("<img","/>",Color8(255,204,153,255),true)
|
||||||
TextEditor.add_color_region("<pre>","</pre>",Color8(192,192,192,255),false)
|
TextEditor.add_color_region("<pre>","</pre>",Color8(192,192,192,255),false)
|
||||||
TextEditor.add_color_region("<center>","</center>",Color8(175,238,238,255),false)
|
TextEditor.add_color_region("<center>","</center>",Color8(175,238,238,255),false)
|
||||||
TextEditor.add_color_region("<right>","</right>",Color8(135,206,235,255),false)
|
TextEditor.add_color_region("<right>","</right>",Color8(135,206,235,255),false)
|
||||||
"md":
|
"md":
|
||||||
TextEditor.add_color_region("***","***",Color8(126,186,181,255),false)
|
TextEditor.add_color_region("***","***",Color8(126,186,181,255),false)
|
||||||
TextEditor.add_color_region("**","**",Color8(153,153,255,255),false)
|
TextEditor.add_color_region("**","**",Color8(153,153,255,255),false)
|
||||||
TextEditor.add_color_region("*","*",Color8(153,255,153,255),false)
|
TextEditor.add_color_region("*","*",Color8(153,255,153,255),false)
|
||||||
TextEditor.add_color_region("+ ","",Color8(255,178,102,255),false)
|
TextEditor.add_color_region("+ ","",Color8(255,178,102,255),false)
|
||||||
TextEditor.add_color_region("- ","",Color8(255,178,102,255),false)
|
TextEditor.add_color_region("- ","",Color8(255,178,102,255),false)
|
||||||
TextEditor.add_color_region("~~","~~",Color8(255,153,153,255),false)
|
TextEditor.add_color_region("~~","~~",Color8(255,153,153,255),false)
|
||||||
TextEditor.add_color_region("__","__",Color8(255,255,102,255),false)
|
TextEditor.add_color_region("__","__",Color8(255,255,102,255),false)
|
||||||
TextEditor.add_color_region("[",")",Color8(153,204,255,255),false)
|
TextEditor.add_color_region("[",")",Color8(153,204,255,255),false)
|
||||||
TextEditor.add_color_region("`","`",Color8(192,192,192,255),false)
|
TextEditor.add_color_region("`","`",Color8(192,192,192,255),false)
|
||||||
TextEditor.add_color_region('"*.','"',Color8(255,255,255,255),true)
|
TextEditor.add_color_region('"*.','"',Color8(255,255,255,255),true)
|
||||||
TextEditor.add_color_region("# ","",Color8(105,105,105,255),true)
|
TextEditor.add_color_region("# ","",Color8(105,105,105,255),true)
|
||||||
TextEditor.add_color_region("## ","",Color8(128,128,128,255),true)
|
TextEditor.add_color_region("## ","",Color8(128,128,128,255),true)
|
||||||
TextEditor.add_color_region("### ","",Color8(169,169,169,255),true)
|
TextEditor.add_color_region("### ","",Color8(169,169,169,255),true)
|
||||||
TextEditor.add_color_region("#### ","",Color8(192,192,192,255),true)
|
TextEditor.add_color_region("#### ","",Color8(192,192,192,255),true)
|
||||||
TextEditor.add_color_region("##### ","",Color8(211,211,211,255),true)
|
TextEditor.add_color_region("##### ","",Color8(211,211,211,255),true)
|
||||||
TextEditor.add_color_region("###### ","",Color8(255,255,255,255),true)
|
TextEditor.add_color_region("###### ","",Color8(255,255,255,255),true)
|
||||||
TextEditor.add_color_region("> ","",Color8(172,138,79,255),true)
|
TextEditor.add_color_region("> ","",Color8(172,138,79,255),true)
|
||||||
"cfg":
|
"cfg":
|
||||||
TextEditor.add_color_region("[","]",Color8(153,204,255,255),false)
|
TextEditor.add_color_region("[","]",Color8(153,204,255,255),false)
|
||||||
TextEditor.add_color_region('"','"',Color8(255,255,102,255),false)
|
TextEditor.add_color_region('"','"',Color8(255,255,102,255),false)
|
||||||
TextEditor.add_color_region(';','',Color8(128,128,128,255),true)
|
TextEditor.add_color_region(';','',Color8(128,128,128,255),true)
|
||||||
"ini":
|
"ini":
|
||||||
TextEditor.add_color_region("[","]",Color8(153,204,255,255),false)
|
TextEditor.add_color_region("[","]",Color8(153,204,255,255),false)
|
||||||
TextEditor.add_color_region('"','"',Color8(255,255,102,255),false)
|
TextEditor.add_color_region('"','"',Color8(255,255,102,255),false)
|
||||||
TextEditor.add_color_region(';','',Color8(128,128,128,255),true)
|
TextEditor.add_color_region(';','',Color8(128,128,128,255),true)
|
||||||
_:
|
_:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func clean_editor():
|
func clean_editor():
|
||||||
TextEditor.set_text("")
|
TextEditor.set_text("")
|
||||||
LastModifiedIcon.texture = IconLoader.load_icon_from_name("save")
|
LastModifiedIcon.texture = IconLoader.load_icon_from_name("save")
|
||||||
LastModified.set_text("")
|
LastModified.set_text("")
|
||||||
FileList.invalidate()
|
FileList.invalidate()
|
||||||
current_filename = ""
|
current_filename = ""
|
||||||
current_path = ""
|
current_path = ""
|
||||||
|
|
||||||
func new_file_open(file_content : String, last_modified : Dictionary, current_file_path : String):
|
func new_file_open(file_content : String, last_modified : Dictionary, current_file_path : String):
|
||||||
current_path = current_file_path
|
current_path = current_file_path
|
||||||
current_filename = current_file_path.get_file()
|
current_filename = current_file_path.get_file()
|
||||||
color_region(current_filename.get_extension())
|
color_region(current_filename.get_extension())
|
||||||
TextEditor.set_text(file_content)
|
TextEditor.set_text(file_content)
|
||||||
update_lastmodified(last_modified,"save")
|
update_lastmodified(last_modified,"save")
|
||||||
FileList.invalidate()
|
FileList.invalidate()
|
||||||
count_characters()
|
count_characters()
|
||||||
|
|
||||||
func update_lastmodified(last_modified : Dictionary, icon : String):
|
func update_lastmodified(last_modified : Dictionary, icon : String):
|
||||||
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(icon)
|
LastModifiedIcon.texture = IconLoader.load_icon_from_name(icon)
|
||||||
|
|
||||||
func new_file_create(file_name):
|
func new_file_create(file_name):
|
||||||
TextEditor.set_text("")
|
TextEditor.set_text("")
|
||||||
|
|
||||||
FileList.invalidate()
|
FileList.invalidate()
|
||||||
|
|
||||||
func _on_Readonly_toggled(button_pressed):
|
func _on_Readonly_toggled(button_pressed):
|
||||||
if button_pressed:
|
if button_pressed:
|
||||||
ReadOnly.set_text("Read Only")
|
ReadOnly.set_text("Read Only")
|
||||||
TextEditor.readonly = (true)
|
TextEditor.readonly = (true)
|
||||||
else:
|
else:
|
||||||
ReadOnly.set_text("Can Edit")
|
ReadOnly.set_text("Can Edit")
|
||||||
TextEditor.readonly = (false)
|
TextEditor.readonly = (false)
|
||||||
|
|
||||||
func _on_TextEditor_text_changed():
|
func _on_TextEditor_text_changed():
|
||||||
LastModifiedIcon.texture = IconLoader.load_icon_from_name("saveas")
|
LastModifiedIcon.texture = IconLoader.load_icon_from_name("saveas")
|
||||||
count_characters()
|
count_characters()
|
||||||
emit_signal("text_changed")
|
emit_signal("text_changed")
|
||||||
|
|
||||||
func count_characters():
|
func count_characters():
|
||||||
var counted : int = 0
|
var counted : int = 0
|
||||||
for line in TextEditor.get_line_count():
|
for line in TextEditor.get_line_count():
|
||||||
counted += TextEditor.get_line(line).length()
|
counted += TextEditor.get_line(line).length()
|
||||||
c_counter.set_text(str(counted))
|
c_counter.set_text(str(counted))
|
||||||
|
|
||||||
func _on_LineEdit_text_changed(new_text):
|
func _on_LineEdit_text_changed(new_text):
|
||||||
var linecount = TextEditor.get_line_count()
|
var linecount = TextEditor.get_line_count()
|
||||||
if new_text != "":
|
if new_text != "":
|
||||||
var found
|
var found
|
||||||
var find = false
|
var find = false
|
||||||
for line in range(0,linecount):
|
for line in range(0,linecount):
|
||||||
for column in range(0,TextEditor.get_line(line).length()):
|
for column in range(0,TextEditor.get_line(line).length()):
|
||||||
found = TextEditor.search( new_text, search_flag, line , column )
|
found = TextEditor.search( new_text, search_flag, line , column )
|
||||||
if found.size():
|
if found.size():
|
||||||
if found[1] == line:
|
if found[1] == line:
|
||||||
# if not find:
|
# if not find:
|
||||||
TextEditor.select(line,found[0],found[1],found[0]+new_text.length())
|
TextEditor.select(line,found[0],found[1],found[0]+new_text.length())
|
||||||
# find = true
|
# find = true
|
||||||
else:
|
else:
|
||||||
TextEditor.select(0,0,0,0)
|
TextEditor.select(0,0,0,0)
|
||||||
else:
|
else:
|
||||||
TextEditor.select(0,0,0,0)
|
TextEditor.select(0,0,0,0)
|
||||||
|
|
||||||
func _on_matchcase_toggled(button_pressed):
|
func _on_matchcase_toggled(button_pressed):
|
||||||
if button_pressed:
|
if button_pressed:
|
||||||
search_flag = 1
|
search_flag = 1
|
||||||
else:
|
else:
|
||||||
if $SearchBox/wholewords.is_pressed():
|
if $SearchBox/wholewords.is_pressed():
|
||||||
search_flag = 2
|
search_flag = 2
|
||||||
else:
|
else:
|
||||||
search_flag = 0
|
search_flag = 0
|
||||||
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
||||||
|
|
||||||
func _on_wholewords_toggled(button_pressed):
|
func _on_wholewords_toggled(button_pressed):
|
||||||
if button_pressed:
|
if button_pressed:
|
||||||
search_flag = 2
|
search_flag = 2
|
||||||
else:
|
else:
|
||||||
if $SearchBox/matchcase.is_pressed():
|
if $SearchBox/matchcase.is_pressed():
|
||||||
search_flag = 1
|
search_flag = 1
|
||||||
else:
|
else:
|
||||||
search_flag = 0
|
search_flag = 0
|
||||||
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
||||||
|
|
||||||
func _on_close_pressed():
|
func _on_close_pressed():
|
||||||
SearchBox.hide()
|
SearchBox.hide()
|
||||||
|
|
||||||
func open_searchbox():
|
func open_searchbox():
|
||||||
if SearchBox.visible:
|
if SearchBox.visible:
|
||||||
SearchBox.hide()
|
SearchBox.hide()
|
||||||
else:
|
else:
|
||||||
SearchBox.show()
|
SearchBox.show()
|
||||||
SearchBox.get_node("LineEdit").grab_focus()
|
SearchBox.get_node("LineEdit").grab_focus()
|
||||||
|
|
||||||
func _on_Button_pressed():
|
func _on_Button_pressed():
|
||||||
var linecount = TextEditor.get_line_count()-1
|
var linecount = TextEditor.get_line_count()-1
|
||||||
var old_text = $ReplaceBox/replace.get_text()
|
var old_text = $ReplaceBox/replace.get_text()
|
||||||
var new_text = $ReplaceBox/with.get_text()
|
var new_text = $ReplaceBox/with.get_text()
|
||||||
var text = TextEditor.get_text()
|
var text = TextEditor.get_text()
|
||||||
TextEditor.set_text(text.replace(old_text,new_text))
|
TextEditor.set_text(text.replace(old_text,new_text))
|
||||||
|
|
||||||
func open_replacebox():
|
func open_replacebox():
|
||||||
if ReplaceBox.visible:
|
if ReplaceBox.visible:
|
||||||
ReplaceBox.hide()
|
ReplaceBox.hide()
|
||||||
else:
|
else:
|
||||||
ReplaceBox.show()
|
ReplaceBox.show()
|
||||||
ReplaceBox.get_node("replace").grab_focus()
|
ReplaceBox.get_node("replace").grab_focus()
|
||||||
|
|
||||||
func _on_close2_pressed():
|
func _on_close2_pressed():
|
||||||
ReplaceBox.hide()
|
ReplaceBox.hide()
|
||||||
|
|
||||||
func _on_LineEdit_focus_entered():
|
func _on_LineEdit_focus_entered():
|
||||||
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
_on_LineEdit_text_changed($SearchBox/LineEdit.get_text())
|
||||||
|
Loading…
Reference in New Issue
Block a user