diff --git a/addons/text_editor/TE_FileEditor.gd b/addons/text_editor/TE_FileEditor.gd index e9b1301..852268d 100644 --- a/addons/text_editor/TE_FileEditor.gd +++ b/addons/text_editor/TE_FileEditor.gd @@ -34,6 +34,7 @@ func _ready(): if get_parent() is TabContainer: get_parent().connect("tab_changed", self, "_tab_changed") + get_parent().connect("tab_selected", self, "_tab_changed") add_font_override("font", editor.FONT) get_menu().add_font_override("font", editor.FONT) @@ -58,6 +59,8 @@ func _scroll_v(v:VScrollBar): func _tab_changed(index:int): var myindex = get_index() if index == myindex and visible: + grab_focus() + grab_click_focus() yield(get_tree(), "idle_frame") set_h_scroll(hscroll) set_v_scroll(vscroll) @@ -87,16 +90,27 @@ func _input(e): if not visible or not in_focus: return - # save files if e is InputEventKey and e.pressed and e.control: - if e.scancode == KEY_S: - if modified: - get_tree().set_input_as_handled() - editor.save_files() - - if e.scancode == KEY_W and not e.shift: + # tab to next + if e.scancode == KEY_TAB: get_tree().set_input_as_handled() - close() + if e.shift: + get_parent().prev() + else: + get_parent().next() + + # save files + elif e.scancode == KEY_S: + get_tree().set_input_as_handled() + editor.save_files() + + # close file + elif e.scancode == KEY_W: + get_tree().set_input_as_handled() + if e.shift: + editor.open_last_file() + else: + close() # remember last selection if e is InputEventKey and e.pressed: diff --git a/addons/text_editor/FileTabs.gd b/addons/text_editor/TE_FileTabs.gd similarity index 100% rename from addons/text_editor/FileTabs.gd rename to addons/text_editor/TE_FileTabs.gd diff --git a/addons/text_editor/TE_FilesList.gd b/addons/text_editor/TE_FilesList.gd index e1ce542..aedd602 100644 --- a/addons/text_editor/TE_FilesList.gd +++ b/addons/text_editor/TE_FilesList.gd @@ -239,15 +239,12 @@ func _draw_dir(dir:Dictionary, deep:int): if is_tagging: if editor.is_tagged(file_path): -# file = b(file) - pass + file = b(file) else: color = color.darkened(dimmest) else: pass -# if is_opened: -# file = b(file) file = clr(file, color) ext = clr("." + ext, Color.white.darkened(.65)) diff --git a/addons/text_editor/line_edit.gd b/addons/text_editor/TE_LineEdit.gd similarity index 100% rename from addons/text_editor/line_edit.gd rename to addons/text_editor/TE_LineEdit.gd diff --git a/addons/text_editor/MetaInfo.gd b/addons/text_editor/TE_MetaInfo.gd similarity index 100% rename from addons/text_editor/MetaInfo.gd rename to addons/text_editor/TE_MetaInfo.gd diff --git a/addons/text_editor/TE_TabScroller.gd b/addons/text_editor/TE_TabScroller.gd new file mode 100644 index 0000000..525a3f2 --- /dev/null +++ b/addons/text_editor/TE_TabScroller.gd @@ -0,0 +1,31 @@ +tool +extends TabContainer + +onready var editor:TextEditor = owner + +var mouse_over:bool = false + +func _ready(): + var _e + _e = connect("mouse_entered", self, "set", ["mouse_over", true]) + _e = connect("mouse_exited", self, "set", ["mouse_over", false]) + +func _input(e): + if mouse_over and e is InputEventMouseButton and e.pressed: + if e.button_index == BUTTON_WHEEL_DOWN: + prev() + get_tree().set_input_as_handled() + + elif e.button_index == BUTTON_WHEEL_UP: + next() + get_tree().set_input_as_handled() + +# if not editor.is_plugin_active(): +# return + +func prev(): + set_current_tab(wrapi(current_tab - 1, 0, get_child_count())) + +func next(): + set_current_tab(wrapi(current_tab + 1, 0, get_child_count())) + diff --git a/addons/text_editor/TE_TextEditor.gd b/addons/text_editor/TE_TextEditor.gd index a1352c0..8a32a28 100644 --- a/addons/text_editor/TE_TextEditor.gd +++ b/addons/text_editor/TE_TextEditor.gd @@ -352,7 +352,7 @@ func _selected_file_changed(file_path:String): emit_signal("file_selected", last_selected_file) func is_tag_enabled(tag:String) -> bool: - return tags_enabled[tag] + return tags_enabled.get(tag, false) func enable_tag(tag:String, enabled:bool=true): tags_enabled[tag] = enabled @@ -611,6 +611,7 @@ func set_directory(path:String=current_directory): func _file_symbols_updated(file_path:String): var tg = get_tab(file_path).tags + tags_enabled.clear() for tag in tg: if not tag in tags_enabled: tags_enabled[tag] = false diff --git a/addons/text_editor/TextEditor.tscn b/addons/text_editor/TextEditor.tscn index 7743100..874df94 100644 --- a/addons/text_editor/TextEditor.tscn +++ b/addons/text_editor/TextEditor.tscn @@ -1,14 +1,13 @@ [gd_scene load_steps=16 format=2] -[ext_resource path="res://addons/text_editor/file_buttons.gd" type="Script" id=1] [ext_resource path="res://addons/text_editor/TE_TextEditor.gd" type="Script" id=2] [ext_resource path="res://addons/text_editor/TE_FilesList.gd" type="Script" id=3] [ext_resource path="res://addons/text_editor/TE_FileEditor.gd" type="Script" id=4] [ext_resource path="res://addons/text_editor/TE_SymbolsList.gd" type="Script" id=5] -[ext_resource path="res://addons/text_editor/FileTabs.gd" type="Script" id=6] +[ext_resource path="res://addons/text_editor/TE_FileTabs.gd" type="Script" id=6] [ext_resource path="res://addons/text_editor/TE_TagsPanel.gd" type="Script" id=7] -[ext_resource path="res://addons/text_editor/line_edit.gd" type="Script" id=8] -[ext_resource path="res://addons/text_editor/MetaInfo.gd" type="Script" id=9] +[ext_resource path="res://addons/text_editor/TE_LineEdit.gd" type="Script" id=8] +[ext_resource path="res://addons/text_editor/TE_MetaInfo.gd" type="Script" id=9] [ext_resource path="res://addons/text_editor/fonts/font_i.tres" type="DynamicFont" id=10] [ext_resource path="res://addons/text_editor/fonts/font_b.tres" type="DynamicFont" id=11] [ext_resource path="res://addons/text_editor/fonts/font_r.tres" type="DynamicFont" id=12] @@ -18,6 +17,9 @@ [sub_resource type="Theme" id=1] TooltipLabel/fonts/font = ExtResource( 12 ) +[sub_resource type="Theme" id=2] +TooltipLabel/fonts/font = ExtResource( 12 ) + [node name="text_editor" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -65,16 +67,15 @@ margin_left = 7.0 margin_top = 7.0 margin_right = 1017.0 margin_bottom = 27.0 -script = ExtResource( 1 ) [node name="test" type="Button" parent="c/c/c"] -margin_right = 56.0 +margin_right = 12.0 margin_bottom = 20.0 -text = "update" +text = "⟳" [node name="file_button" type="MenuButton" parent="c/c/c"] -margin_left = 60.0 -margin_right = 92.0 +margin_left = 16.0 +margin_right = 48.0 margin_bottom = 20.0 text = "file" items = [ "New File", null, 0, false, false, 0, 0, null, "", false, "Extensions", null, 0, false, false, 1, 0, null, "Extensions", false, "New File", null, 0, false, false, 2, 0, null, "", false, "Extensions", null, 0, false, false, 3, 0, null, "Extensions", false ] @@ -83,8 +84,8 @@ __meta__ = { } [node name="view_button" type="MenuButton" parent="c/c/c"] -margin_left = 96.0 -margin_right = 137.0 +margin_left = 52.0 +margin_right = 93.0 margin_bottom = 20.0 focus_mode = 2 text = "view" @@ -273,6 +274,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 size_flags_horizontal = 3 size_flags_vertical = 3 +theme = SubResource( 2 ) custom_fonts/bold_italics_font = ExtResource( 13 ) custom_fonts/italics_font = ExtResource( 10 ) custom_fonts/bold_font = ExtResource( 11 ) diff --git a/addons/text_editor/file_buttons.gd b/addons/text_editor/file_buttons.gd deleted file mode 100644 index 1eccaec..0000000 --- a/addons/text_editor/file_buttons.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends Node - - -# Declare member variables here. Examples: -# var a = 2 -# var b = "text" - - -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -#func _process(delta): -# pass diff --git a/addons/text_editor/tab_scroll.gd b/addons/text_editor/tab_scroll.gd deleted file mode 100644 index d0832e5..0000000 --- a/addons/text_editor/tab_scroll.gd +++ /dev/null @@ -1,36 +0,0 @@ -tool -extends TabContainer - -onready var editor:TextEditor = owner - -var mouse:bool = false - -func _ready(): - var _e - _e = connect("mouse_entered", self, "set", ["mouse", true]) - _e = connect("mouse_exited", self, "set", ["mouse", false]) - -func _input(e): - if not editor.is_plugin_active(): - return - - if mouse and e is InputEventMouseButton and e.pressed: - if e.button_index == BUTTON_WHEEL_DOWN: - prev() - get_tree().set_input_as_handled() - - elif e.button_index == BUTTON_WHEEL_UP: - next() - get_tree().set_input_as_handled() - - if e is InputEventKey and e.pressed and e.control and e.scancode == KEY_TAB: - if e.shift: - prev() - get_tree().set_input_as_handled() - else: - next() - get_tree().set_input_as_handled() - -func prev(): current_tab = wrapi(current_tab - 1, 0, get_child_count()) -func next(): current_tab = wrapi(current_tab + 1, 0, get_child_count()) -