How to use the scrollablebox function from blessed

Find comprehensive JavaScript blessed.scrollablebox code examples handpicked from public code repositorys.

blessed.scrollablebox is a widget in the Blessed library that creates a box widget that can be scrolled horizontally and vertically.

180
181
182
183
184
185
186
187
188
189
  }
  return ret;
};

// This fix prevents crashing, when view is removed from parent during before nextTick call.
const _setScrollPerc = blessed.scrollablebox.prototype.setScrollPerc;
blessed.scrollablebox.prototype.setScrollPerc = function (percent) {
  if (this.parent) {
    _setScrollPerc.call(this, percent);
  }
fork icon148
star icon0
watch icon1

37
38
39
40
41
42
43
44
45
46
47
	top: roomlist.height,
	height: 1,
});


Room.prototype.makeBox = function(){
	return Blessed.scrollablebox({
		parent: screen,
		top: userlist.height+roomlist.height,
		bottom: input.height+divider.height,
		keys: true,
fork icon0
star icon0
watch icon2

How does blessed.scrollablebox work?

blessed.scrollablebox is a widget in the Blessed library that creates a box widget that can be scrolled horizontally and vertically. When you create a blessed.scrollablebox widget, you can specify its position, size, and content. The widget is rendered as a box with scrollbars on the right and bottom sides. You can use the arrow keys, page up/down keys, and mouse wheel to scroll the content of the widget. You can also click and drag the scrollbars to scroll the content. Here's an implementation of blessed.scrollablebox to illustrate how it works: javascript Copy code {{{{{{{ const blessed = require('blessed'); const screen = blessed.screen(); const scrollableBox = blessed.scrollablebox({ content: 'This is a scrollable box!', scrollbar: { ch: ' ', track: { bg: 'grey' }, style: { inverse: true } }, border: { type: 'line' }, width: '50%', height: '50%', top: 'center', left: 'center', mouse: true, keys: true, alwaysScroll: true, scrollable: true }); screen.append(scrollableBox); screen.render(); In this implementation, we first import the Blessed library using require('blessed'). We also create a new screen using blessed.screen(). We then create a new blessed.scrollablebox widget using blessed.scrollablebox({ ... }). We provide several options to configure the widget, including the content, scrollbars, border, position, and scrolling behavior. We then append the scrollableBox widget to the screen using screen.append(scrollableBox). This adds the widget to the screen so that it can be rendered. Finally, we render the screen using screen.render(). This renders the screen and all its widgets, including the scrollableBox widget. Overall, blessed.scrollablebox is a useful widget in the Blessed library that allows you to create a box widget that can be scrolled horizontally and vertically.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const blessed = require("blessed");
const screen = blessed.screen();

const scrollableBox = blessed.scrollablebox({
  content: "This is a scrollable box!",
  scrollbar: {
    ch: " ",
    track: {
      bg: "grey",
    },
    style: {
      inverse: true,
    },
  },
  border: {
    type: "line",
  },
  width: "50%",
  height: "50%",
  top: "center",
  left: "center",
  mouse: true,
  keys: true,
  alwaysScroll: true,
  scrollable: true,
});

screen.append(scrollableBox);
screen.render();

In this example, we first import the Blessed library using require('blessed'). We also create a new screen using blessed.screen(). We then create a new blessed.scrollablebox widget using blessed.scrollablebox({ ... }). We provide several options to configure the widget, including the content, scrollbars, border, position, and scrolling behavior. The content option specifies the text content of the scrollable box. The scrollbar option specifies the appearance of the scrollbars. The border option specifies the appearance of the box border. The width and height options specify the size of the box. The top and left options specify the position of the box on the screen. The mouse and keys options specify whether mouse and keyboard events are captured by the widget. The alwaysScroll option specifies whether the widget should always scroll to the bottom when new content is added. The scrollable option specifies whether the widget is scrollable. We then append the scrollableBox widget to the screen using screen.append(scrollableBox). This adds the widget to the screen so that it can be rendered. Finally, we render the screen using screen.render(). This renders the screen and all its widgets, including the scrollableBox widget. Overall, this example demonstrates how to create a blessed.scrollablebox widget with custom content, appearance, and behavior using the Blessed library.