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

Deal with some annoying formatting stuff

parent 1d3d066e
Branches main
No related tags found
No related merge requests found
......@@ -3454,7 +3454,7 @@
},
"node_modules/swindows": {
"version": "1.0.0",
"resolved": "git+ssh://git@gitlab.synchro.net:echicken/swindows.git#a2104d78dcf3f7ff42f12bc34edd6652b5cb1fe1"
"resolved": "git+ssh://git@gitlab.synchro.net:echicken/swindows.git#0f5df42b75fb6fd1d3d2b94c456510ba9533818a"
},
"node_modules/to-fast-properties": {
"version": "2.0.0",
......
......@@ -28,13 +28,8 @@ function main(): void {
bbs.nodesync();
mswait(5);
}
ui.close();
}
init();
main();
/**
* To do:
* - mystery bug in swindows where returning from clear screen and calling wm.draw didn't set attribute correctly in some rows/cells for an avatar in an imsg
* - scrollback limit in swindows
*/
\ No newline at end of file
......@@ -22,13 +22,11 @@ export default class ActivityWindow extends ShellWindow {
input: Input;
inputWindow: ControlledWindow;
timestamp: number = 0;
sessionFile: any = new File(`${system.temp_path}active-shell-${user.number}-${time()}.txt`);
constructor(name: string, wm: WindowManager, position: IPosition, size: ISize, footer: IBorderText) {
super(name, wm, position, size, footer);
this.window.wrap = defs.WRAP.WORD;
this.window.scrollBack = { width: Infinity, height: 1000 };
// this.window.write(HELP.split('\r\n').slice(1).join('\r\n'));
this.write(HELP.split('\r\n').slice(1).join('\r\n'));
this.inputWindow = new ControlledWindow({
......@@ -62,10 +60,14 @@ export default class ActivityWindow extends ShellWindow {
}
write(str: string): void {
this.window.write(str);
this.sessionFile.open('a');
this.sessionFile.write(str);
this.sessionFile.close();
if (this.window.cursor.y > 0) this.window.write('\r\n');
const now = time();
if (now - this.timestamp >= 60) {
const ts = `\x01h\x01y${system.timestr(time())}\x01n\x01w\r\n`;
this.window.write(ts);
this.timestamp = now;
}
this.window.write(`${str}`);
}
getCmd(cmd: string): void {
......@@ -97,12 +99,11 @@ export default class ActivityWindow extends ShellWindow {
this.window.scrollTo({ x: 0, y: this.window.contentWindow.dataHeight - this.window.contentWindow.size.height });
break;
case keydefs.CTRL_H: // Help
// this.window.write(`${HELP}`);
this.write(`${HELP}`);
break;
case keydefs.CTRL_W: // Who's Online
const presence = getPresence();
if (presence !== undefined) this.write(`${presence}`); // this.window.write(`${presence}`);
if (presence !== undefined) this.write(`${presence}`);
break;
case keydefs.CTRL_S: // Send
if (!this.forceFocus) {
......@@ -120,18 +121,10 @@ export default class ActivityWindow extends ShellWindow {
cycle(): void {
const msg: string[] = [];
while (!js.terminated && queue.data_waiting) {
const str = queue.read();
msg.push(str.replace(/[\x00\x02-\x09\x0B\x0C\x0E-\x1F]/g, ''));
msg.push(queue.read());
}
if (msg.length < 1) return;
const now = time();
if (now - this.timestamp >= 60) {
// this.window.write(`\x01n\x01m${system.timestr(time())}\x01n\x01w\r\n`);
this.write(`\x01n\x01m${system.timestr(time())}\x01n\x01w\r\n`);
this.timestamp = now;
}
// this.window.write(msg.join('\r\n'));
this.write(msg.join('\r\n'));
this.write(`${msg.join('\r\n')}`);
}
close(): void {
......
......@@ -136,11 +136,13 @@ export default class UI {
break;
// Global commands not handled by any window
case keydefs.CTRL_D: // Disconnect immediately
this.close();
bbs.hangup();
break;
case keydefs.CTRL_L: // Log off
clear();
bbs.logout();
this.windowManager.draw();
break;
// Pass input to the focused window
default:
......@@ -150,4 +152,10 @@ export default class UI {
}
}
close(): void {
for (const window of this.windows) {
window.close?.();
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment