mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-14 06:46:36 +00:00
Preserve Autoscroll and Timestamp states
Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
parent
459e55a69a
commit
7f33b62e0b
@ -1,6 +1,13 @@
|
||||
import { injectable } from "inversify";
|
||||
import { Emitter } from "@theia/core";
|
||||
|
||||
export namespace MonitorModel {
|
||||
export interface Data {
|
||||
autoscroll: boolean,
|
||||
timestamp: boolean
|
||||
}
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class MonitorModel {
|
||||
|
||||
@ -28,4 +35,16 @@ export class MonitorModel {
|
||||
this._timestamp = !this._timestamp;
|
||||
this.onChangeEmitter.fire(undefined);
|
||||
}
|
||||
|
||||
restore(model: MonitorModel.Data) {
|
||||
this._autoscroll = model.autoscroll;
|
||||
this._timestamp = model.timestamp;
|
||||
}
|
||||
|
||||
store(): MonitorModel.Data {
|
||||
return {
|
||||
autoscroll: this._autoscroll,
|
||||
timestamp: this._timestamp
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { ReactWidget, Message, Widget } from "@theia/core/lib/browser";
|
||||
import { ReactWidget, Message, Widget, StatefulWidget } from "@theia/core/lib/browser";
|
||||
import { postConstruct, injectable, inject } from "inversify";
|
||||
import * as React from 'react';
|
||||
import Select, { components } from 'react-select';
|
||||
@ -107,7 +107,7 @@ export interface SelectOption {
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class MonitorWidget extends ReactWidget {
|
||||
export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
||||
|
||||
static readonly ID = 'serial-monitor';
|
||||
|
||||
@ -169,6 +169,14 @@ export class MonitorWidget extends ReactWidget {
|
||||
this.update();
|
||||
}
|
||||
|
||||
storeState(): MonitorModel.Data {
|
||||
return this.model.store();
|
||||
}
|
||||
|
||||
restoreState(oldState: MonitorModel.Data): void {
|
||||
this.model.restore(oldState);
|
||||
}
|
||||
|
||||
protected onAfterAttach(msg: Message) {
|
||||
super.onAfterAttach(msg);
|
||||
this.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user