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
Tags
No related merge requests found
...@@ -3454,7 +3454,7 @@ ...@@ -3454,7 +3454,7 @@
}, },
"node_modules/swindows": { "node_modules/swindows": {
"version": "1.0.0", "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": { "node_modules/to-fast-properties": {
"version": "2.0.0", "version": "2.0.0",
......
...@@ -28,13 +28,8 @@ function main(): void { ...@@ -28,13 +28,8 @@ function main(): void {
bbs.nodesync(); bbs.nodesync();
mswait(5); mswait(5);
} }
ui.close();
} }
init(); init();
main(); 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 { ...@@ -22,13 +22,11 @@ export default class ActivityWindow extends ShellWindow {
input: Input; input: Input;
inputWindow: ControlledWindow; inputWindow: ControlledWindow;
timestamp: number = 0; 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) { constructor(name: string, wm: WindowManager, position: IPosition, size: ISize, footer: IBorderText) {
super(name, wm, position, size, footer); super(name, wm, position, size, footer);
this.window.wrap = defs.WRAP.WORD; this.window.wrap = defs.WRAP.WORD;
this.window.scrollBack = { width: Infinity, height: 1000 }; 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.write(HELP.split('\r\n').slice(1).join('\r\n'));
this.inputWindow = new ControlledWindow({ this.inputWindow = new ControlledWindow({
...@@ -62,10 +60,14 @@ export default class ActivityWindow extends ShellWindow { ...@@ -62,10 +60,14 @@ export default class ActivityWindow extends ShellWindow {
} }
write(str: string): void { write(str: string): void {
this.window.write(str); if (this.window.cursor.y > 0) this.window.write('\r\n');
this.sessionFile.open('a'); const now = time();
this.sessionFile.write(str); if (now - this.timestamp >= 60) {
this.sessionFile.close(); 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 { getCmd(cmd: string): void {
...@@ -97,12 +99,11 @@ export default class ActivityWindow extends ShellWindow { ...@@ -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 }); this.window.scrollTo({ x: 0, y: this.window.contentWindow.dataHeight - this.window.contentWindow.size.height });
break; break;
case keydefs.CTRL_H: // Help case keydefs.CTRL_H: // Help
// this.window.write(`${HELP}`);
this.write(`${HELP}`); this.write(`${HELP}`);
break; break;
case keydefs.CTRL_W: // Who's Online case keydefs.CTRL_W: // Who's Online
const presence = getPresence(); const presence = getPresence();
if (presence !== undefined) this.write(`${presence}`); // this.window.write(`${presence}`); if (presence !== undefined) this.write(`${presence}`);
break; break;
case keydefs.CTRL_S: // Send case keydefs.CTRL_S: // Send
if (!this.forceFocus) { if (!this.forceFocus) {
...@@ -120,18 +121,10 @@ export default class ActivityWindow extends ShellWindow { ...@@ -120,18 +121,10 @@ export default class ActivityWindow extends ShellWindow {
cycle(): void { cycle(): void {
const msg: string[] = []; const msg: string[] = [];
while (!js.terminated && queue.data_waiting) { while (!js.terminated && queue.data_waiting) {
const str = queue.read(); msg.push(queue.read());
msg.push(str.replace(/[\x00\x02-\x09\x0B\x0C\x0E-\x1F]/g, ''));
} }
if (msg.length < 1) return; if (msg.length < 1) return;
const now = time(); this.write(`${msg.join('\r\n')}`);
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'));
} }
close(): void { close(): void {
......
...@@ -136,11 +136,13 @@ export default class UI { ...@@ -136,11 +136,13 @@ export default class UI {
break; break;
// Global commands not handled by any window // Global commands not handled by any window
case keydefs.CTRL_D: // Disconnect immediately case keydefs.CTRL_D: // Disconnect immediately
this.close();
bbs.hangup(); bbs.hangup();
break; break;
case keydefs.CTRL_L: // Log off case keydefs.CTRL_L: // Log off
clear(); clear();
bbs.logout(); bbs.logout();
this.windowManager.draw();
break; break;
// Pass input to the focused window // Pass input to the focused window
default: default:
...@@ -150,4 +152,10 @@ export default class UI { ...@@ -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