-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftware.js
More file actions
145 lines (111 loc) · 3.3 KB
/
Copy pathsoftware.js
File metadata and controls
145 lines (111 loc) · 3.3 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const elem_project_info_text = document.getElementById('project-info-text');
const elem_terminal = document.getElementById('terminal');
const projects = [
'bakey',
'eclair-os',
'emerald',
'lv2-plugins',
];
const project_descriptions = {
'bakey': 'A simple and portable terminal emulator written in C.',
'eclair-os': 'A hobby operating system written in C for the X86 platform. It is at this point more of an artistic project.',
'emerald': 'A simple python-like scripting language designed around speed, efficiency and versatility.',
'lv2-plugins': 'A collection of audio plugins / effects in the LV2 format.',
};
const project_pages = {
'bakey': 'https://github.com/Pixelthegreat/bakey',
'eclair-os': 'https://github.com/Pixelthegreat/eclair-os',
'emerald': 'https://github.com/Pixelthegreat/emerald',
'lv2-plugins': 'https://github.com/Pixelthegreat/lv2-plugins',
};
function display_project(name) {
elem_project_info_text.innerHTML = '<a href="' + project_pages[name] + '">(Main page)</a><br><br>' + project_descriptions[name];
}
/* open terminal */
var terminal = new Terminal();
terminal.resize(48, 6);
terminal.options = {
fontSize: 12,
fontFamily: 'monospace',
theme: {
background: '#16161a',
foreground: '#d7e0fe',
black: '#202126',
brightBlack: '#383a42',
red: '#bd608f',
brightRed: '#eeaacc',
green: '#8fbd60',
brightGreen: '#cceeaa',
yellow: '#bd8f60',
brightYellow: '#eeccaa',
blue: '#608fbd',
brightBlue: '#aaccee',
magenta: '#8f60bd',
brightMagenta: '#ccaaee',
cyan: '#60bd8f',
brightCyan: '#aaeecc',
white: '#aeb5cd',
brightWhite: '#d7e0fe',
cursor: '#d7e0fe',
cursorAccent: '#16161a',
},
};
terminal.open(elem_terminal);
terminal.write('\n ');
for (let i = 0; i < 16; i++) {
if (i < 8) terminal.write('\x1b[4' + i + 'm ');
else terminal.write('\x1b[10' + (i - 8) + 'm ');
}
terminal.write('\x1b[0m\r\n\nType \'help\' for help!\r\n $ ');
/* this generally follows the same strategy as the xtermjs.org demo */
var input_string = '';
terminal.onData(e => {
switch (e) {
/* enter pressed */
case '\r':
processInput();
input_string = '';
break;
/* backspace pressed */
case '\u007f':
if (input_string.length > 0) {
terminal.write('\b \b');
input_string = input_string.slice(0, input_string.length - 1);
}
break;
/* anything else */
default:
if ((e >= '\u0020' && e <= '\u007e') || e >= '\00a0') {
input_string += e;
terminal.write(e);
}
break;
}
});
/* process terminal input */
function processInput() {
let args = input_string.split(' ');
if (args.length > 0) {
let command = args[0];
/* help */
if (command == 'help')
terminal.write('\r\n help - Display this help message\r\n project - Display list of projects\r\n project <name of project> - Display project information');
/* project info */
else if (command == 'project') {
if (args.length >= 2) {
let name = args[1];
let description = project_descriptions[name];
if (description !== undefined)
terminal.write('\r\n' + description);
else terminal.write('\r\nUnrecognized project \'' + name + '\'');
}
else {
for (let i in projects)
terminal.write('\r\n' + projects[i]);
}
}
/* otherwise */
else terminal.write('\r\nUnrecognized command \'' + command + '\'');
}
terminal.write('\r\n $ ');
}