mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 20:24:23 +02:00
Add more features, bug fixes and bugs ;-)
Most notably: - Reflow is now working. Terminal size will fill the window and cols/rows will be resized/calculated based on window and font size. - Added support for different fonts (i.e. bold, italic, bolditalic). - Enabled blinking characters. - Adde more tests and caught a few subtle bugs. - Removed renderer code (which was part of xterm.js) and just doing naive rendering in terminal.gd, but it seems to perform a lot faster. Still not working completely: - vim (some weirdness going on). - vttest (more weirdness). Todo: - Fix the above. - Draw the cursor! - Improve performance. Performance is still not great. The terminal becomes unusable when running `yes` or `cmatrix -r`.
This commit is contained in:
parent
0769592a1b
commit
0d4e10f5ab
30 changed files with 2640 additions and 1157 deletions
|
@ -145,8 +145,9 @@ func set_execute_handler_fallback(target: Object, method: String):
|
|||
_execute_handler_fb = { 'target': target, 'method': method }
|
||||
|
||||
|
||||
func set_esc_handler(id, target, method):
|
||||
_esc_handlers[identifier(id, [0x30, 0x7e])] = [{'target': target, 'method': method}]
|
||||
func set_esc_handler(id, target, method, arg = null):
|
||||
_esc_handlers[identifier(id, [0x30, 0x7e])] = [{'target': target,
|
||||
'method': method, 'arg': arg}]
|
||||
|
||||
|
||||
func set_esc_handler_fallback(target: Object, method: String):
|
||||
|
@ -229,6 +230,7 @@ func parse(data: Array, length: int):
|
|||
ParserAction.EXECUTE:
|
||||
var handler = _execute_handlers.get(code)
|
||||
if handler:
|
||||
print("EXEC: ", handler['method'])
|
||||
handler['target'].call(handler['method'])
|
||||
elif _execute_handler_fb:
|
||||
_execute_handler_fb['target'].call(_execute_handler_fb['method'], code)
|
||||
|
@ -243,6 +245,7 @@ func parse(data: Array, length: int):
|
|||
var handlers = _csi_handlers.get((collect << 8 | code), [])
|
||||
handlers.invert()
|
||||
for handler in handlers:
|
||||
print("CSI: ", handler['method'])
|
||||
# undefined or true means success and to stop bubbling
|
||||
if handler['target'].call(handler['method'], params):
|
||||
continue
|
||||
|
@ -277,8 +280,13 @@ 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']) != false:
|
||||
continue
|
||||
print("ESC: ", handler['method'])
|
||||
if handler['arg']:
|
||||
if handler['target'].call(handler['method'], handler['arg']) != false:
|
||||
continue
|
||||
else:
|
||||
if handler['target'].call(handler['method']) != false:
|
||||
continue
|
||||
handlers.invert()
|
||||
if handlers.empty():
|
||||
_esc_handler_fb['target'].call(_esc_handler_fb['method'], collect << 8 | code)
|
||||
|
|
|
@ -75,6 +75,12 @@ func add_param(value: int):
|
|||
params[length] = MAX_VALUE if value > MAX_VALUE else value
|
||||
length += 1
|
||||
|
||||
|
||||
# Add a sub parameter value.
|
||||
# The sub parameter is automatically associated with the last parameter value.
|
||||
# Thus it is not possible to add a subparameter without any parameter added yet.
|
||||
# `Params` only stores up to `subParamsLength` sub parameters, any later
|
||||
# sub parameter will be ignored.
|
||||
func add_sub_param(value: int):
|
||||
digit_is_sub = true
|
||||
if !length:
|
||||
|
@ -88,6 +94,21 @@ func add_sub_param(value: int):
|
|||
sub_params_length += 1
|
||||
sub_params_idx[length - 1] += 1
|
||||
|
||||
|
||||
# Whether parameter at index `idx` has sub parameters.
|
||||
func has_sub_params(idx: int) -> bool:
|
||||
return (sub_params_idx[idx] & 0xFF) - (sub_params_idx[idx] >> 8) > 0
|
||||
|
||||
|
||||
func get_sub_params(idx: int):
|
||||
var start = sub_params_idx[idx] >> 8
|
||||
var end = sub_params_idx[idx] & 0xFF
|
||||
if end - start > 0:
|
||||
return sub_params.slice(start, end - 1)
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
func add_digit(value: int):
|
||||
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):
|
||||
|
@ -97,10 +118,6 @@ func add_digit(value: int):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue