Add/update more files

This commit is contained in:
Leroy Hopson 2020-05-10 22:56:49 +12:00
parent 3307231b65
commit 0769592a1b
44 changed files with 4188 additions and 362 deletions

View file

@ -244,7 +244,7 @@ func parse(data: Array, length: int):
handlers.invert()
for handler in handlers:
# undefined or true means success and to stop bubbling
if handler['target'].call(handler['method'], params.to_array()):
if handler['target'].call(handler['method'], params):
continue
handlers.invert()
if handlers.empty():

View file

@ -53,6 +53,17 @@ func _init(max_length: int = 32, max_sub_params_length: int = 32):
sub_params.resize(max_sub_params_length)
sub_params_idx.resize(max_length)
# Gets param at `index` from param if it exists and is non-zero.
# Otherwise returns `default` (which is zero anyway due to zero default
# mode (ZDM), but allows the caller to specify a non-zero default value).
func get_param(index: int, default = 0) -> int:
if index < params.size() and params[index]:
return params[index]
else:
return default
func add_param(value: int):
digit_is_sub = false
if length >= _max_length:
@ -78,7 +89,6 @@ func add_sub_param(value: int):
sub_params_idx[length - 1] += 1
func add_digit(value: int):
print("adding digit: ", value, " is sub: ", digit_is_sub)
var _length = sub_params_length if digit_is_sub else length
if _reject_digits or (not _length) or (digit_is_sub and _reject_sub_digits):
return
@ -86,6 +96,11 @@ func add_digit(value: int):
var cur = store[_length - 1]
store[_length - 1] = min(cur * 10 + value, MAX_VALUE) if ~cur else value
func size():
return params.size()
func to_array():
var res = []
for i in range(length):

View file

@ -1,5 +1,5 @@
# Copyright (c) 2020 The GodotXterm authors.
# Copyright (c) 2019 The xterm.js authors. All rights reserved.
# Ported to GDScript by the GodotXterm authors.
# License MIT
extends Reference