mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
71efff6827
* Update eslint config * Applied linter to lib * Applied eslint config to CliClient/app * Removed prettier due to https://github.com/prettier/prettier/pull/4765 * First pass on test units * Applied linter config to test units * Applied eslint config to clipper * Applied to plugin dir * Applied to root of ElectronClient * Applied on RN root * Applied on CLI root * Applied on Clipper root * Applied config to tools * test hook * test hook * test hook * Added pre-commit hook * Applied rule no-trailing-spaces * Make sure root packages are installed when installing sub-dir * Added doc
51 lines
903 B
JavaScript
51 lines
903 B
JavaScript
const TextWidget = require('tkwidgets/TextWidget.js');
|
|
|
|
class ConsoleWidget extends TextWidget {
|
|
constructor() {
|
|
super();
|
|
this.lines_ = [];
|
|
this.updateText_ = false;
|
|
this.markdownRendering = false;
|
|
this.stickToBottom = true;
|
|
this.maxLines_ = 1000;
|
|
}
|
|
|
|
get name() {
|
|
return 'console';
|
|
}
|
|
|
|
get lastLine() {
|
|
return this.lines_.length ? this.lines_[this.lines_.length - 1] : '';
|
|
}
|
|
|
|
addLine(line) {
|
|
this.lines_.push(line);
|
|
this.updateText_ = true;
|
|
this.invalidate();
|
|
}
|
|
|
|
onFocus() {
|
|
this.stickToBottom = false;
|
|
super.onFocus();
|
|
}
|
|
|
|
onBlur() {
|
|
this.stickToBottom = true;
|
|
super.onBlur();
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
module.exports = ConsoleWidget;
|