diff --git a/src/cheapGlkOte.js b/src/cheapGlkOte.js index fbcb931..01ad987 100644 --- a/src/cheapGlkOte.js +++ b/src/cheapGlkOte.js @@ -5,8 +5,8 @@ const GlkOte = require('./glkOte/glkote-term') class CheapGlkOte extends GlkOte { - constructor(handlers, loggers) { - super() + constructor(handlers, loggers, size) { + super(size) this.current_input_type = null diff --git a/src/glkOte/glkote-term.js b/src/glkOte/glkote-term.js index f91fdc8..2a4d251 100644 --- a/src/glkOte/glkote-term.js +++ b/src/glkOte/glkote-term.js @@ -3,7 +3,10 @@ */ class GlkOte { - constructor() { + constructor({width, height}) { + this.width = width + this.height = height + this.current_metrics = null this.disabled = false this.generation = 0 @@ -13,8 +16,8 @@ class GlkOte { measure_window() { return { - width: 80, - height: 25, + width: this.width, + height: this.height, buffercharheight: 1, buffercharwidth: 1, buffermarginx: 0, diff --git a/src/index.js b/src/index.js index b832a4d..397397f 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,7 @@ const CheapGlkOte = require('./cheapGlkOte') const noop = () => void null -const noopHandlers = [ +const defaultHandlers = [ 'onInit', 'onUpdateWindows', 'onUpdateInputs', @@ -21,12 +21,21 @@ const defaultLoggers = { error: console.error } -module.exports = (handlers_, loggers = defaultLoggers) => { +const defaultSize = { + width: 80, + height: 25 +} + +module.exports = (handlers_, {loggers: loggers_, size: size_ } = {}) => { const handlers = - Object.assign({}, noopHandlers, handlers_) + Object.assign({}, defaultHandlers, handlers_) + const loggers = + Object.assign({}, defaultLoggers, size_) + const size = + Object.assign({}, defaultSize, size_) const Dialog = new FakeDialog(handlers, loggers) - const GlkOte = new CheapGlkOte(handlers, loggers) + const GlkOte = new CheapGlkOte(handlers, loggers, size) const sendFn = GlkOte.sendFn.bind(GlkOte)