mirror of
https://github.com/Relintai/Godot-TextEditor.git
synced 2025-01-26 16:59:19 +01:00
1.1
This commit is contained in:
parent
aef3075863
commit
b2cd4a035e
@ -1,3 +1,6 @@
|
|||||||
# 1.1
|
# 1.1
|
||||||
- `fix` Loading settings caused printed an error.
|
- Fixed files and directories not being sorted.
|
||||||
- Get rid of test file.
|
- Added `addons` folder hider option.
|
||||||
|
- Fixed "failed to load settings" error.
|
||||||
|
- Tweaked syntax coloring.
|
||||||
|
- Got rid of accidental test file.
|
||||||
|
1
addons/test.txt
Normal file
1
addons/test.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -217,7 +217,7 @@ func update_symbols():
|
|||||||
else:
|
else:
|
||||||
tags[tag] += 1
|
tags[tag] += 1
|
||||||
|
|
||||||
var _e = TE_Util.sort(tags, true)
|
# var _e = TE_Util.sort(tags, true)
|
||||||
editor._file_symbols_updated(file_path)
|
editor._file_symbols_updated(file_path)
|
||||||
|
|
||||||
func close():
|
func close():
|
||||||
|
@ -36,12 +36,27 @@ func _clicked(id):
|
|||||||
var tag = tag_indices[int(id)]
|
var tag = tag_indices[int(id)]
|
||||||
editor.enable_tag(tag, not editor.is_tag_enabled(tag))
|
editor.enable_tag(tag, not editor.is_tag_enabled(tag))
|
||||||
|
|
||||||
|
func sort_tags(tags:Dictionary):
|
||||||
|
var sorter:Array = []
|
||||||
|
for tag in tags:
|
||||||
|
sorter.append([tag, tags[tag]])
|
||||||
|
|
||||||
|
sorter.sort_custom(self, "_sort_tags")
|
||||||
|
|
||||||
|
tags.clear()
|
||||||
|
for item in sorter:
|
||||||
|
tags[item[0]] = item[1]
|
||||||
|
return tags
|
||||||
|
|
||||||
|
func _sort_tags(a, b):
|
||||||
|
return a[0] < b[0]
|
||||||
|
|
||||||
func _redraw():
|
func _redraw():
|
||||||
var tab = editor.get_selected_tab()
|
var tab = editor.get_selected_tab()
|
||||||
var tags = editor.tag_counts
|
var tags = editor.tag_counts
|
||||||
var tab_tags = {} if not tab else tab.tags
|
var tab_tags = {} if not tab else tab.tags
|
||||||
|
|
||||||
TE_Util.sort_value(tags)
|
sort_tags(tags)
|
||||||
|
|
||||||
if not tags:
|
if not tags:
|
||||||
set_bbcode("[color=#%s][i][center]*No tags*" % [Color.webgray.to_html()])
|
set_bbcode("[color=#%s][i][center]*No tags*" % [Color.webgray.to_html()])
|
||||||
|
@ -50,6 +50,7 @@ var show:Dictionary = {
|
|||||||
hidden=true,
|
hidden=true,
|
||||||
gdignore=true,
|
gdignore=true,
|
||||||
|
|
||||||
|
addons=false,
|
||||||
git=false,
|
git=false,
|
||||||
import=false,
|
import=false,
|
||||||
trash=false
|
trash=false
|
||||||
@ -132,16 +133,17 @@ func _ready():
|
|||||||
popup_view_dir.clear()
|
popup_view_dir.clear()
|
||||||
popup_view_dir.set_name("Directories")
|
popup_view_dir.set_name("Directories")
|
||||||
popup_view_dir.add_font_override("font", FONT_R)
|
popup_view_dir.add_font_override("font", FONT_R)
|
||||||
popup_view_dir.add_check_item("Hidden", 0)
|
popup_view_dir.add_check_item("Hidden", hash("Hidden"))
|
||||||
popup_view_dir.add_check_item("Empty", 1)
|
popup_view_dir.add_check_item("Empty", hash("Empty"))
|
||||||
popup_view_dir.add_check_item(".gdignore", 2)
|
popup_view_dir.add_check_item(".gdignore", hash(".gdignore"))
|
||||||
popup_view_dir.set_item_checked(0, show.dir.hidden)
|
popup_view_dir.set_item_checked(0, show.dir.hidden)
|
||||||
popup_view_dir.set_item_checked(1, show.dir.gdignore)
|
popup_view_dir.set_item_checked(1, show.dir.empty)
|
||||||
popup_view_dir.set_item_checked(2, show.dir.empty)
|
popup_view_dir.set_item_checked(2, show.dir.gdignore)
|
||||||
popup_view_dir.add_separator()
|
popup_view_dir.add_separator()
|
||||||
popup_view_dir.add_check_item(".import/", 4)
|
popup_view_dir.add_check_item("addons/", hash("addons/"))
|
||||||
popup_view_dir.add_check_item(".git/", 5)
|
popup_view_dir.add_check_item(".import/", hash(".import/"))
|
||||||
popup_view_dir.add_check_item(".trash/", 6)
|
popup_view_dir.add_check_item(".git/", hash(".git/"))
|
||||||
|
popup_view_dir.add_check_item(".trash/", hash(".trash/"))
|
||||||
|
|
||||||
popup_view.add_child(popup_view_dir)
|
popup_view.add_child(popup_view_dir)
|
||||||
popup_view.add_submenu_item("Directories", "Directories")
|
popup_view.add_submenu_item("Directories", "Directories")
|
||||||
@ -200,7 +202,13 @@ func load_state():
|
|||||||
tab_parent.current_tab = selected.get_index()
|
tab_parent.current_tab = selected.get_index()
|
||||||
|
|
||||||
current_directory = state.current
|
current_directory = state.current
|
||||||
show = state.show
|
|
||||||
|
for k in state.show.dir:
|
||||||
|
show.dir[k] = state.show.dir[k]
|
||||||
|
|
||||||
|
for k in state.show.file:
|
||||||
|
show.file[k] = state.show.file[k]
|
||||||
|
|
||||||
tag_counts = state.tag_counts
|
tag_counts = state.tag_counts
|
||||||
tags_enabled = state.tags_enabled
|
tags_enabled = state.tags_enabled
|
||||||
exts_enabled = state.exts_enabled
|
exts_enabled = state.exts_enabled
|
||||||
@ -232,7 +240,6 @@ func save_state():
|
|||||||
TE_Util.save_json(PATH_STATE, state)
|
TE_Util.save_json(PATH_STATE, state)
|
||||||
emit_signal("state_saved")
|
emit_signal("state_saved")
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
save_state()
|
save_state()
|
||||||
|
|
||||||
@ -271,33 +278,35 @@ func _apply_fonts(n:Node):
|
|||||||
n.add_font_override("font", FONT_R)
|
n.add_font_override("font", FONT_R)
|
||||||
|
|
||||||
func _menu_file(id):
|
func _menu_file(id):
|
||||||
# var index = popup_file.get_item_index(id)
|
|
||||||
# var data = popup_file.items[index]
|
|
||||||
# prints(id, index, data)
|
|
||||||
match id:
|
match id:
|
||||||
100: popup_create_file() # "New File"
|
100: popup_create_file() # "New File"
|
||||||
200: popup_create_dir() # "New Folder"
|
200: popup_create_dir() # "New Folder"
|
||||||
300: open_last_file() # "Open last closed"
|
300: open_last_file() # "Open last closed"
|
||||||
|
|
||||||
func _menu_view_dir(index:int):
|
func _menu_view_dir(index:int):
|
||||||
match index:
|
var text = popup_view_dir.get_item_text(index)
|
||||||
0:
|
print(text)
|
||||||
|
match text:
|
||||||
|
"Hidden":
|
||||||
show.dir.hidden = not show.dir.hidden
|
show.dir.hidden = not show.dir.hidden
|
||||||
popup_view_dir.set_item_checked(index, show.dir.hidden)
|
popup_view_dir.set_item_checked(index, show.dir.hidden)
|
||||||
1:
|
"Empty":
|
||||||
show.dir.empty = not show.dir.empty
|
show.dir.empty = not show.dir.empty
|
||||||
popup_view_dir.set_item_checked(index, show.dir.empty)
|
popup_view_dir.set_item_checked(index, show.dir.empty)
|
||||||
2:
|
".gdignore":
|
||||||
show.dir.gdignore = not show.dir.gdignore
|
show.dir.gdignore = not show.dir.gdignore
|
||||||
popup_view_dir.set_item_checked(index, show.dir.gdignore)
|
popup_view_dir.set_item_checked(index, show.dir.gdignore)
|
||||||
|
|
||||||
4:
|
"addons/":
|
||||||
|
show.dir.addons = not show.dir.addons
|
||||||
|
popup_view_dir.set_item_checked(index, show.dir.addons)
|
||||||
|
".import/":
|
||||||
show.dir.import = not show.dir.import
|
show.dir.import = not show.dir.import
|
||||||
popup_view_dir.set_item_checked(index, show.dir.import)
|
popup_view_dir.set_item_checked(index, show.dir.import)
|
||||||
5:
|
".git/":
|
||||||
show.dir.git = not show.dir.git
|
show.dir.git = not show.dir.git
|
||||||
popup_view_dir.set_item_checked(index, show.dir.git)
|
popup_view_dir.set_item_checked(index, show.dir.git)
|
||||||
6:
|
".trash/":
|
||||||
show.dir.trash = not show.dir.trash
|
show.dir.trash = not show.dir.trash
|
||||||
popup_view_dir.set_item_checked(index, show.dir.trash)
|
popup_view_dir.set_item_checked(index, show.dir.trash)
|
||||||
|
|
||||||
@ -444,13 +453,6 @@ func _debug_pressed():
|
|||||||
func save_files():
|
func save_files():
|
||||||
emit_signal("save_files")
|
emit_signal("save_files")
|
||||||
|
|
||||||
func sort_files():
|
|
||||||
TE_Util.dig(file_list, self, "_sort")
|
|
||||||
emit_signal("updated_file_list")
|
|
||||||
|
|
||||||
func _sort(dir:Dictionary):
|
|
||||||
return TE_Util.sort_on_ext(dir)
|
|
||||||
|
|
||||||
func get_selected_file() -> String:
|
func get_selected_file() -> String:
|
||||||
var node = get_selected_tab()
|
var node = get_selected_tab()
|
||||||
return node.file_path if node else ""
|
return node.file_path if node else ""
|
||||||
@ -560,7 +562,6 @@ func recycle_file(file_path:String):
|
|||||||
|
|
||||||
# remove by renaming
|
# remove by renaming
|
||||||
rename_file(file_path, new_path)
|
rename_file(file_path, new_path)
|
||||||
print("Send to " + new_path)
|
|
||||||
|
|
||||||
if tab:
|
if tab:
|
||||||
tab_parent.remove_child(tab)
|
tab_parent.remove_child(tab)
|
||||||
@ -636,10 +637,9 @@ func refresh_files():
|
|||||||
var dir = Directory.new()
|
var dir = Directory.new()
|
||||||
if dir.open(current_directory) == OK:
|
if dir.open(current_directory) == OK:
|
||||||
_scan_dir("", current_directory, dir, file_list)
|
_scan_dir("", current_directory, dir, file_list)
|
||||||
|
emit_signal("updated_file_list")
|
||||||
else:
|
else:
|
||||||
push_error("error trying to load %s." % current_directory)
|
push_error("error trying to load %s." % current_directory)
|
||||||
|
|
||||||
sort_files()
|
|
||||||
|
|
||||||
func show_dir(fname:String, base_dir:String) -> bool:
|
func show_dir(fname:String, base_dir:String) -> bool:
|
||||||
if not show.dir.gdignore and File.new().file_exists(base_dir.plus_file(".gdignore")):
|
if not show.dir.gdignore and File.new().file_exists(base_dir.plus_file(".gdignore")):
|
||||||
@ -650,6 +650,8 @@ func show_dir(fname:String, base_dir:String) -> bool:
|
|||||||
if not show.dir.import and fname == ".import": return false
|
if not show.dir.import and fname == ".import": return false
|
||||||
if not show.dir.git and fname == ".git": return false
|
if not show.dir.git and fname == ".git": return false
|
||||||
if not show.dir.trash and fname == ".trash": return false
|
if not show.dir.trash and fname == ".trash": return false
|
||||||
|
else:
|
||||||
|
if not show.dir.addons and fname == "addons": return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
@ -698,6 +700,25 @@ func _scan_dir(id:String, path:String, dir:Directory, last_dir:Dictionary):
|
|||||||
a_dirs.append(p)
|
a_dirs.append(p)
|
||||||
else:
|
else:
|
||||||
a_files.append(a_dirs_and_files[p])
|
a_files.append(a_dirs_and_files[p])
|
||||||
|
|
||||||
|
sort_on_ext(a_dirs)
|
||||||
|
sort_on_ext(a_files)
|
||||||
|
|
||||||
|
func sort_on_ext(items:Array):
|
||||||
|
var sorted = []
|
||||||
|
for a in items:
|
||||||
|
var k = a.get_file()
|
||||||
|
if "." in k:
|
||||||
|
k = k.split(".", true, 1)
|
||||||
|
k = k[1] + k[0]
|
||||||
|
sorted.append([k, a])
|
||||||
|
sorted.sort_custom(self, "_sort_on_ext")
|
||||||
|
for i in len(items):
|
||||||
|
items[i] = sorted[i][1]
|
||||||
|
return items
|
||||||
|
|
||||||
|
func _sort_on_ext(a, b):
|
||||||
|
return a[0] < b[0]
|
||||||
|
|
||||||
static func get_extension(file_path:String) -> String:
|
static func get_extension(file_path:String) -> String:
|
||||||
var file = file_path.get_file()
|
var file = file_path.get_file()
|
||||||
|
@ -83,14 +83,14 @@ static func file_size(path:String) -> String:
|
|||||||
return String.humanize_size(bytes)
|
return String.humanize_size(bytes)
|
||||||
return "-1"
|
return "-1"
|
||||||
|
|
||||||
static func sort(d:Dictionary, reverse:bool=false) -> Dictionary:
|
#static func sort(d, reverse:bool=false):
|
||||||
return Dict.new(d).sort(reverse)
|
# return Dict.new(d).sort(reverse)
|
||||||
|
#
|
||||||
static func sort_value(d:Dictionary, reverse:bool=false) -> Dictionary:
|
#static func sort_value(d:Dictionary, reverse:bool=false) -> Dictionary:
|
||||||
return Dict.new(d).sort_value(reverse)
|
# return Dict.new(d).sort_value(reverse)
|
||||||
|
#
|
||||||
static func sort_on_ext(d:Dictionary, reverse:bool=false) -> Dictionary:
|
#static func sort_on_ext(d:Dictionary, reverse:bool=false) -> Dictionary:
|
||||||
return Dict.new(d).sort_ext(reverse)
|
# return Dict.new(d).sort_ext(reverse)
|
||||||
|
|
||||||
static func split_many(s:String, spliton:String, allow_empty:bool=true) -> PoolStringArray:
|
static func split_many(s:String, spliton:String, allow_empty:bool=true) -> PoolStringArray:
|
||||||
var parts := PoolStringArray()
|
var parts := PoolStringArray()
|
||||||
@ -116,44 +116,60 @@ static func commas(number) -> String:
|
|||||||
out += number[i]
|
out += number[i]
|
||||||
return out
|
return out
|
||||||
|
|
||||||
class Dict:
|
#class Dict:
|
||||||
var d:Dictionary
|
# var sort_array:bool = false
|
||||||
var a:Array = []
|
# var d:Dictionary
|
||||||
var i:int = 0
|
# var a:Array
|
||||||
|
# var sorter:Array = []
|
||||||
func _init(dict:Dictionary):
|
# var i:int = 0
|
||||||
d = dict
|
#
|
||||||
|
# func _init(item):
|
||||||
func _pop():
|
# if item is Array:
|
||||||
for k in d: a.append([k, d[k]])
|
# sort_array = true
|
||||||
|
# a = item
|
||||||
func _unpop() -> Dictionary:
|
# else:
|
||||||
d.clear()
|
# d = item
|
||||||
for i in a: d[i[0]] = i[1]
|
#
|
||||||
return d
|
# func _pop():
|
||||||
|
# if sort_array:
|
||||||
func sort(reverse:bool=false) -> Dictionary:
|
# for i in a: sorter.append(a)
|
||||||
_pop()
|
# else:
|
||||||
a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
# for k in d: sorter.append([k, d[k]])
|
||||||
return _unpop()
|
#
|
||||||
|
# func _unpop():
|
||||||
func sort_value(reverse:bool=false) -> Dictionary:
|
# if sort_array:
|
||||||
_pop()
|
# for i in len(sorter): a[i] = sorter[i]
|
||||||
i = 1
|
# return a
|
||||||
a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
# else:
|
||||||
return _unpop()
|
# d.clear()
|
||||||
|
# for i in a: d[i[0]] = i[1]
|
||||||
func sort_ext(reverse:bool=false) -> Dictionary:
|
# return d
|
||||||
for k in d:
|
#
|
||||||
if "." in k:
|
# func sort(reverse:bool=false):
|
||||||
var p = k.split(".", true, 1)
|
# _pop()
|
||||||
p = p[1] + p[0]
|
# a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
||||||
a.append([k, d[k], p + "." + k])
|
# return _unpop()
|
||||||
else:
|
#
|
||||||
a.append([k, d[k], "." + k])
|
# func sort_value(reverse:bool=false):
|
||||||
i = 2
|
# _pop()
|
||||||
a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
# i = 1
|
||||||
return _unpop()
|
# a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
||||||
|
# return _unpop()
|
||||||
func _sort(a, b): return a[i] > b[i]
|
#
|
||||||
func _sort_reverse(a, b): return a[i] < b[i]
|
# func sort_ext(reverse:bool=false):
|
||||||
|
# if sort_array:
|
||||||
|
# for x in a:
|
||||||
|
# if "." in a:
|
||||||
|
# for k in d:
|
||||||
|
# if "." in k:
|
||||||
|
# var p = k.split(".", true, 1)
|
||||||
|
# p = p[1] + p[0]
|
||||||
|
# a.append([k, d[k], p + "." + k])
|
||||||
|
# else:
|
||||||
|
# a.append([k, d[k], "." + k])
|
||||||
|
# i = 2
|
||||||
|
# a.sort_custom(self, "_sort_reverse" if reverse else "_sort")
|
||||||
|
# return _unpop()
|
||||||
|
#
|
||||||
|
# func _sort(a, b): return a[i] > b[i]
|
||||||
|
# func _sort_reverse(a, b): return a[i] < b[i]
|
||||||
|
@ -130,35 +130,7 @@ custom_fonts/italics_font = ExtResource( 10 )
|
|||||||
custom_fonts/bold_font = ExtResource( 11 )
|
custom_fonts/bold_font = ExtResource( 11 )
|
||||||
custom_fonts/normal_font = ExtResource( 12 )
|
custom_fonts/normal_font = ExtResource( 12 )
|
||||||
bbcode_enabled = true
|
bbcode_enabled = true
|
||||||
bbcode_text = "[url=add_file:0][color=#ff00ff00]+[/color][/url]
|
|
||||||
[color=#ff4d4d4d][url=d:0][color=#ff333333][/color]🗀▼[b]test_files[/b][/url][/color]
|
|
||||||
[url=f:0][color=#ff333333][/color][color=#ff333333]┣╸[/color][i][color=#ff404040]questish[/color][/i].[color=#ff666666]yaml[/color][/url]
|
|
||||||
[url=f:1][color=#ff333333][/color][color=#ff333333]┣╸[/color][i][color=#ff404040]garoyle[/color][/i].[color=#ff666666]md[/color][/url]
|
|
||||||
[url=f:2][color=#ff333333][/color][color=#ff333333]┣╸[/color][i][color=#ff404040]json[/color][/i].[color=#ff666666]json[/color][/url]
|
|
||||||
[url=f:3][color=#ff333333][/color][color=#ff333333]┣╸[/color][i][color=#ff404040]config[/color][/i].[color=#ff666666]ini[/color][/url]
|
|
||||||
[url=f:4][color=#ff333333][/color][color=#ff333333]┣╸[/color][i][color=#ff404040]acc[/color][/i].[color=#ff666666]csv[/color][/url]
|
|
||||||
[color=#ff4d4d4d][url=d:1][color=#ff333333]┃ [/color]🗀▼[b]afolder[/b][/url][/color]
|
|
||||||
[url=f:5][color=#ff333333]┃ [/color][color=#ff333333]┣╸[/color][i][color=#ff404040]new_file[/color][/i].[color=#ff666666]yaml[/color][/url]
|
|
||||||
[url=f:6][color=#ff333333]┃ [/color][color=#ff333333]┣╸[/color][i][color=#ff404040]ass2[/color][/i].[color=#ff666666]yaml[/color][/url]
|
|
||||||
[url=f:7][color=#ff333333]┃ [/color][color=#ff333333]┣╸[/color][i][color=#ff404040]todo[/color][/i].[color=#ff666666]md[/color][/url]
|
|
||||||
[url=f:8][color=#ff333333]┃ [/color][color=#ff333333]┣╸[/color][i][color=#ff404040]my_fileok[/color][/i].[color=#ff666666]md[/color][/url]
|
|
||||||
[color=#ff4d4d4d][url=d:2][color=#ff333333]┃ ┃ [/color]🗀▼[b]New Folder[/b][/url][/color]
|
|
||||||
[url=f:9][color=#ff333333]┃ ┃ [/color][color=#ff333333]┗╸[/color][i][color=#ff404040]mor[/color][/i].[color=#ff666666]md[/color][/url]"
|
|
||||||
meta_underlined = false
|
meta_underlined = false
|
||||||
text = "+
|
|
||||||
🗀▼test_files
|
|
||||||
┣╸questish.yaml
|
|
||||||
┣╸garoyle.md
|
|
||||||
┣╸json.json
|
|
||||||
┣╸config.ini
|
|
||||||
┣╸acc.csv
|
|
||||||
┃ 🗀▼afolder
|
|
||||||
┃ ┣╸new_file.yaml
|
|
||||||
┃ ┣╸ass2.yaml
|
|
||||||
┃ ┣╸todo.md
|
|
||||||
┃ ┣╸my_fileok.md
|
|
||||||
┃ ┃ 🗀▼New Folder
|
|
||||||
┃ ┃ ┗╸mor.md"
|
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -7,7 +7,7 @@ func toggle_comment(t:TextEdit, head:String="<!-- ", tail:String=" -->"):
|
|||||||
func apply_colors(e:TextEditor, t:TextEdit):
|
func apply_colors(e:TextEditor, t:TextEdit):
|
||||||
.apply_colors(e, t)
|
.apply_colors(e, t)
|
||||||
|
|
||||||
var code:Color = e.color_text.darkened(.5)
|
var code:Color = lerp(e.color_text.darkened(.5), Color.yellowgreen, .5)
|
||||||
|
|
||||||
t.add_keyword_color("true", e.color_var)
|
t.add_keyword_color("true", e.color_var)
|
||||||
t.add_keyword_color("false", e.color_var)
|
t.add_keyword_color("false", e.color_var)
|
||||||
|
Loading…
Reference in New Issue
Block a user