一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
63 行
1.2 KiB
TypeScript
63 行
1.2 KiB
TypeScript
const TextWidget = require('tkwidgets/TextWidget.js');
|
|
|
|
class ConsoleWidget extends TextWidget {
|
|
private lines_: string[];
|
|
private updateText_: boolean;
|
|
public markdownRendering: boolean;
|
|
public stickToBottom: boolean;
|
|
private maxLines_: number;
|
|
|
|
public constructor() {
|
|
super();
|
|
this.lines_ = [];
|
|
this.updateText_ = false;
|
|
this.markdownRendering = false;
|
|
this.stickToBottom = true;
|
|
this.maxLines_ = 1000;
|
|
}
|
|
|
|
public get name() {
|
|
return 'console';
|
|
}
|
|
|
|
public get lastLine() {
|
|
return this.lines_.length ? this.lines_[this.lines_.length - 1] : '';
|
|
}
|
|
|
|
public addLine(line: string) {
|
|
this.lines_.push(line);
|
|
this.updateText_ = true;
|
|
this.invalidate();
|
|
}
|
|
|
|
public onFocus() {
|
|
this.stickToBottom = false;
|
|
super.onFocus();
|
|
}
|
|
|
|
public onBlur() {
|
|
this.stickToBottom = true;
|
|
super.onBlur();
|
|
}
|
|
|
|
public clear() {
|
|
this.lines_ = [];
|
|
this.updateText_ = true;
|
|
this.invalidate();
|
|
}
|
|
|
|
public render() {
|
|
if (this.updateText_) {
|
|
if (this.lines_.length > this.maxLines_) {
|
|
this.lines_.splice(0, this.lines_.length - this.maxLines_);
|
|
}
|
|
this.text = this.lines_.join('\n');
|
|
this.updateText_ = false;
|
|
}
|
|
|
|
super.render();
|
|
}
|
|
}
|
|
|
|
export default ConsoleWidget;
|