-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
562 additions
and
1,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export class Log { | ||
private line: i32 = 0; | ||
constructor(line: i32 = 0) { | ||
this.line = line; | ||
} | ||
edit(data: string): Log { | ||
term.clearLn(this.line); | ||
process.stdout.write(data); | ||
process.stdout.write("\x1B[999B"); | ||
process.stdout.write("\x1B[0G"); | ||
return new Log(this.line); | ||
} | ||
} | ||
|
||
export namespace term { | ||
export let lines: i32 = 0; | ||
export function write(data: string): Log { | ||
process.stdout.write(data); | ||
return new Log(term.lines++); | ||
} | ||
export function writeLn(data: string): void { | ||
for (let i = 0; i < data.length; i++) { | ||
const code = data.charCodeAt(i); | ||
if (code === 10) term.lines++; | ||
} | ||
term.lines++; | ||
process.stdout.write(data + "\n"); | ||
} | ||
export function clearLn(line: i32): void { | ||
process.stdout.write(`\u001B[${term.lines - line}A`); | ||
process.stdout.write("\x1B[2K"); | ||
process.stdout.write("\x1B[0G"); | ||
} | ||
export function editLn(data: string, ln: i32): void { | ||
process.stdout.write(`\u001B[${ln}A`); | ||
process.stdout.write("\x1B[2K"); | ||
process.stdout.write("\x1B[0G"); | ||
term.writeLn(data); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.