mirror of
https://github.com/Relintai/Godot-TextEditor.git
synced 2025-04-09 11:52:37 +02:00
1.12
This commit is contained in:
parent
4225903a92
commit
25d4f161cf
@ -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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Text Editor
|
||||
Version `1.11`
|
||||
Version `1.12`
|
||||
|
||||

|
||||
|
||||
@ -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: `` in Markdown.
|
||||
Images look like: `` in Markdown.
|
||||
|
||||
# Icon credit
|
||||
<a href="https://www.flaticon.com/free-icons/files-and-folders" title="files and folders icons">Files and folders icons created by Uniconlabs - Flaticon</a>
|
BIN
README/icon.png
Normal file
BIN
README/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@ -788,6 +788,9 @@ func get_selected_file() -> 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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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 ""
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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():
|
||||
|
@ -3,5 +3,5 @@
|
||||
name="TextEditor"
|
||||
description="A text editor for Godot."
|
||||
author="teebar"
|
||||
version="1.11"
|
||||
version="1.12"
|
||||
script="plugin.gd"
|
||||
|
3
default_bus_layout.tres
Normal file
3
default_bus_layout.tres
Normal file
@ -0,0 +1,3 @@
|
||||
[gd_resource type="AudioBusLayout" format=2]
|
||||
|
||||
[resource]
|
Loading…
Reference in New Issue
Block a user