2021-09-24 00:36:29 -05:00
|
|
|
jdk.imports['java.io.PrintStream'].load = async () => {
|
2021-09-23 01:41:44 -05:00
|
|
|
class PrintStream {
|
|
|
|
constructor() {
|
|
|
|
this.log = '';
|
|
|
|
this.onPrint = () => {};
|
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
this.log = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
_onPrint(length) {
|
|
|
|
this.onPrint(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
print(arg) {
|
|
|
|
let str = arg.toString();
|
|
|
|
this.log += str;
|
2021-09-23 19:56:21 -05:00
|
|
|
if (window?.ide) {
|
|
|
|
ide.log.value += str;
|
2021-09-23 01:41:44 -05:00
|
|
|
this._onPrint(str.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
println(arg) {
|
|
|
|
let str = arg.toString() + '\n';
|
|
|
|
this.log += str;
|
2021-09-23 19:56:21 -05:00
|
|
|
if (window?.ide) {
|
|
|
|
ide.log.value += str;
|
2021-09-23 01:41:44 -05:00
|
|
|
this._onPrint(str.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(format, ...args) {
|
2021-11-15 20:02:30 -05:00
|
|
|
let str = String.format(format, args);
|
2021-09-23 01:41:44 -05:00
|
|
|
this.log += str;
|
2021-09-23 19:56:21 -05:00
|
|
|
if (window?.ide) {
|
|
|
|
ide.log.value += str;
|
2021-09-23 01:41:44 -05:00
|
|
|
this._onPrint(str.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-23 23:26:42 -05:00
|
|
|
jdk.java.io.PrintStream = PrintStream;
|
2021-09-23 01:41:44 -05:00
|
|
|
};
|