1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jre/java/io/PrintStream.js
Quinton Ashley e9c4dd302e 1.0.2
2021-09-23 19:56:21 -05:00

45 lines
774 B
JavaScript
Executable File

jre.imports['java.io.PrintStream'].load = () => {
class PrintStream {
constructor() {
this.log = '';
this.onPrint = () => {};
}
reset() {
this.log = '';
}
_onPrint(length) {
this.onPrint(length);
}
print(arg) {
let str = arg.toString();
this.log += str;
if (window?.ide) {
ide.log.value += str;
this._onPrint(str.length);
}
}
println(arg) {
let str = arg.toString() + '\n';
this.log += str;
if (window?.ide) {
ide.log.value += str;
this._onPrint(str.length);
}
}
printf(format, ...args) {
let str = new Formatter().format(format, args);
this.log += str;
if (window?.ide) {
ide.log.value += str;
this._onPrint(str.length);
}
}
}
jre.java.io.PrintStream = PrintStream;
};