rse / blessed-xterm

XTerm Widget for Blessed Curses Environment
https://www.npmjs.com/package/blessed-xterm
47 stars 11 forks source link

how can we make it work well with a relative layout? #2

Open bencao opened 7 years ago

bencao commented 7 years ago

Thanks for the good work! Recently I used blessed-xterm in my project, to draw a dashboard like following:

------------------------------------
==== Menu Items At Top ========
==== Terminal in the Middle ========
==== Status Bar At Bottom ======
------------------------------------

here're some information about the above layout:

menuLayout (top: 0, left: 0, height: 1)
terminalLayout (top: 1, left: 0, height: '100%-2')
   xTermWindow.width = terminalLayout.width
   xTermWindow.height = terminalLayout.height
statusBarLayout (bottom: 0, left: 0, height: 1)

The problem I noticed is that when I resize the terminal, or adjust font size, the xterm window will remain its initial size, which does not fit any more.

Any idea whether we can make it more "responsible" to layout changes?

Thank you!

bencao commented 7 years ago

I did a further attempt:

Instead of specify a fixed width, I passed on "parent" and a percentage as "width" and "height" to xTermWindow. And I got an error like this:

TypeError: Cannot set property bytesRead of #<Socket> which has only a getter
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:16)
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:18)
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:18)
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:18)
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:18)
    at _clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:156:18)
    at clone (/Users/zcao/Documents/workspace/integration/node_modules/clone/clone.js:196:10)
    at XTerm (/Users/zcao/Documents/workspace/integration/node_modules/blessed-xterm/blessed-xterm.js5:54:19)
    at onBuildWorkspace (/Users/zcao/Documents/workspace/integration/cli/it_concerns/dev/uif.js:13:29)
    at buildScreen (/Users/zcao/Documents/workspace/integration/cli/it_concerns/dev/common.js:247:22)
    at buildWindows (/Users/zcao/Documents/workspace/integration/cli/it_concerns/dev/uif.js:10:10)
    at onReady (/Users/zcao/Documents/workspace/integration/cli/it_concerns/dev/uif.js:158:41)
    at Socket.runContainer.stdout.on.runContainerData (/Users/zcao/Documents/workspace/integration/cli/it_concerns/dev/common.js:440:7)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:250:12)

The reason might be that "parent" is a blessed layout object which cannot easily be cloned.

If I comment out the "clone" call in line 46 of blessed-xterm.js, it just works as expected, responsive to screen resize events and font size changes.

So the question becomes: What's the purpose of cloning the options, is it safe to remove this line?

kamushadenes commented 6 years ago

Had the same issue and commenting the clone call also fixed the problem for me.

I'm using the Grid layout from blessed-contrib.

novast commented 5 years ago

I have the same issue. Comment the clone fix the problem.

acidjazz commented 5 years ago

Are any of you using a fork w/ this clone rmeoved @novast @kamushadenes @bencao ?

Is there a solution that doesn't require me to fork this @rse ?

novast commented 5 years ago

No. Finally, I found that blessed.log meet my requirement. @acidjazz