From 7560e4d7afb01cf76f52a5a31a811d8952b78de5 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Fri, 23 May 2025 23:41:04 +0300 Subject: [PATCH] move zterm to new app --- app/mxwm/package.json | 4 ++-- app/mxwm/startz.js | 24 ++++-------------------- app/mxwm/zterm.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 app/mxwm/zterm.js diff --git a/app/mxwm/package.json b/app/mxwm/package.json index 649c11c..8e8a313 100644 --- a/app/mxwm/package.json +++ b/app/mxwm/package.json @@ -3,6 +3,6 @@ "version": "0.1.0", "description": "Mega eXtreme Window Manager", "author": "MeexReay", - "apps": [ "zcom.js", "startz.js" ], + "apps": [ "zcom.js", "startz.js", "zterm.js" ], "configs": [] -} \ No newline at end of file +} diff --git a/app/mxwm/startz.js b/app/mxwm/startz.js index 072eb31..ce306d7 100644 --- a/app/mxwm/startz.js +++ b/app/mxwm/startz.js @@ -19,9 +19,9 @@ async function drawWindowDecorations(ctx, x, y, width, height, title) { const buttonSpacing = 8; const outerX = x - borderWidth - 1; - const outerY = y - headerHeight - borderWidth - 1; - const outerWidth = width + borderWidth * 2; - const outerHeight = height + headerHeight + borderWidth * 2; + const outerY = y - headerHeight - borderWidth - 2; + const outerWidth = width + borderWidth * 2 + 1; + const outerHeight = height + headerHeight + borderWidth * 2 + 2; ctx.fillStyle = "#f4f4f4"; ctx.fillRect(outerX, outerY, outerWidth, outerHeight) @@ -34,23 +34,7 @@ async function drawWindowDecorations(ctx, x, y, width, height, title) { } async function onStart(screen_ctx) { - let wid, ctx = createWindow({ - "title": "zterm", - "width": 500, - "height": 500, - "x": 50, - "y": 50, - "onkeydown": key => { - ctx.fillStyle = "#222"; - ctx.font = "bold 14px sans-serif"; - ctx.textBaseline = "middle"; - ctx.textAlign = "left"; - ctx.fillText(key, 10, 10); - } - }) - - ctx.fillStyle = "cyan" - ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height) + executeCommand(["/app/zterm.js"]) } async function onKeyDown(ctx, key) { diff --git a/app/mxwm/zterm.js b/app/mxwm/zterm.js new file mode 100644 index 0000000..87747fe --- /dev/null +++ b/app/mxwm/zterm.js @@ -0,0 +1,34 @@ +eval(readFile("/app/zcom.js")) + +var text = "" + +async function draw(ctx) { + ctx.fillStyle = "cyan" + ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height) + + ctx.fillStyle = "#222"; + ctx.font = "bold 14px sans-serif"; + ctx.textBaseline = "middle"; + ctx.textAlign = "left"; + ctx.fillText(text, 10, 10); +} + +async function onKeyDown(key) { + text += key +} + +async function main(args) { + let wid, ctx = createWindow({ + "title": "zterm", + "width": 500, + "height": 500, + "x": 50, + "y": 50, + "onkeydown": onKeyDown + }) + + while (graphics_canvas != null) { + draw(ctx) + await new Promise(res => setTimeout(res, 100)); + } +}