From 25d4f161cf11a9dc6441354e20f14b3d2d171464 Mon Sep 17 00:00:00 2001 From: teebarjunk Date: Thu, 3 Feb 2022 07:34:34 -0500 Subject: [PATCH] 1.12 --- CHANGES.md | 9 +++ README.md | 7 ++- README/icon.png | Bin 0 -> 1742 bytes addons/text_editor/TE_Editor.gd | 3 + addons/text_editor/TE_FileEditor.gd | 18 +++++- addons/text_editor/TE_FileTabs.gd | 93 ++++++++++++++++++++-------- addons/text_editor/TE_FilesList.gd | 1 - addons/text_editor/TE_MetaTabs.gd | 1 + addons/text_editor/TextEditor.tscn | 8 ++- addons/text_editor/ext/ext_yaml.gd | 3 + addons/text_editor/plugin.cfg | 2 +- default_bus_layout.tres | 3 + 12 files changed, 114 insertions(+), 34 deletions(-) create mode 100644 README/icon.png create mode 100644 default_bus_layout.tres diff --git a/CHANGES.md b/CHANGES.md index 3f7e311..17e1ed7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,12 @@ +# 1.12 +- Changed icon. +- Added tabs popup menu: + - Options for closing many tabs. + - Options for selecting tabs. +- Console is hidden on start. +- Fixed `yaml` tabs not working. +- Fixed `tab` + `shift + tab`ing when multiple lines are selected. + # 1.11 - Toggled `Low Processor Mode` to keep cpu/gpu usage down. - Simplified *File List* filter display. diff --git a/README.md b/README.md index d60d00f..3443c00 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Text Editor -Version `1.11` +Version `1.12` ![](README/readme_preview.png) @@ -147,4 +147,7 @@ Select a column to sort on: ### Image In Markdown files (`.md`) you can `ctrl + click` an image to preview it. -Images look like: `![](image_url.png)` in Markdown. \ No newline at end of file +Images look like: `![](image_url.png)` in Markdown. + +# Icon credit +Files and folders icons created by Uniconlabs - Flaticon \ No newline at end of file diff --git a/README/icon.png b/README/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7732afdb0b18218338a45b49c58502f4602825b0 GIT binary patch literal 1742 zcmaJ?do&wn6#tSYDqbOo$A}`uRu#oMO45kTqw}tk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hv+H+Os&eCql?Fe}MZ!xfR$hfhM zeyPyii0Nm=;=}T{`wj>y@=6Y(oM)Ukz6z3%J^5qw)b!GwoWSS-O-I6IWIZ2Nprl+x zL8+)B07xdN8xLZJ@N)K86$r@y!L<7ftRzsq-tG?~I|>g`iKq8SNp5S}%4^gFOsYlX%3pt%OMQT<9W3G{9BrT4MM^@5k{#EyK^CmB#W_4B z*xKjx02b=n6MogAYUn6Cw1|gN$fn~_2=VN5AGBIIJG-RDMJ-!!dlg%OWTmIHk9OQt zJUe4W+u2GQeN~awyGPX|e)yOb1Q2bt$%$Iyj?J3Q8_U7JZ2wFdz9H}}L{W=R^dnhA zhRIoi(}3v>{C5}j*Xx}3_diuQ@M?ow|FNV@XK zoI_X%3xZNYZie+gNgkk@KRNUEele@TPps-M>qb7 String: var node = get_selected_tab() return node.file_path if node else "" +func get_tabs() -> Array: + return tab_parent.get_children() + func get_tab(file_path:String) -> TextEdit: for child in tab_parent.get_children(): if child is TextEdit and child.file_path == file_path: diff --git a/addons/text_editor/TE_FileEditor.gd b/addons/text_editor/TE_FileEditor.gd index 9bceaae..7208ae3 100644 --- a/addons/text_editor/TE_FileEditor.gd +++ b/addons/text_editor/TE_FileEditor.gd @@ -218,7 +218,22 @@ func _input(e): # custom tab system if visible and in_focus and e is InputEventKey and e.pressed and e.scancode == KEY_TAB: - insert_text_at_cursor(helper.get_tab()) + if is_selection_active(): + var a = get_selection_from_line() + var b = get_selection_to_line() + var lines = get_selection_text().split("\n") + if e.shift: + for i in len(lines): + lines[i] = lines[i].trim_prefix(helper.get_tab()) + else: + for i in len(lines): + lines[i] = helper.get_tab() + lines[i] + insert_text_at_cursor(lines.join("\n")) + select(a, 0, b, len(get_line(b))) + + else: + insert_text_at_cursor(helper.get_tab()) + get_tree().set_input_as_handled() if not visible or not in_focus or not mouse_inside: @@ -487,6 +502,7 @@ func update_name(): editor.tab_parent.set_tab_icon(get_index(), null) editor.tab_parent.set_tab_title(get_index(), n) + name = n func update_heading(): if Engine.editor_hint: diff --git a/addons/text_editor/TE_FileTabs.gd b/addons/text_editor/TE_FileTabs.gd index 45d426e..3adb21d 100644 --- a/addons/text_editor/TE_FileTabs.gd +++ b/addons/text_editor/TE_FileTabs.gd @@ -3,6 +3,7 @@ extends TabContainer onready var editor:TE_Editor = owner var mouse:bool = false var last_tab_index:int = -1 +var tab_menu:PopupMenu func _ready(): if not editor.is_plugin_active(): @@ -12,40 +13,70 @@ func _ready(): _e = connect("mouse_entered", self, "set", ["mouse", true]) _e = connect("mouse_exited", self, "set", ["mouse", false]) _e = connect("tab_changed", self, "_tab_changed") + _e = connect("pre_popup_pressed", self, "update_popup") add_font_override("font", editor.FONT_R) + + tab_menu = owner.get_node("popup_tab_menu") + tab_menu.connect("index_pressed", self, "_popup_selected") func _tab_changed(index): - var tab - var data - -# if last_tab_index >= 0 and last_tab_index < get_child_count(): -# tab = get_child(last_tab_index) -# data = editor.get_file_data(tab.file_path) -# data.hscroll = tab.hscroll -# data.vscroll = tab.vscroll -# data.cursor = tab.get_cursor_state() -# prints("SAVED", tab.file_path, tab.cursor_state) -# -# yield(get_tree(), "idle_frame") -# -# tab = get_child(index) -# data = editor.get_file_data(tab.file_path) -# if "cursor" in data: -# print("LOADED", data.cursor) -# tab.set_cursor_state(data.cursor) -# tab.set_h_scroll(data.hscroll) -# tab.set_v_scroll(data.vscroll) - - tab = get_child(index) -# var s = tab.get_cursor_state() + var tab = get_child(index) tab.grab_focus() -# tab.grab_click_focus() -# yield(get_tree(), "idle_frame") -# tab.set_cursor_state(s) last_tab_index = index -# prints(tab, tab.file_path) + +func _popup_selected(index:int): + var tindex := tab_menu.get_item_id(index) + if tindex >= 100: + current_tab = tindex - 100 + return + + match tindex: + 0: # close + get_child(hovered_tab_index).close() + + 1: # close others + var all_tabs = owner.get_tabs() + var hovered = get_child(hovered_tab_index) + for tab in all_tabs: + if tab != hovered: + tab.close() + + 2: # close left + var all_tabs = owner.get_tabs() + for i in range(0, hovered_tab_index): + all_tabs[i].close() + current_tab = 0 + + 3: # close right + var all_tabs = owner.get_tabs() + for i in range(hovered_tab_index+1, len(all_tabs)): + all_tabs[i].close() + +var hovered_tab_index:int +func update_popup(index:int=current_tab): + var all_tabs = owner.get_tabs() + + hovered_tab_index = index + + tab_menu.clear() + tab_menu.rect_size = Vector2.ZERO + tab_menu.add_item("Close", 0) + tab_menu.add_item("Close others", 1) + + if index > 0: + tab_menu.add_item("Close all to left", 2) + + if index < len(all_tabs)-1: + tab_menu.add_item("Close all to right", 3) + + tab_menu.add_separator() + + var i = 0 + for tab in owner.get_tabs(): + tab_menu.add_item(tab.name, 100+i) + i += 1 func _input(e): if not editor.is_plugin_active(): @@ -59,6 +90,14 @@ func _input(e): elif e.button_index == BUTTON_WHEEL_UP: next() get_tree().set_input_as_handled() + + elif e.button_index == BUTTON_RIGHT: + var index := get_tab_idx_at_point(get_local_mouse_position()) + if index != -1: + update_popup(index) + tab_menu.rect_global_position = get_global_mouse_position() + tab_menu.popup() + get_tree().set_input_as_handled() if e is InputEventKey and e.pressed and e.control and e.scancode == KEY_TAB: if e.shift: diff --git a/addons/text_editor/TE_FilesList.gd b/addons/text_editor/TE_FilesList.gd index 5bc84b6..1a5983e 100644 --- a/addons/text_editor/TE_FilesList.gd +++ b/addons/text_editor/TE_FilesList.gd @@ -262,7 +262,6 @@ func _draw_dir(dir:Dictionary, deep:int) -> Array: link += " " + meta(clr("⬅", Color.yellowgreen), ["unrecycle", dir], file) var out = [] - var sel = editor.get_selected_tab() sel = sel.file_path if sel else "" diff --git a/addons/text_editor/TE_MetaTabs.gd b/addons/text_editor/TE_MetaTabs.gd index 8a4cd5f..362776f 100644 --- a/addons/text_editor/TE_MetaTabs.gd +++ b/addons/text_editor/TE_MetaTabs.gd @@ -7,6 +7,7 @@ func _ready(): if not editor.is_plugin_active(): return + set_visible(false) add_font_override("font", editor.FONT_R) func _unhandled_key_input(e): diff --git a/addons/text_editor/TextEditor.tscn b/addons/text_editor/TextEditor.tscn index ec455d7..0beea84 100644 --- a/addons/text_editor/TextEditor.tscn +++ b/addons/text_editor/TextEditor.tscn @@ -172,7 +172,7 @@ margin_top = 3.0 margin_right = 1010.0 margin_bottom = 20.0 custom_fonts/font = ExtResource( 12 ) -text = "v1.11" +text = "v1.12" align = 2 [node name="div1" type="HSplitContainer" parent="c"] @@ -212,7 +212,7 @@ margin_right = 192.0 margin_bottom = 27.0 custom_fonts/font = ExtResource( 12 ) clear_button_enabled = true -placeholder_text = "File Filter" +placeholder_text = "Filter" [node name="list_files" type="RichTextLabel" parent="c/div1/c2/c/c"] margin_top = 31.0 @@ -626,3 +626,7 @@ current_path = "res://test_files/" __meta__ = { "_edit_use_anchors_": false } + +[node name="popup_tab_menu" type="PopupMenu" parent="."] +margin_right = 124.0 +margin_bottom = 112.0 diff --git a/addons/text_editor/ext/ext_yaml.gd b/addons/text_editor/ext/ext_yaml.gd index 2452bdc..e935f6e 100644 --- a/addons/text_editor/ext/ext_yaml.gd +++ b/addons/text_editor/ext/ext_yaml.gd @@ -1,6 +1,9 @@ tool extends TE_ExtensionHelper +func get_tab() -> String: + return " " + func _is_commented(lines) -> bool: for i in len(lines): if not lines[i].strip_edges(): diff --git a/addons/text_editor/plugin.cfg b/addons/text_editor/plugin.cfg index c98bba0..846f32c 100644 --- a/addons/text_editor/plugin.cfg +++ b/addons/text_editor/plugin.cfg @@ -3,5 +3,5 @@ name="TextEditor" description="A text editor for Godot." author="teebar" -version="1.11" +version="1.12" script="plugin.gd" diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..eb4accc --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,3 @@ +[gd_resource type="AudioBusLayout" format=2] + +[resource]