-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 1 KB
/
index.js
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
30
31
32
33
34
35
36
const blessed = require('blessed');
const contrib = require('blessed-contrib');
const screen = blessed.screen();
const log = require('./src/utils/log');
const pages = require('./src/utils/pages');
// We deliberately omitted helpPage to avoid circular dependencies
const helpPage = require('./src/pages/help');
log('Starting eax');
screen.key(['escape', 'q', 'C-c'], function (/*ch, key*/) {
return process.exit(0); // eslint-disable-line
});
const _pages = [
...pages,
{ name: 'help', page: helpPage, keyCodes: ['?', '!'] },
];
const pageObjects = _pages.map((p) => p.page);
var carousel = new contrib.carousel(pageObjects, {
screen: screen,
interval: 0, //how often to switch views (set 0 to never swicth automatically)
controlKeys: true, //should right and left keyboard arrows control view rotation
});
// Define keyboard navigations
_pages.forEach((p, index) => {
screen.key(p.keyCodes, function (/*ch, key*/) {
carousel.currPage = index;
carousel.move();
});
});
module.exports = carousel;