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')
|
||||
|
||||
class CheapGlkOte extends GlkOte {
|
||||
constructor(handlers, loggers) {
|
||||
super()
|
||||
constructor(handlers, loggers, size) {
|
||||
super(size)
|
||||
|
||||
this.current_input_type = null
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
17
src/index.js
17
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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue