mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 08:57:25 +00:00
Add the possibility to specify the screen size
This commit is contained in:
parent
af71e2f706
commit
d283f27e81
3 changed files with 21 additions and 9 deletions
|
|
@ -5,8 +5,8 @@
|
||||||
const GlkOte = require('./glkOte/glkote-term')
|
const GlkOte = require('./glkOte/glkote-term')
|
||||||
|
|
||||||
class CheapGlkOte extends GlkOte {
|
class CheapGlkOte extends GlkOte {
|
||||||
constructor(handlers, loggers) {
|
constructor(handlers, loggers, size) {
|
||||||
super()
|
super(size)
|
||||||
|
|
||||||
this.current_input_type = null
|
this.current_input_type = null
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class GlkOte {
|
class GlkOte {
|
||||||
constructor() {
|
constructor({width, height}) {
|
||||||
|
this.width = width
|
||||||
|
this.height = height
|
||||||
|
|
||||||
this.current_metrics = null
|
this.current_metrics = null
|
||||||
this.disabled = false
|
this.disabled = false
|
||||||
this.generation = 0
|
this.generation = 0
|
||||||
|
|
@ -13,8 +16,8 @@ class GlkOte {
|
||||||
|
|
||||||
measure_window() {
|
measure_window() {
|
||||||
return {
|
return {
|
||||||
width: 80,
|
width: this.width,
|
||||||
height: 25,
|
height: this.height,
|
||||||
buffercharheight: 1,
|
buffercharheight: 1,
|
||||||
buffercharwidth: 1,
|
buffercharwidth: 1,
|
||||||
buffermarginx: 0,
|
buffermarginx: 0,
|
||||||
|
|
|
||||||
17
src/index.js
17
src/index.js
|
|
@ -3,7 +3,7 @@ const CheapGlkOte = require('./cheapGlkOte')
|
||||||
|
|
||||||
const noop = () => void null
|
const noop = () => void null
|
||||||
|
|
||||||
const noopHandlers = [
|
const defaultHandlers = [
|
||||||
'onInit',
|
'onInit',
|
||||||
'onUpdateWindows',
|
'onUpdateWindows',
|
||||||
'onUpdateInputs',
|
'onUpdateInputs',
|
||||||
|
|
@ -21,12 +21,21 @@ const defaultLoggers = {
|
||||||
error: console.error
|
error: console.error
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = (handlers_, loggers = defaultLoggers) => {
|
const defaultSize = {
|
||||||
|
width: 80,
|
||||||
|
height: 25
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = (handlers_, {loggers: loggers_, size: size_ } = {}) => {
|
||||||
const handlers =
|
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 Dialog = new FakeDialog(handlers, loggers)
|
||||||
const GlkOte = new CheapGlkOte(handlers, loggers)
|
const GlkOte = new CheapGlkOte(handlers, loggers, size)
|
||||||
|
|
||||||
const sendFn = GlkOte.sendFn.bind(GlkOte)
|
const sendFn = GlkOte.sendFn.bind(GlkOte)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue