Skip to content

Commit 7f33b62

Browse files
committed
Preserve Autoscroll and Timestamp states
Signed-off-by: jbicker <[email protected]>
1 parent 459e55a commit 7f33b62

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

arduino-ide-extension/src/browser/monitor/monitor-model.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { injectable } from "inversify";
22
import { Emitter } from "@theia/core";
33

4+
export namespace MonitorModel {
5+
export interface Data {
6+
autoscroll: boolean,
7+
timestamp: boolean
8+
}
9+
}
10+
411
@injectable()
512
export class MonitorModel {
613

@@ -28,4 +35,16 @@ export class MonitorModel {
2835
this._timestamp = !this._timestamp;
2936
this.onChangeEmitter.fire(undefined);
3037
}
38+
39+
restore(model: MonitorModel.Data) {
40+
this._autoscroll = model.autoscroll;
41+
this._timestamp = model.timestamp;
42+
}
43+
44+
store(): MonitorModel.Data {
45+
return {
46+
autoscroll: this._autoscroll,
47+
timestamp: this._timestamp
48+
}
49+
}
3150
}

arduino-ide-extension/src/browser/monitor/monitor-widget.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReactWidget, Message, Widget } from "@theia/core/lib/browser";
1+
import { ReactWidget, Message, Widget, StatefulWidget } from "@theia/core/lib/browser";
22
import { postConstruct, injectable, inject } from "inversify";
33
import * as React from 'react';
44
import Select, { components } from 'react-select';
@@ -107,7 +107,7 @@ export interface SelectOption {
107107
}
108108

109109
@injectable()
110-
export class MonitorWidget extends ReactWidget {
110+
export class MonitorWidget extends ReactWidget implements StatefulWidget {
111111

112112
static readonly ID = 'serial-monitor';
113113

@@ -169,6 +169,14 @@ export class MonitorWidget extends ReactWidget {
169169
this.update();
170170
}
171171

172+
storeState(): MonitorModel.Data {
173+
return this.model.store();
174+
}
175+
176+
restoreState(oldState: MonitorModel.Data): void {
177+
this.model.restore(oldState);
178+
}
179+
172180
protected onAfterAttach(msg: Message) {
173181
super.onAfterAttach(msg);
174182
this.clear();

0 commit comments

Comments
 (0)