Skip to content
Snippets Groups Projects
Commit 17b62d2e authored by echicken's avatar echicken :chicken:
Browse files

Reorg

parent 24e68345
Branches
Tags
No related merge requests found
import type { ICgaDefs, ISbbsDefs } from '@swag/ts4s';
import { load } from '@swag/ts4s';
import * as swindows from 'swindows';
import UI from './lib/UI';
const sbbsdefs: ISbbsDefs = load('sbbsdefs.js');
const cgadefs: ICgaDefs = load('cga_defs.js');
const { bbs, console, mswait } = js.global;
const windowManager = new swindows.WindowManager();
const ui = new UI(windowManager);
const ui = new UI();
function init(): void {
js.on_exit(`bbs.sys_status = ${bbs.sys_status};`);
......@@ -22,13 +20,11 @@ function init(): void {
bbs.sys_status |= sbbsdefs.SS_MOFF;
console.ctrlkey_passthru = "+UPKTG";
console.clear(cgadefs.BG_BLACK|cgadefs.LIGHTGRAY);
windowManager.hideCursor();
}
function main(): void {
while (!js.terminated) {
ui.cycle();
windowManager.refresh();
bbs.nodesync();
mswait(5);
}
......
......@@ -62,9 +62,12 @@ function getWindows(windowManager: swindows.WindowManager): IShellWindow[] {
export default class UI {
activeWindow: number = 0;
windows: IShellWindow[] = [];
windowManager: swindows.WindowManager;
constructor(windowManager: swindows.WindowManager) {
this.windows = getWindows(windowManager);
constructor() {
this.windowManager = new swindows.WindowManager();
this.windowManager.hideCursor();
this.windows = getWindows(this.windowManager);
this.focusWindow(1);
}
......@@ -73,6 +76,7 @@ export default class UI {
window.cycle();
}
this.getInput();
this.windowManager.refresh();
}
focusWindow(n: number): void {
......
......@@ -10,6 +10,7 @@ function clear(): void {
}
function exec(wm: WindowManager, fn: (...args: any[]) => any, ...args: any[]): void {
wm.showCursor();
clear();
try {
fn(...args);
......@@ -17,6 +18,7 @@ function exec(wm: WindowManager, fn: (...args: any[]) => any, ...args: any[]): v
console.putmsg(err as string);
}
clear();
wm.hideCursor();
wm.draw();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment