Skip to content

Commit 8c353bf

Browse files
committed
Fix #27 Scroll in widgets, add scrollbar
1 parent f116262 commit 8c353bf

File tree

6 files changed

+63
-27
lines changed

6 files changed

+63
-27
lines changed

HELP.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
| Plugin Parameters Widget | - | LEFT / RIGHT | Change parameter value by default step |
1313
| Plugin Parameters Widget | SHIFT | LEFT / RIGHT | Change parameter value by small step. |
1414
| Plugin Parameters Widget | CTRL | LEFT / RIGHT | Change parameter value by big step. |
15-
| Plugin Parameters Widget | - | PAGE_UP / PAGE_DOWN | Change parameter value by 1/5 of the maximum allowed |
15+
| Plugin Parameters Widget | - | TODO | Change parameter value by 1/5 of the maximum allowed |
16+
| Plugin Parameters Widget | - | PAGE UP / PAGE DOWN | Scroll properties |

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Modify `.config.yaml` with your settings, more info [in the docs](https://ajboni
5454
| Plugin Parameters Widget | - | LEFT / RIGHT | Change parameter value by default step |
5555
| Plugin Parameters Widget | SHIFT | LEFT / RIGHT | Change parameter value by small step. |
5656
| Plugin Parameters Widget | CTRL | LEFT / RIGHT | Change parameter value by big step. |
57-
| Plugin Parameters Widget | - | PAGE_UP / PAGE_DOWN | Change parameter value by 1/5 of the maximum allowed |
57+
| Plugin Parameters Widget | - | TODO | Change parameter value by 1/5 of the maximum allowed |
58+
| Plugin Parameters Widget | - | PAGE UP / PAGE DOWN | Scroll properties |
5859

5960
# DEV
6061

TODO.md

-1
This file was deleted.

src/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const LV2 = require("./lv2");
1212
const store = require("./store");
1313
const program = blessed.program();
1414
const screen = blessed.screen({
15-
smartCSR: true,
15+
// smartCSR: true,
1616
});
1717

1818
try {

src/widgets/pluginControls.js

+50-22
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ const PluginControls = function (grid, x, y, xSpan, ySpan) {
1212
mouse: true,
1313
interactive: true,
1414
keys: true,
15-
15+
vi: true,
16+
// alwaysScroll: true,
1617
padding: { left: 1, right: 1 },
17-
mouse: true,
18+
19+
scrollable: true,
20+
focusable: true,
1821
scrollbar: {
1922
ch: " ",
2023
inverse: true,
2124
},
22-
scrollable: true,
23-
focusable: true,
24-
2525
style: {
2626
border: { fg: "#7ea87f" },
2727
focus: {
@@ -31,6 +31,14 @@ const PluginControls = function (grid, x, y, xSpan, ySpan) {
3131
},
3232
});
3333

34+
pluginControls.key(["pageup"], (c, x) => {
35+
pluginControls.scroll(-pluginControls.height);
36+
});
37+
38+
pluginControls.key(["pagedown"], (c, x) => {
39+
pluginControls.scroll(pluginControls.height);
40+
});
41+
3442
pluginControls.key(["down"], (e, x) => {
3543
Layout.focusNext();
3644
});
@@ -66,7 +74,8 @@ const PluginControls = function (grid, x, y, xSpan, ySpan) {
6674
values[control.symbol],
6775
y,
6876
control,
69-
plugin
77+
plugin,
78+
pluginControls
7079
);
7180
pluginControls.append(controlWidget);
7281
pluginControls.scrollable = true;
@@ -106,7 +115,7 @@ const PluginControls = function (grid, x, y, xSpan, ySpan) {
106115
* @param {pluginInstance} pluginInstance
107116
* @returns Returns the progress control blessed widget.
108117
*/
109-
function progressControl(value, top, pluginControl, pluginInstance) {
118+
function progressControl(value, top, pluginControl, pluginInstance, parent) {
110119
const {
111120
comment,
112121
designation,
@@ -121,24 +130,22 @@ function progressControl(value, top, pluginControl, pluginInstance) {
121130
units,
122131
} = pluginControl;
123132

124-
var box = blessed.box({
133+
let box = blessed.box({
125134
interactive: false,
126-
focusable: false,
135+
focusable: true,
136+
127137
top: top,
138+
height: 3,
139+
// bg: "green",
140+
right: 2,
141+
left: 2,
142+
// alwaysScroll: true,
143+
scrollable: true,
128144
});
129145

130146
box.value = parseControlValue(pluginControl, value);
131147
const valuePercent = getControlValuePercent(pluginControl, box.value);
132148

133-
// Control Label
134-
var label = blessed.text({
135-
content: shortName,
136-
left: 1,
137-
top: 1,
138-
interactive: false,
139-
focusable: false,
140-
});
141-
142149
// Progress Widget
143150
var progress = blessed.progressbar({
144151
border: {
@@ -166,6 +173,18 @@ function progressControl(value, top, pluginControl, pluginInstance) {
166173
right: "8",
167174
filled: parseInt(valuePercent.toString()),
168175
width: "65%",
176+
177+
// alwaysScroll: true,
178+
scrollable: true,
179+
});
180+
181+
// Control Label
182+
let label = blessed.text({
183+
content: shortName,
184+
left: 1,
185+
top: 1,
186+
// alwaysScroll: true,
187+
scrollable: true,
169188
});
170189

171190
const valueLabelValue = getControlValueLabel(
@@ -177,8 +196,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
177196
content: valueLabelValue,
178197
right: 4,
179198
top: 1,
180-
interactive: false,
181-
focusable: false,
199+
// alwaysScroll: true,
200+
scrollable: true,
182201
});
183202

184203
box.append(label);
@@ -225,6 +244,15 @@ function progressControl(value, top, pluginControl, pluginInstance) {
225244
"pagedown",
226245
],
227246
function (e, keys) {
247+
if (keys.name === "pageup") {
248+
parent.scroll(-25);
249+
return;
250+
}
251+
if (keys.name === "pagedown") {
252+
parent.scroll(25);
253+
return;
254+
}
255+
228256
let newValue = 0;
229257

230258
// if it is a toggle button, just send 0 or 1
@@ -261,8 +289,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
261289

262290
if (keys.shift) step /= 10;
263291
if (keys.ctrl) step *= 5;
264-
if (keys.name === "pageup") step = -ranges.maximum / 5;
265-
if (keys.name === "pagedown") step = ranges.maximum / 5;
292+
// if (keys.name === "pageup") step = -ranges.maximum / 5;
293+
// if (keys.name === "pagedown") step = ranges.maximum / 5;
266294
if (keys.name === "left") step = -step;
267295
newValue = box.value + step;
268296

src/widgets/pluginMonitor.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const PluginMonitor = function (grid, x, y, xSpan, ySpan) {
2424
scrollable: true,
2525
style: {
2626
border: { fg: "#7ea87f" },
27-
scrollbar: true,
2827
focus: {
2928
border: { fg: "red" },
3029
// enabled: false,
@@ -115,6 +114,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
115114
interactive: false,
116115
focusable: false,
117116
top: top,
117+
alwaysScroll: true,
118+
scrollable: true,
118119
});
119120

120121
box.value = parseControlValue(pluginControl, value);
@@ -127,6 +128,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
127128
top: 1,
128129
interactive: false,
129130
focusable: false,
131+
alwaysScroll: true,
132+
scrollable: true,
130133
});
131134

132135
// Progress Widget
@@ -135,6 +138,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
135138
focusable: false,
136139
keyable: false,
137140
keys: false,
141+
alwaysScroll: true,
142+
scrollable: true,
138143
border: {
139144
type: "bg",
140145
// fg: "#882822",
@@ -173,6 +178,8 @@ function progressControl(value, top, pluginControl, pluginInstance) {
173178
top: 1,
174179
interactive: false,
175180
focusable: false,
181+
alwaysScroll: true,
182+
scrollable: true,
176183
});
177184

178185
box.append(label);

0 commit comments

Comments
 (0)