blessed-xterm icon indicating copy to clipboard operation
blessed-xterm copied to clipboard

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

Open bencao opened this issue 8 years ago • 5 comments

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 avatar Jul 13 '17 20:07 bencao

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?

bencao avatar Jul 13 '17 21:07 bencao

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

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

kamushadenes avatar Feb 20 '18 19:02 kamushadenes

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

novast avatar Oct 07 '19 06:10 novast

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 ?

acidjazz avatar Nov 11 '19 06:11 acidjazz

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

novast avatar Nov 18 '19 07:11 novast