Bless: make the magazine widget scrollable

I am using the Blessed library to make a control panel in a terminal.

I write things to the log widget and want the widget to scroll. With the code below, a scroll bar appears, but I cannot scroll it using the mouse wheel or dragging the scroll bar.

var logPanel = blessed.log({ top: '0', left: '0', width: '60%', height: '100%', tags: true, border: { type: 'line' }, scrollable: true, alwaysScroll: true, scrollbar: { ch: ' ', inverse: true }, style: { fg: 'green', bg: 'black', border: { fg: '#f0f0f0' } } }); 

How can I make the scroll work?

+5
source share
1 answer

According to the Blessed documentation, there are three scrolling methods that you can enable by setting the appropriate true properties in the options object:

  • mouse - whether to enable automatic mouse support for this element [scrollwheel]
  • keys - use predefined keys to navigate the text [arrow keys]
  • vi - use vi keys with keys [j / k keys] option

(as indicated in the deprecated ScrollableBox , but also applicable to a simple box)

I had some problems with this from the document itself. I think sometimes, if there is a lot of text, this does not mean that it is good.

Another problem that you encounter, if it overflows with text, it will not automatically scroll. You need to enable this yourself by calling the setScrollPerc(100) function on your Box object immediately after adding a new line.

+2
source

Source: https://habr.com/ru/post/1265236/


All Articles