help page and add date and time to taskbar

This commit is contained in:
MeexReay 2025-05-25 15:11:26 +03:00
parent 23c71f01ac
commit 3911454188
6 changed files with 115 additions and 19 deletions

View File

@ -1,8 +1,8 @@
{
"name": "mxwm",
"version": "0.1.1",
"version": "0.1.2",
"description": "Mega eXtreme Window Manager",
"author": "MeexReay",
"apps": [ "zcom.js", "startz.js", "zterm.js", "poki.js" ],
"configs": []
"apps": [ "zcom.js", "startz.js", "zterm.js", "poki.js", "zhelp.js" ],
"configs": [ "poki.json" ]
}

View File

@ -11,17 +11,10 @@ let ctx = null
const HEIGHT = 64
const APPS = [
{
"id": "zterm",
"title": "zterm - terminal emulator",
"icon": "app/mxwm/zterm.png",
"script": ["/app/zterm.js"]
}
]
const APPS = JSON.parse(readFile("/config/poki.json"))
const ICON_SIZE = 60
const ICON_PADDING = 4
const ICON_SIZE = 52
const ICON_PADDING = 6
function findRect() {
return [0, graphics_canvas.height - HEIGHT, graphics_canvas.width, HEIGHT]
@ -37,6 +30,23 @@ async function draw() {
ctx.drawImage(app.icon_image, x, ICON_PADDING, ICON_SIZE, ICON_SIZE)
x += ICON_SIZE + ICON_PADDING
}
ctx.font = "bold 20px sans-serif";
ctx.textBaseline = "middle";
ctx.textAlign = "center";
ctx.fillStyle = "black";
const now = new Date();
const timeString = now.toTimeString().slice(0, 5)
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = String(now.getFullYear()).slice(-2);
const dateString = `${day}.${month}.${year}`
ctx.fillText(timeString, ctx.canvas.width - 65, 22);
ctx.fillText(dateString, ctx.canvas.width - 65, 47);
}
async function onUpdate() {

14
app/mxwm/poki.json Normal file
View File

@ -0,0 +1,14 @@
[
{
"id": "zhelp",
"title": "help page",
"icon": "app/mxwm/zhelp.png",
"script": ["/app/zhelp.js"]
},
{
"id": "zterm",
"title": "zterm - terminal emulator",
"icon": "app/mxwm/zterm.png",
"script": ["/app/zterm.js"]
}
]

58
app/mxwm/zhelp.js Normal file
View File

@ -0,0 +1,58 @@
eval(readFile("/app/zcom.js"))
const HELP_MESSAGE = `Помощь по MXWM:
Выключить оконный менеджер - Alt+Shift+Q
Создать новое окно ZTERM - Alt+Enter
Закрыть окно - Alt+Shift+C
Переместить окно - Зажмите мышкой на заголовке окна
ИЛИ Нажмите Alt и зажмите левой кнопки мышки на окне
Изменить размер окна - Зажмите мышкой на
правом нижнем углу окна
ИЛИ Нажмите Alt и зажмите правой кнопки мышки на окне`
let run = true
function draw(ctx) {
ctx.fillStyle = "white"
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height)
ctx.font = "bold 14px terminus";
ctx.textBaseline = "middle";
ctx.textAlign = "left";
ctx.fillStyle = "black";
let y = 0
for (let line of HELP_MESSAGE.split("\n").reverse()) {
ctx.fillText(line, 10, ctx.canvas.height - 10 - y);
y += 18
}
}
async function main(args) {
let [wid, ctx] = createWindow({
"title": "help page",
"x": 50,
"y": 50,
"width": 420,
"height": 184,
"onresize": () => {
draw(ctx)
},
"onsignal": (s) => {
if (s == 9) run = false;
},
"resizable": false
})
draw(ctx)
while (run && graphics_canvas != null) {
await new Promise(resolve => setTimeout(resolve, 100))
draw(ctx)
}
closeWindow(wid)
return 0
}

BIN
app/mxwm/zhelp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

View File

@ -248,7 +248,9 @@ async function onKeyUp(key) {
}
async function main(args) {
[wid, ctx] = createWindow({
let run = true
let d = createWindow({
"title": "zterm",
"app_id": "zterm",
"width": 500,
@ -257,24 +259,36 @@ async function main(args) {
"y": 50,
"onkeydown": onKeyDown,
"onkeyup": onKeyUp,
"onresize": (w,h) => draw()
"onresize": (w,h) => draw(),
"onsignal": (s) => {
if (s == 9) {
run = false
}
}
})
wid = d[0]
ctx = d[1]
draw()
await executeCommand(
executeCommand(
["/app/posh.js"],
readStdin,
writeStdout,
setStdinFlag,
readLine,
pollStdinEvent
).promise
).promise.then(() => {
run = false
})
while (run && graphics_canvas != null) {
await new Promise(resolve => setTimeout(resolve, 100))
}
ctx = null
console.log("posh exit")
closeWindow(wid)
return 0