mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-14 22:30:26 +01:00
27 lines
761 B
GDScript3
27 lines
761 B
GDScript3
|
# Copyright (c) 2020 The GodotXterm authors.
|
||
|
# Copyright (c) 2019 The xterm.js authors. All rights reserved.
|
||
|
# License MIT
|
||
|
extends Reference
|
||
|
|
||
|
enum TableAccess {
|
||
|
TRANSITION_ACTION_SHIFT = 4,
|
||
|
TRANSITION_STATE_MASK = 15,
|
||
|
INDEX_STATE_SHIFT = 8
|
||
|
}
|
||
|
|
||
|
var table: PoolByteArray = PoolByteArray()
|
||
|
|
||
|
func _init(length: int):
|
||
|
table.resize(length)
|
||
|
|
||
|
func setDefault(action: int, next: int):
|
||
|
for i in range(table.size()):
|
||
|
table[i] = action << TableAccess.TRANSITION_ACTION_SHIFT | next
|
||
|
|
||
|
func add(code: int, state: int, action: int, next: int):
|
||
|
table[state << TableAccess.INDEX_STATE_SHIFT | code] = action << TableAccess.TRANSITION_ACTION_SHIFT | next
|
||
|
|
||
|
func addMany(codes: Array, state: int, action: int, next: int):
|
||
|
for code in codes:
|
||
|
add(code, state, action, next)
|