who the fuck knows

This commit is contained in:
Dan 2024-05-08 17:06:15 +01:00
parent 1c33ea2f59
commit 1da411cacd
31 changed files with 1372 additions and 78 deletions

View file

@ -0,0 +1,17 @@
extends CodeEdit
func _ready() -> void:
code_completion_enabled = true
add_code_completion_option(CodeEdit.KIND_MEMBER, "Test", "test")
add_code_completion_option(CodeEdit.KIND_MEMBER, "Boo", "boo")
code_completion_prefixes = ["t", "b"]
code_completion_requested.connect(func():
add_code_completion_option(CodeEdit.KIND_MEMBER, "Test", "test")
add_code_completion_option(CodeEdit.KIND_MEMBER, "Boo", "boo")
update_code_completion_options(true)
)
text_changed.connect(func(): request_code_completion(true))

View file

@ -0,0 +1,50 @@
## Autocomplete Class
extends OptionButton
## LineEdit.text_change_rejected
signal text_change_rejected(rejected_substring: String)
## LineEdit.text_changed
signal text_changed(new_text: String)
## LineEdit.text_submitted
signal text_submitted(new_text: String)
## LineEdit component
var edit: LineEdit = LineEdit.new()
@export var get_autocomplete_options: Callable = func(text: String): return []
func _ready() -> void:
focus_mode = Control.FOCUS_NONE
edit.custom_minimum_size = size
get_popup().unfocusable = true
add_child(edit)
edit.reset_size()
edit.text_change_rejected.connect(func(arg): text_change_rejected.emit(arg))
edit.text_changed.connect(func(arg): text_changed.emit(arg))
edit.text_submitted.connect(func(arg): text_submitted.emit(arg))
edit.text_changed.connect(_update_options)
edit.focus_entered.connect(_update_options)
edit.focus_exited.connect(clear)
get_autocomplete_options = func(text: String):
return [
"test",
"ashina",
"hello"
].filter(func(el: String): return el.contains(text))
func _update_options(text: String = edit.text):
clear()
var options = get_autocomplete_options.call(text)
for option in options:
if typeof(option) == TYPE_STRING:
add_item(option)
show_popup()