cheapGlkOte: passing the full input data to onUpdateInputs

This commit is contained in:
He4eT 2021-07-18 23:31:57 +05:00
commit 10891cf269

View file

@ -8,17 +8,14 @@ class CheapGlkOte extends GlkOte {
constructor(handlers, loggers, size) {
super(size)
this.current_input_type = null
this.handlers = handlers
}
sendFn(message, window) {
sendFn (message, type, window) {
this.send_response(
this.current_input_type,
type,
window,
message)
this.current_input_type = null
}
init (iface) {
@ -27,13 +24,8 @@ class CheapGlkOte extends GlkOte {
}
update_inputs (data) {
if (!data.length) return null
const { type } = data[0]
if (['char', 'line'].includes(type)) {
this.current_input_type = type
this.handlers.onUpdateInputs(type)
}
if (!data.length) return []
this.handlers.onUpdateInputs(data)
}
accept_specialinput (data) {
@ -63,33 +55,27 @@ class CheapGlkOte extends GlkOte {
}
cancel_inputs (data) {
if (data.length === 0) {
this.current_input_type = null
this.handlers.onUpdateInputs(null)
}
this.handlers.onUpdateInputs(data)
}
disable(disable) {
this.disabled = disable
this.handlers.onDisable(disable)
disable (data) {
this.handlers.onDisable(data)
}
update_windows (windows) {
if (windows.length) {
this.handlers.onUpdateWindows(windows)
}
}
log (message) {
loggers.log(message)
this.loggers.log(message)
}
warning (message) {
loggers.warn(message)
this.loggers.warn(message)
}
error (message) {
loggers.error(message)
this.loggers.error(message)
}
}