Add shell and echo app
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
export const Keycode = {
|
export const Keycode = {
|
||||||
Enter: 28,
|
Enter: 28,
|
||||||
|
Backspace: 14,
|
||||||
Q: 16,
|
Q: 16,
|
||||||
W: 17,
|
W: 17,
|
||||||
E: 18,
|
E: 18,
|
||||||
@@ -28,10 +29,12 @@ export const Keycode = {
|
|||||||
M: 50,
|
M: 50,
|
||||||
".": 52,
|
".": 52,
|
||||||
"/": 53,
|
"/": 53,
|
||||||
|
" ": 57,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RKeycode = {
|
export const RKeycode = {
|
||||||
28: "Enter",
|
28: "Enter",
|
||||||
|
14: "Backspace",
|
||||||
16: "Q",
|
16: "Q",
|
||||||
17: "W",
|
17: "W",
|
||||||
18: "E",
|
18: "E",
|
||||||
@@ -60,4 +63,5 @@ export const RKeycode = {
|
|||||||
50: "M",
|
50: "M",
|
||||||
52: ".",
|
52: ".",
|
||||||
53: "/",
|
53: "/",
|
||||||
|
57: " ",
|
||||||
};
|
};
|
||||||
|
|||||||
8
src/os/src/oskrnl/app/launcher.ts
Normal file
8
src/os/src/oskrnl/app/launcher.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { kmod_app_run } from "../../kernel/modules/app/app.kmod";
|
||||||
|
|
||||||
|
export function oskrnl_app_launcher_run(path: string, args: string) {
|
||||||
|
if ((globalThis as any).__oskrnl) {
|
||||||
|
(globalThis as any).__oskrnl.app_args = args;
|
||||||
|
}
|
||||||
|
kmod_app_run(path);
|
||||||
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import { oskrnl_app_launcher_run } from "./app/launcher";
|
||||||
import { oskrnl_console_log, oskrnl_console_update } from "./console/console";
|
import { oskrnl_console_log, oskrnl_console_update } from "./console/console";
|
||||||
import { oskrnl_input_onKeyPress } from "./input/input";
|
import { oskrnl_input_onKeyPress } from "./input/input";
|
||||||
|
|
||||||
export function oskrnl_register() {
|
export function oskrnl_register() {
|
||||||
(globalThis as any).__oskrnl = {
|
(globalThis as any).__oskrnl = {
|
||||||
|
app_args: "why",
|
||||||
console_log: oskrnl_console_log,
|
console_log: oskrnl_console_log,
|
||||||
console_update: oskrnl_console_update,
|
console_update: oskrnl_console_update,
|
||||||
input_onKeyPress: oskrnl_input_onKeyPress,
|
input_onKeyPress: oskrnl_input_onKeyPress,
|
||||||
|
app_launcher_run: oskrnl_app_launcher_run,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
1
test-hdd/apps/echo/index.js
Normal file
1
test-hdd/apps/echo/index.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__oskrnl.console_log(__oskrnl.app_args);
|
||||||
5
test-hdd/apps/echo/meta.lam
Normal file
5
test-hdd/apps/echo/meta.lam
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"app:name": "echo",
|
||||||
|
"app:version": "1.0.0",
|
||||||
|
"app:entrypoint": "index.js"
|
||||||
|
}
|
||||||
23
test-hdd/apps/tysh/index.js
Normal file
23
test-hdd/apps/tysh/index.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
__oskrnl.console_log("> ");
|
||||||
|
|
||||||
|
var input = "";
|
||||||
|
var inputActive = true;
|
||||||
|
|
||||||
|
__oskrnl.input_onKeyPress(function (key) {
|
||||||
|
if (!inputActive) return;
|
||||||
|
|
||||||
|
if (key == "Backspace") input = input.slice(0, -1);
|
||||||
|
else if (key == "Enter") {
|
||||||
|
inputActive = false;
|
||||||
|
process();
|
||||||
|
return;
|
||||||
|
} else input += key.toLowerCase();
|
||||||
|
|
||||||
|
__oskrnl.console_update("> " + input);
|
||||||
|
});
|
||||||
|
|
||||||
|
function process() {
|
||||||
|
var app = input.split(" ")[0];
|
||||||
|
var args = input.split(" ").slice(1);
|
||||||
|
__oskrnl.app_launcher_run(app, args.join(" "));
|
||||||
|
}
|
||||||
5
test-hdd/apps/tysh/meta.lam
Normal file
5
test-hdd/apps/tysh/meta.lam
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"app:name": "tysh",
|
||||||
|
"app:version": "1.0.0",
|
||||||
|
"app:entrypoint": "index.js"
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
It works!
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
console.log("Hello from myApp");
|
|
||||||
1
test-hdd/ushellc
Normal file
1
test-hdd/ushellc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/disk/apps/tysh
|
||||||
Reference in New Issue
Block a user