-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxtrn-setup.js
95 lines (84 loc) · 2.96 KB
/
xtrn-setup.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// $Id: xtrn-setup.js,v 1.8 2020/04/27 02:10:25 rswindell Exp $
// vi: tabstop=4
load('sbbsdefs.js');
load('frame.js');
load('tree.js');
js.on_exit('console.attributes = ' + console.attributes);
js.on_exit('bbs.sys_status = ' + bbs.sys_status);
bbs.sys_status|=SS_MOFF;
const frame = new Frame(1, 1, console.screen_columns, console.screen_rows, BG_BLUE|WHITE);
const main_frame = new Frame(1, 2, frame.width, frame.height - 2, BG_BLACK|LIGHTGRAY, frame);
const tree_frame = new Frame(1, main_frame.y + 1, Math.floor(main_frame.width / 2), main_frame.height - 2, BG_BLACK|LIGHTGRAY, main_frame);
const info_frame = new Frame(tree_frame.width + 1, main_frame.y + 1, main_frame.width - tree_frame.width - 1, main_frame.height - 2, BG_BLACK|WHITE, main_frame);
info_frame.word_wrap = true;
const tree = new Tree(tree_frame);
frame.putmsg('External Program Setup');
frame.gotoxy(1, frame.height);
frame.putmsg('[Up/Down/Home/End] to navigate, [Enter] to select, [Q] to quit');
tree.colors.fg = LIGHTGRAY;
tree.colors.bg = BG_BLACK;
tree.colors.lfg = WHITE;
tree.colors.lbg = BG_CYAN;
tree.colors.kfg = LIGHTCYAN;
var longest = 0;
directory(system.exec_dir + '../xtrn/*', GLOB_ONLYDIR).forEach(function (e) {
const ini = e + '/install-xtrn.ini';
if (!file_exists(ini)) return;
const f = new File(ini);
if (!f.open('r')) {
alert("Error " + f.error + " opening " + f.name);
return;
}
const xtrn = f.iniGetObject();
f.close();
if(!xtrn.Name) {
alert("Skipping file with no 'Name' value: " + f.name);
return;
}
const item = tree.addItem(xtrn.Name, function () {
console.clear(LIGHTGRAY);
js.exec('install-xtrn.js', {}, e);
console.pause();
frame.invalidate();
});
item.__xtrn_setup = xtrn;
if (xtrn.Name.length > longest) longest = xtrn.Name.length;
});
tree_frame.width = longest + 1;
info_frame.x = tree_frame.width + 2;
info_frame.width = main_frame.width - tree_frame.width - 2;
console.clear(BG_BLACK|LIGHTGRAY);
frame.open();
tree.open();
frame.cycle();
var key;
var xtrn;
console.ungetstr(KEY_UP);
while (!js.terminated) {
key = console.getkey();
if (key.toLowerCase() == 'q') break;
tree.getcmd(key);
if (key == KEY_UP || key == KEY_DOWN || key == KEY_HOME || key == KEY_END) {
xtrn = tree.currentItem.__xtrn_setup;
info_frame.erase(' ');
info_frame.putmsg('\x01h\x01w' + xtrn.Name + '\r\n');
if (xtrn.Desc) {
info_frame.putmsg('\x01n\x01w' + xtrn.Desc + '\r\n');
}
info_frame.crlf();
if (xtrn.By) {
info_frame.putmsg('\x01h\x01cBy\x01w:\r\n');
info_frame.putmsg('\x01w' + xtrn.By + '\r\n\r\n');
}
if (xtrn.Cats) {
info_frame.putmsg('\x01h\x01cCategories\x01w:\r\n');
info_frame.putmsg('\x01n' + xtrn.Cats + '\r\n\r\n');
}
if (xtrn.Subs) {
info_frame.putmsg('\x01h\x01cSubcategories\x01w:\r\n');
info_frame.putmsg('\x01n' + xtrn.Subs + '\r\n');
}
}
if (frame.cycle()) console.gotoxy(console.screen_columns, console.screen_rows);
}
frame.close();