diff --git a/README.md b/README.md index 85a8bb5..5c669ff 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ Version 1.0 - `.ini`: `; ` - `.cfg`: `; ` - `.yaml`: `# ` - - Table of Contents (Symbols) # Controls - `ctrl + W` Close file diff --git a/addons/text_editor/TE_FileEditor.gd b/addons/text_editor/TE_FileEditor.gd index 48cddb4..58785d2 100644 --- a/addons/text_editor/TE_FileEditor.gd +++ b/addons/text_editor/TE_FileEditor.gd @@ -51,7 +51,6 @@ func _scroll_h(h:HScrollBar): func _scroll_v(v:VScrollBar): vscroll = v.value - prints(file_path, vscroll) func _tab_changed(index:int): var myindex = get_index() @@ -241,15 +240,18 @@ func update_name(): update_heading() func update_heading(): + if Engine.editor_hint: + return + # set window "file (directory)" var f = file_path.get_file() if modified: f = "*" + f var d = file_path.get_base_dir().get_file() if d: - OS.set_window_title("%s (%s)" % [f, d]) + OS.set_window_title("%s (%s) - Text Editor" % [f, d]) else: - OS.set_window_title(f) + OS.set_window_title("%s - Text Editor" % f) func needs_save() -> bool: return modified or not File.new().file_exists(file_path) diff --git a/addons/text_editor/TE_FilesList.gd b/addons/text_editor/TE_FilesList.gd index de71db3..f54c066 100644 --- a/addons/text_editor/TE_FilesList.gd +++ b/addons/text_editor/TE_FilesList.gd @@ -190,13 +190,16 @@ func url(s:String, url:String) -> String: return "[url=%s]%s[/url]" % [url, s] const FOLDER:String = "🗀" # not visible in godot func _draw_dir(dir:Dictionary, deep:int): + var is_tagging = editor.is_tagging() + var dimmest:float = .65 if is_tagging else 0.0 + var space = clr("┃ ".repeat(deep), Color.white.darkened(.8)) var file:String = dir.file_path var name:String = b(file.get_file()) var head:String = "▼" if dir.open else "▶" var dir_index:int = len(dirs) - var link:String = url(space+FOLDER+head+" "+name, "d:%s" % dir_index) - lines.append(clr(link, Color.white.darkened(.7))) + var link:String = url(space+clr(FOLDER+head, Color.white.darkened(.5))+" "+name, "d:%s" % dir_index) + lines.append(clr(link, Color.white.darkened(dimmest))) dirs.append(dir) var sel = editor.get_selected_tab() @@ -216,31 +219,38 @@ func _draw_dir(dir:Dictionary, deep:int): file = file_path.get_file() var p = file.split(".", true, 1) file = p[0] - var is_selected = file_path == sel var ext = p[1] - match ext: - "cfg", "ini": head = "⚙" # invisible emoji - "json", "yaml": head = "💾" # invisible emoji - _: head = "┣╸" if i != last else "┗╸" + + var is_selected = file_path == sel + var is_opened = editor.is_opened(file_path) + var color = Color.white + head = "┣╸" if i != last else "┗╸" if "readme" in file.to_lower(): head = "🛈" if is_selected: - head = clr(head, Color.white.darkened(.5)) + head = "● " + + elif is_opened: + head = "○ " + + head = clr(head, Color.white.darkened(.5 if is_opened else .75)) + + if is_tagging: + if editor.is_tagged(file_path): +# file = b(file) + pass + + else: + color = color.darkened(dimmest) else: - head = clr(head, Color.white.darkened(.8)) - - var color = Color.white if editor.is_tagged(file_path) else Color.white.darkened(.5) - - if editor.is_selected(file_path): - file = clr(file, color) - elif editor.is_opened(file_path): - file = clr(file, color.darkened(.5)) - else: - file = i(clr(file, color.darkened(.75))) - - ext = clr("." + ext, Color.white.darkened(.75)) + pass +# if is_opened: +# file = b(file) + + file = clr(file, color) + ext = clr("." + ext, Color.white.darkened(.65)) var line = space + head + file + ext lines.append(url(line, "f:%s" % len(files))) files.append(file_path) diff --git a/addons/text_editor/TE_TagsPanel.gd b/addons/text_editor/TE_TagsPanel.gd index 6397196..69707e7 100644 --- a/addons/text_editor/TE_TagsPanel.gd +++ b/addons/text_editor/TE_TagsPanel.gd @@ -8,6 +8,7 @@ var tag_indices:Array = [] # safer to use int in [url=] than str. func _ready(): var _e _e = connect("meta_hover_started", self, "_hovered") + _e = connect("meta_hover_ended", self, "_unhover") _e = connect("meta_clicked", self, "_clicked") _e = editor.connect("symbols_updated", self, "_redraw") _e = editor.connect("tags_updated", self, "_redraw") @@ -17,10 +18,19 @@ func _ready(): add_font_override("italics_font", editor.FONT_I) add_font_override("bold_italics_font", editor.FONT_BI) + # hint + theme = Theme.new() + theme.set_font("font", "TooltipLabel", editor.FONT_R) + call_deferred("_redraw") -func _hovered(_id): - pass +func _hovered(index): + var tag = tag_indices[int(index)] + var count = editor.tag_counts[tag] + hint_tooltip = "%s x%s" % [tag, count] + +func _unhover(t): + hint_tooltip = "" func _clicked(id): var tag = tag_indices[int(id)] @@ -44,11 +54,11 @@ func _redraw(): var count = editor.tag_counts[tag] var enabled = editor.is_tag_enabled(tag) - var x - if count > 1: - x = "[color=#%s][i]%s[/i][/color]%s" % [count_color1 if enabled else count_color2, count, tag] - else: - x = tag + var x = tag +# if count > 1: +# x = "[color=#%s][i]%s[/i][/color]%s" % [count_color1 if enabled else count_color2, count, tag] +# else: +# x = tag var color = editor.color_text var dim = 0.75 diff --git a/addons/text_editor/TE_TextEditor.gd b/addons/text_editor/TE_TextEditor.gd index 5779172..d380253 100644 --- a/addons/text_editor/TE_TextEditor.gd +++ b/addons/text_editor/TE_TextEditor.gd @@ -66,12 +66,12 @@ var color_var:Color = Color.orange var color_varname:Color = Color.white.darkened(.25) onready var test_button:Node = $c/c/c/test -onready var tab_parent:TabContainer = $c/c3/c/c/tab_container +onready var tab_parent:TabContainer = $c/div1/div2/c/tab_container onready var tab_prefab:Node = $file_editor onready var popup:ConfirmationDialog = $popup onready var popup_unsaved:ConfirmationDialog = $popup_unsaved onready var file_dialog:FileDialog = $file_dialog -onready var line_edit:LineEdit = $c/c3/c/c/line_edit +onready var line_edit:LineEdit = $c/div1/div2/c/line_edit onready var menu_file:MenuButton = $c/c/c/file_button onready var menu_view:MenuButton = $c/c/c/view_button var popup_file:PopupMenu @@ -203,10 +203,14 @@ func load_state(): tags_enabled = state.tags_enabled exts_enabled = state.exts_enabled + $c/div1.split_offset = state.div1 + $c/div1/div2.split_offset = state.div2 + emit_signal("state_loaded") func save_state(): var state:Dictionary = { + "save_version": "1", "current": current_directory, "font_size": FONT.size, "tabs": {}, @@ -215,7 +219,10 @@ func save_state(): "tags": tags, "tag_counts": tag_counts, "tags_enabled": tags_enabled, - "exts_enabled": exts_enabled + "exts_enabled": exts_enabled, + + "div1": $c/div1.split_offset, + "div2": $c/div1/div2.split_offset } for tab in get_all_tabs(): state.tabs[tab.file_path] = tab.get_state() @@ -358,13 +365,14 @@ func is_tagged_or_visible(file_tags:Array) -> bool: return true func is_tagged(file_path:String) -> bool: - if not len(tags): - return true var tab = get_tab(file_path) if tab: return is_tagged_or_visible(tab.tags.keys()) return false +func is_tagging() -> bool: + return len(tags) > 0 + func popup_create_file(dir:String="res://"): file_dialog.mode = FileDialog.MODE_SAVE_FILE file_dialog.current_dir = dir @@ -519,6 +527,7 @@ func is_opened(file_path:String) -> bool: func is_selected(file_path:String) -> bool: return get_selected_file() == file_path + func recycle_file(file_path:String): var old_base:String = file_path.substr(len("res://")).get_base_dir() var p = file_path.get_file().split(".", true, 1) diff --git a/addons/text_editor/TextEditor.tscn b/addons/text_editor/TextEditor.tscn index 07f2a67..7743100 100644 --- a/addons/text_editor/TextEditor.tscn +++ b/addons/text_editor/TextEditor.tscn @@ -93,7 +93,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="c3" type="HSplitContainer" parent="c"] +[node name="div1" type="HSplitContainer" parent="c"] margin_top = 34.0 margin_right = 1024.0 margin_bottom = 600.0 @@ -103,14 +103,14 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="c2" type="PanelContainer" parent="c/c3"] +[node name="c2" type="PanelContainer" parent="c/div1"] margin_right = 206.0 margin_bottom = 566.0 rect_min_size = Vector2( 200, 0 ) size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="c" type="Panel" parent="c/c3/c2"] +[node name="c" type="Panel" parent="c/div1/c2"] margin_left = 7.0 margin_top = 7.0 margin_right = 199.0 @@ -118,7 +118,7 @@ margin_bottom = 559.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="list_files" type="RichTextLabel" parent="c/c3/c2/c"] +[node name="list_files" type="RichTextLabel" parent="c/div1/c2/c"] anchor_right = 1.0 anchor_bottom = 1.0 size_flags_horizontal = 3 @@ -163,19 +163,19 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="file_popup" type="PopupMenu" parent="c/c3/c2/c/list_files"] +[node name="file_popup" type="PopupMenu" parent="c/div1/c2/c/list_files"] margin_right = 20.0 margin_bottom = 20.0 custom_fonts/font = ExtResource( 14 ) items = [ "Rename", null, 0, false, false, 0, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Remove", null, 0, false, false, 2, 0, null, "", false ] -[node name="dir_popup" type="PopupMenu" parent="c/c3/c2/c/list_files"] +[node name="dir_popup" type="PopupMenu" parent="c/div1/c2/c/list_files"] margin_right = 20.0 margin_bottom = 20.0 custom_fonts/font = ExtResource( 14 ) -items = [ "Create new file", null, 0, false, false, 0, 0, null, "", false ] +items = [ "New File", null, 0, false, false, 0, 0, null, "", false, "New Folder", null, 0, false, false, 1, 0, null, "", false ] -[node name="c" type="HSplitContainer" parent="c/c3"] +[node name="div2" type="HSplitContainer" parent="c/div1"] margin_left = 218.0 margin_right = 1024.0 margin_bottom = 566.0 @@ -186,20 +186,20 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="c" type="VBoxContainer" parent="c/c3/c"] +[node name="c" type="VBoxContainer" parent="c/div1/div2"] margin_right = 614.0 margin_bottom = 566.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="line_edit" type="LineEdit" parent="c/c3/c/c"] +[node name="line_edit" type="LineEdit" parent="c/div1/div2/c"] visible = false margin_right = 614.0 margin_bottom = 24.0 custom_fonts/font = ExtResource( 12 ) script = ExtResource( 8 ) -[node name="tab_container" type="TabContainer" parent="c/c3/c/c"] +[node name="tab_container" type="TabContainer" parent="c/div1/div2/c"] margin_right = 614.0 margin_bottom = 539.0 size_flags_horizontal = 3 @@ -212,7 +212,7 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="meta" type="RichTextLabel" parent="c/c3/c/c"] +[node name="meta" type="RichTextLabel" parent="c/div1/div2/c"] margin_top = 543.0 margin_right = 614.0 margin_bottom = 566.0 @@ -224,27 +224,27 @@ bbcode_enabled = true fit_content_height = true script = ExtResource( 9 ) -[node name="c2" type="PanelContainer" parent="c/c3/c"] +[node name="c2" type="PanelContainer" parent="c/div1/div2"] margin_left = 626.0 margin_right = 806.0 margin_bottom = 566.0 rect_min_size = Vector2( 100, 0 ) size_flags_vertical = 3 -[node name="c" type="VSplitContainer" parent="c/c3/c/c2"] +[node name="c" type="VSplitContainer" parent="c/div1/div2/c2"] margin_left = 7.0 margin_top = 7.0 margin_right = 173.0 margin_bottom = 559.0 custom_constants/autohide = 0 -[node name="c" type="Panel" parent="c/c3/c/c2/c"] +[node name="c" type="Panel" parent="c/div1/div2/c2/c"] margin_right = 166.0 margin_bottom = 270.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="list_symbols" type="RichTextLabel" parent="c/c3/c/c2/c/c"] +[node name="list_symbols" type="RichTextLabel" parent="c/div1/div2/c2/c/c"] anchor_right = 1.0 anchor_bottom = 1.0 size_flags_vertical = 3 @@ -261,14 +261,14 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="c2" type="Panel" parent="c/c3/c/c2/c"] +[node name="c2" type="Panel" parent="c/div1/div2/c2/c"] margin_top = 282.0 margin_right = 166.0 margin_bottom = 552.0 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="list_tags" type="RichTextLabel" parent="c/c3/c/c2/c/c2"] +[node name="list_tags" type="RichTextLabel" parent="c/div1/div2/c2/c/c2"] anchor_right = 1.0 anchor_bottom = 1.0 size_flags_horizontal = 3 diff --git a/new_file.txt b/new_file.txt index e69de29..1433b14 100644 --- a/new_file.txt +++ b/new_file.txt @@ -0,0 +1,6 @@ +Let's run a test. + + +Okay, who cares aout that? + +Okay, and then what? \ No newline at end of file diff --git a/project.godot b/project.godot index 77b3eb0..76c0569 100644 --- a/project.godot +++ b/project.godot @@ -42,6 +42,10 @@ config/name="TextEdit" run/main_scene="res://addons/text_editor/TextEditor.tscn" config/icon="res://icon.png" +[editor_plugins] + +enabled=PoolStringArray( "res://addons/text_editor/plugin.cfg" ) + [physics] common/enable_pause_aware_picking=true