Skip to content

Commit 5dfd87c

Browse files
authored
Merge pull request #78 from Milk-Cool/master
Bugfix & Ctrl+Alt+Del
2 parents 1ac51ef + b8e2420 commit 5dfd87c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

js/core/tty/ctrlaltdel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = () => {
2+
debug("Ctrl+Alt+Del pressed, rebooting");
3+
$$.machine.reboot();
4+
}

js/core/tty/terminal.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ exports.clear = printer.clear;
2727

2828
let isReading = false;
2929

30+
function listenCtrlAltDel (keyinfo) {
31+
if (keyinfo.type === "kpdel"
32+
&& keyinfo.ctrl
33+
&& keyinfo.alt) {
34+
require("./ctrlaltdel.js")();
35+
}
36+
}
37+
keyboard.onKeydown.add(listenCtrlAltDel);
38+
3039
exports.read = (cb) => {
3140
if (isReading) {
3241
throw new Error('nested terminal read is not allowed');

js/service/shell/commands.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ const cmds = {
7979
'description': 'Show this message or show usage of the command =)',
8080
'usage': 'help <command> |OR| help |OR| help -p[=n] |OR| help --page[=n]',
8181
run (_args, f, res) {
82-
let args = _args.trim().split(/\s+/);
82+
let args = _args.trim().split(/(\s+)/).filter(i => i.trim().length > 0);
8383

84-
if (!args || args[0].startsWith("-p") || args[0].startsWith("--page")) {
85-
let tmp_page = args[0].slice(3 + 4 * Number(args[0].startsWith("--page"))) - 1 || 0;
86-
if(tmp_page == -1) tmp_page = 0;
84+
if (args.length === 0 || args[0].startsWith("-p") || args[0].startsWith("--page")) {
85+
if (!args.length) args = ["-p=1"];
86+
const tmp_page = args[0].slice(3 + 4 * Number(args[0].startsWith("--page"))) - 1;
8787
const height = HEIGHT - 4;
8888
const commandList = Array.from(processor.getCommands()).sort();
8989
if(tmp_page < 0 || tmp_page + 1 > Math.ceil(commandList.length / height)){

0 commit comments

Comments
 (0)