Newest Commit - code same as last commit
This commit is contained in:
24
src/lib/stores/bash/bash.ts
Normal file → Executable file
24
src/lib/stores/bash/bash.ts
Normal file → Executable file
@@ -65,6 +65,16 @@ export class Bash {
|
||||
this.vfs = new VirtualFS({ fs: args.fs, user: args.user });
|
||||
}
|
||||
|
||||
private _appendNewResult(inode: number, output: any, cmd: string) {
|
||||
const data: PrintData = {
|
||||
path: this.vfs.formatPath(this.vfs.getPathByInode(inode)),
|
||||
output: output,
|
||||
cmd: cmd
|
||||
};
|
||||
console.log(data);
|
||||
this._terminal.PrintOutput(data);
|
||||
}
|
||||
|
||||
updateHistory(input: string): void {
|
||||
if ((this.user.history.length = 255)) {
|
||||
this.user.history.unshift(...this.user.history.splice(-1));
|
||||
@@ -107,14 +117,14 @@ export class Bash {
|
||||
if (command.root) {
|
||||
if (this.hasSudoPerms(this.user.uid)) {
|
||||
let out: Result = command.method.call(this, args);
|
||||
this.appendNewResult(this.getCwd(), out, this.user.history[0]);
|
||||
this._appendNewResult(this.getCwd(), out, this.user.history[0]);
|
||||
}
|
||||
this.throwError(result);
|
||||
}
|
||||
|
||||
let out: Result = command.method.call(this, args);
|
||||
console.log(out);
|
||||
this.appendNewResult(out.path, out.data?.data, this.user.history[0]);
|
||||
this._appendNewResult(out.path, out.data?.data, this.user.history[0]);
|
||||
}
|
||||
|
||||
throwError(result: Result): void {
|
||||
@@ -134,16 +144,6 @@ export class Bash {
|
||||
}
|
||||
}
|
||||
|
||||
private appendNewResult(inode: number, output: any, cmd: string) {
|
||||
const data: PrintData = {
|
||||
path: this.vfs.formatPath(this.vfs.getPathByInode(inode)),
|
||||
output: output,
|
||||
cmd: cmd
|
||||
};
|
||||
console.log(data);
|
||||
this._terminal.PrintOutput(data);
|
||||
}
|
||||
|
||||
formatBytes(bytes: number, dPoint?: number, pow: 1024 | 1000 = 1024): string {
|
||||
if (!+bytes) return '0';
|
||||
|
||||
|
||||
0
src/lib/stores/bash/commands/cd.ts
Normal file → Executable file
0
src/lib/stores/bash/commands/cd.ts
Normal file → Executable file
0
src/lib/stores/bash/commands/ls.ts
Normal file → Executable file
0
src/lib/stores/bash/commands/ls.ts
Normal file → Executable file
0
src/lib/stores/bash/fs.ts
Normal file → Executable file
0
src/lib/stores/bash/fs.ts
Normal file → Executable file
0
src/lib/stores/bash/sort.ts
Normal file → Executable file
0
src/lib/stores/bash/sort.ts
Normal file → Executable file
0
src/lib/stores/bash/static.ts
Normal file → Executable file
0
src/lib/stores/bash/static.ts
Normal file → Executable file
0
src/lib/stores/char.ts
Normal file → Executable file
0
src/lib/stores/char.ts
Normal file → Executable file
0
src/lib/stores/lang.ts
Normal file → Executable file
0
src/lib/stores/lang.ts
Normal file → Executable file
0
src/lib/stores/stack.ts
Normal file → Executable file
0
src/lib/stores/stack.ts
Normal file → Executable file
0
src/lib/stores/terminal/init.svelte.ts
Normal file → Executable file
0
src/lib/stores/terminal/init.svelte.ts
Normal file → Executable file
0
src/lib/stores/terminal/stdio.ts
Normal file → Executable file
0
src/lib/stores/terminal/stdio.ts
Normal file → Executable file
8
src/lib/stores/terminal/terminal.ts
Normal file → Executable file
8
src/lib/stores/terminal/terminal.ts
Normal file → Executable file
@@ -110,6 +110,14 @@ export class Terminal {
|
||||
return this.bash.getUser();
|
||||
}
|
||||
|
||||
getTerminalWidth(): number {
|
||||
const width = this.callbacks.getWidth?.();
|
||||
if(!width) { throw new Error('somehow width is undefined still after all the checks'); }
|
||||
|
||||
console.log(width);
|
||||
return width;
|
||||
}
|
||||
|
||||
getCwd(): string {
|
||||
const fs: VirtualFS = this.bash.getFs();
|
||||
console.log(fs.getPathByInode(this.bash.getCwd()));
|
||||
|
||||
0
src/lib/stores/theme.ts
Normal file → Executable file
0
src/lib/stores/theme.ts
Normal file → Executable file
Reference in New Issue
Block a user