This commit is contained in:
teebarjunk 2021-11-20 08:53:02 -05:00
parent baeeb0a808
commit 498fb79e89
9 changed files with 149 additions and 45 deletions

View File

@ -1,3 +1,13 @@
# 1.8
- Added filter to symbols list.
- Added filter to file list.
- Added `.md` highlighting for `{}`. (Not official Markdown.)
- Fixed unsaved files asking for a save path if no text entered.
- Fixed file wiping if hitting undo after loading a file.
- Fixed *no word_skip_list.txt* error.
- Folders colorized in file list.
- Display version at top right.
# 1.7
- Added option to view `Extensionless` files.
- Added Symbol path heirarchy to hint popup so you know where you are in big files:

View File

@ -1,5 +1,5 @@
# Text Editor
Version `1.7`
Version `1.8`
![](README/readme_preview.png)

View File

@ -67,6 +67,12 @@ func _ready():
# hint
theme = Theme.new()
theme.set_font("font", "TooltipLabel", editor.FONT_R)
# var sb = StyleBoxFlat.new()
# sb.bg_color.a = .75
# theme.set_color("font_color", "TooltipLabel", Color(0,0,0,.5))
# theme.set_stylebox("panel", "TooltipPanel", sb)
# print(theme.get_color_list("TooltipLabel"))
# print(theme.get_color_types())
TE_Util.dig(self, self, "_node")
@ -309,7 +315,6 @@ func _file_selected(p:String):
grab_focus()
grab_click_focus()
func goto_line(line:int):
# force scroll to bottom so selected line will be at top
@ -389,6 +394,7 @@ func load_file(path:String):
file_path = path
if path != "":
text = editor.load_file(path)
clear_undo_history()
update_colors()
update_name()
@ -404,7 +410,7 @@ func _created_nonexisting(fp:String):
update_symbols()
func save_file():
if file_path == "":
if file_path == "" and text:
editor.popup_create_file(editor.current_directory, text, funcref(self, "_created_nonexisting"))
else:
@ -424,7 +430,7 @@ func update_name():
var n:String
if file_path == "":
n = "*UNSAVED"
n = "UNSAVED"
else:
n = file_path.get_file().split(".", true, 1)[0]
@ -453,5 +459,5 @@ func update_heading():
OS.set_window_title("%s - Text Editor" % f)
func needs_save() -> bool:
return modified or not File.new().file_exists(file_path)
return modified or (not File.new().file_exists(file_path) and text)

View File

@ -7,6 +7,8 @@ onready var dir_popup:PopupMenu = $dir_popup
const DragLabel = preload("res://addons/text_editor/TE_DragLabel.gd")
var drag_label:RichTextLabel
export var p_filter:NodePath
var filter:String = ""
var selected:Array = []
var dragging:Array = []
var drag_start:Vector2
@ -20,6 +22,10 @@ func _ready():
_e = editor.connect("file_selected", self, "_file_selected")
_e = editor.connect("file_renamed", self, "_file_renamed")
var le:LineEdit = get_node(p_filter)
_e = le.connect("text_changed", self, "_filter_changed")
le.add_font_override("font", editor.FONT_R)
# file popup
file_popup.clear()
file_popup.rect_size = Vector2.ZERO
@ -49,6 +55,10 @@ func _ready():
add_font_override("italics_font", editor.FONT_I)
add_font_override("bold_italics_font", editor.FONT_BI)
func _filter_changed(t:String):
filter = t
_redraw()
func _dir_popup(index:int):
var type = selected[0]
var file = selected[1]
@ -199,7 +209,7 @@ func _draw_dir(dir:Dictionary, deep:int):
var space = clr("".repeat(deep), Color.white.darkened(.8))
var file:String = dir.file_path
var head:String = "" if dir.open else ""
head = clr(space+FOLDER+head, Color.white.darkened(.5))
head = clr(space+FOLDER, Color.gold) + clr(head, Color.white.darkened(.5))
head += " " + b(file.get_file())
var link:String = meta(head, ["d", dir], editor.get_localized_path(file))
if editor.is_trash_path(file):
@ -230,14 +240,13 @@ func _draw_dir(dir:Dictionary, deep:int):
var color = dir.tint
head = "┣╸" if i != last else "┗╸"
if "readme" in file.to_lower():
head = "🛈"
var fname_lower = file.to_lower()
# if is_selected or is_opened:
# head = "● "
#
# elif is_opened:
# head = "○ "
if filter and not filter in fname_lower:
continue
if "readme" in fname_lower:
head = "🛈"
head = clr(head, Color.white.darkened(.5 if is_opened else .75))

View File

@ -18,7 +18,10 @@ func _update():
# load block list
var skip_list = editor.current_directory.plus_file("word_skip_list.txt")
skip_words = TE_Util.load_text(skip_list).replace("\n", " ").strip_edges().to_lower().split(" ")
if File.new().file_exists(skip_list):
skip_words = TE_Util.load_text(skip_list).replace("\n", " ").strip_edges().to_lower().split(" ")
else:
skip_words = PoolStringArray()
for path in editor.file_paths:
var file = path.get_file()

View File

@ -5,6 +5,9 @@ var hscrolls:Dictionary = {}
var selected_line:int = 0
var current_file:String = ""
var filter:String = ""
export var p_filter:NodePath
func _ready():
var _e
_e = editor.connect("symbols_updated", self, "_redraw")
@ -15,6 +18,10 @@ func _ready():
_e = editor.connect("selected_symbol_line", self, "_selected_symbol_line")
_e = get_v_scroll().connect("value_changed", self, "_scrolling")
var le:LineEdit = get_node(p_filter)
_e = le.connect("text_changed", self, "_filter_changed")
le.add_font_override("font", editor.FONT_R)
add_font_override("normal_font", editor.FONT_R)
add_font_override("bold_font", editor.FONT_B)
add_font_override("italics_font", editor.FONT_I)
@ -22,6 +29,10 @@ func _ready():
call_deferred("_redraw")
func _filter_changed(t:String):
filter = t.to_lower()
_redraw()
func _selected_symbol_line(line:int):
selected_line = clamp(line, 0, get_line_count())
scroll_to_line(clamp(line-1, 0, get_line_count()-1))
@ -100,11 +111,15 @@ func _redraw():
i += 1
if line_index == -1:
continue # special file chapter
var symbol_info = symbols[line_index]
var deep = symbol_info.deep
var space = "" if not deep else clr("-".repeat(deep), Color.white.darkened(.75))
var cl = Color.white
if filter and not filter in symbol_info.name.to_lower():
continue
if deep == 0:
cl = editor.color_symbol
if symbol_info.name.begins_with("*") and symbol_info.name.ends_with("*"):

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=2]
[gd_scene load_steps=26 format=2]
[ext_resource path="res://addons/text_editor/TE_Console.gd" type="Script" id=1]
[ext_resource path="res://addons/text_editor/TE_Editor.gd" type="Script" id=2]
@ -18,25 +18,27 @@
[ext_resource path="res://addons/text_editor/TE_MetaTabs.gd" type="Script" id=16]
[ext_resource path="res://addons/text_editor/TE_ScriptInfo.gd" type="Script" id=17]
[sub_resource type="Theme" id=1]
[sub_resource type="Theme" id=8]
[sub_resource type="Theme" id=9]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=2]
[sub_resource type="Theme" id=10]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=3]
[sub_resource type="Theme" id=11]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=4]
[sub_resource type="Theme" id=12]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=5]
[sub_resource type="Theme" id=13]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=6]
[sub_resource type="Theme" id=14]
TooltipLabel/fonts/font = ExtResource( 12 )
[sub_resource type="Theme" id=7]
[sub_resource type="Theme" id=15]
TooltipLabel/fonts/font = ExtResource( 12 )
[node name="editor" type="Control"]
@ -59,6 +61,7 @@ margin_right = 214.0
margin_bottom = 30.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 8 )
custom_fonts/font = ExtResource( 14 )
highlight_current_line = true
syntax_highlighting = true
@ -119,6 +122,17 @@ margin_right = 155.0
margin_bottom = 24.0
text = "wrap"
[node name="version" type="Label" parent="c/c/c"]
modulate = Color( 1, 1, 1, 0.521569 )
margin_left = 159.0
margin_top = 3.0
margin_right = 1010.0
margin_bottom = 20.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 12 )
text = "v1.8"
align = 2
[node name="div1" type="HSplitContainer" parent="c"]
margin_top = 38.0
margin_right = 1024.0
@ -144,12 +158,25 @@ margin_bottom = 555.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="list_files" type="RichTextLabel" parent="c/div1/c2/c"]
[node name="c" type="VBoxContainer" parent="c/div1/c2/c"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="filter" type="LineEdit" parent="c/div1/c2/c/c"]
margin_right = 192.0
margin_bottom = 24.0
clear_button_enabled = true
[node name="list_files" type="RichTextLabel" parent="c/div1/c2/c/c"]
margin_top = 28.0
margin_right = 192.0
margin_bottom = 548.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 1 )
theme = SubResource( 9 )
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
custom_fonts/bold_font = ExtResource( 11 )
@ -160,18 +187,19 @@ script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
p_filter = NodePath("../filter")
[node name="file_popup" type="PopupMenu" parent="c/div1/c2/c/list_files"]
[node name="file_popup" type="PopupMenu" parent="c/div1/c2/c/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/div1/c2/c/list_files"]
[node name="dir_popup" type="PopupMenu" parent="c/div1/c2/c/c/list_files"]
margin_right = 20.0
margin_bottom = 20.0
custom_fonts/font = ExtResource( 14 )
items = [ "New File", 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 ]
items = [ "New File", 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, "", null, 0, false, false, -1, 0, null, "", true, "Tint Yellow", null, 0, false, false, 4, 0, null, "", false, "Tint Red", null, 0, false, false, 5, 0, null, "", false, "Tint Blue", null, 0, false, false, 6, 0, null, "", false, "Tint Green", null, 0, false, false, 7, 0, null, "", false, "Reset Tint", null, 0, false, false, 8, 0, null, "", false ]
[node name="div2" type="HSplitContainer" parent="c/div1"]
margin_left = 218.0
@ -206,7 +234,7 @@ split_offset = -200
[node name="tab_container" type="TabContainer" parent="c/div1/div2/c/c"]
margin_right = 614.0
margin_bottom = 283.0
margin_bottom = 562.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = ExtResource( 12 )
@ -218,13 +246,13 @@ __meta__ = {
}
[node name="meta_tabs" type="TabContainer" parent="c/div1/div2/c/c"]
margin_top = 295.0
visible = false
margin_top = 326.0
margin_right = 614.0
margin_bottom = 562.0
script = ExtResource( 16 )
[node name="console" type="RichTextLabel" parent="c/div1/div2/c/c/meta_tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
@ -233,7 +261,7 @@ margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 2 )
theme = SubResource( 10 )
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
custom_fonts/bold_font = ExtResource( 11 )
@ -242,6 +270,9 @@ bbcode_enabled = true
meta_underlined = false
text = "active: False
active: False
active: False
active: False
active: False
"
script = ExtResource( 1 )
@ -255,7 +286,7 @@ margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 3 )
theme = SubResource( 11 )
custom_constants/table_hseparation = 16
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
@ -265,6 +296,7 @@ bbcode_enabled = true
script = ExtResource( 9 )
[node name="search" type="VBoxContainer" parent="c/div1/div2/c/c/meta_tabs"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
@ -288,6 +320,7 @@ custom_fonts/font = ExtResource( 12 )
margin_left = 427.0
margin_right = 501.0
margin_bottom = 27.0
custom_fonts/font = ExtResource( 12 )
pressed = true
text = "all files"
@ -295,6 +328,7 @@ text = "all files"
margin_left = 505.0
margin_right = 606.0
margin_bottom = 27.0
custom_fonts/font = ExtResource( 12 )
text = "match case"
[node name="rte" type="RichTextLabel" parent="c/div1/div2/c/c/meta_tabs/search"]
@ -303,7 +337,7 @@ margin_right = 606.0
margin_bottom = 231.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 4 )
theme = SubResource( 12 )
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
custom_fonts/bold_font = ExtResource( 11 )
@ -334,7 +368,7 @@ margin_right = 606.0
margin_bottom = 232.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 5 )
theme = SubResource( 13 )
custom_constants/table_hseparation = 101
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
@ -366,11 +400,26 @@ margin_bottom = 448.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="list_symbols" type="RichTextLabel" parent="c/div1/div2/c2/c/c"]
[node name="c" type="VBoxContainer" parent="c/div1/div2/c2/c/c"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 6 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="filter" type="LineEdit" parent="c/div1/div2/c2/c/c/c"]
margin_right = 166.0
margin_bottom = 24.0
clear_button_enabled = true
[node name="list_symbols" type="RichTextLabel" parent="c/div1/div2/c2/c/c/c"]
margin_top = 28.0
margin_right = 166.0
margin_bottom = 448.0
size_flags_vertical = 3
theme = SubResource( 14 )
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
custom_fonts/bold_font = ExtResource( 11 )
@ -383,6 +432,7 @@ script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
p_filter = NodePath("../filter")
[node name="c2" type="Panel" parent="c/div1/div2/c2/c"]
margin_top = 460.0
@ -396,7 +446,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 7 )
theme = SubResource( 15 )
custom_fonts/bold_italics_font = ExtResource( 13 )
custom_fonts/italics_font = ExtResource( 10 )
custom_fonts/bold_font = ExtResource( 11 )

View File

@ -124,8 +124,10 @@ func toggle_comment(t:TextEdit, head:String="<!-- ", tail:String=" -->"):
func apply_colors(e:TE_Editor, t:TextEdit):
.apply_colors(e, t)
var code:Color = TE_Util.hue_shift(e.color_var, .33)#.darkened(.25)
var quote:Color = lerp(e.color_text, e.color_symbol, .5)
t.add_color_override("function_color", e.color_text)
# t.add_color_override("background_color", e.color_background)
t.add_keyword_color("true", e.color_var)
t.add_keyword_color("false", e.color_var)
@ -138,11 +140,23 @@ func apply_colors(e:TE_Editor, t:TextEdit):
t.add_color_region("*", "*", Color.tomato.lightened(.3), false)
# quote
t.add_color_region("> ", "", lerp(e.color_text, e.color_symbol, .5), true)
t.add_color_region("> ", "", quote, true)
# comment
t.add_color_region("<!--", "-->", e.color_comment, false)
# non official markdown:
# formatted
t.add_color_region("{", "}", lerp(e.color_text, e.color_var, .5).darkened(.25), false)
if false:
# quote
t.add_color_region('"', '"', quote, false)
# brackets
t.add_color_region('(', ')', quote, false)
else:
# url links
t.add_color_region("![", ")", e.color_var.lightened(.5))
# headings
var head = e.color_symbol
var tint1 = TE_Util.hue_shift(head, -.33)
@ -153,16 +167,11 @@ func apply_colors(e:TE_Editor, t:TextEdit):
t.add_color_region("%s \"" % h, "\"", tint2, true)
t.add_color_region("%s " % h, "*", head, true)
# url links
# t.add_color_region("[]", ")", e.color_var.lightened(.5))
t.add_color_region("![", ")", e.color_var.lightened(.5))
# lists
t.add_color_region("- [x", "]", Color.yellowgreen, false)
t.add_color_region("- [", " ]", e.color_text.darkened(.6), false)
# code blocks
var code:Color = TE_Util.hue_shift(e.color_var, .33)#.darkened(.25)
t.add_color_region("```", "```", code, false)
t.add_color_region("~~~", "~~~", code, false)
t.add_color_region("---", "---", code, false)
@ -178,6 +187,8 @@ func apply_colors(e:TE_Editor, t:TextEdit):
# tables
t.add_color_region("|", "", Color.tan, true)
func get_symbols(t:String) -> Dictionary:
var out = .get_symbols(t)

View File

@ -3,5 +3,5 @@
name="TextEditor"
description="A text editor for Godot."
author="teebar"
version="1.7"
version="1.8"
script="plugin.gd"