mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-13 12:19:29 +00:00
a few bugfixes. updated grpc dependencies.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -171,6 +171,7 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
||||
|
||||
// Serial Monitor
|
||||
bind(MonitorModel).toSelf().inSingletonScope();
|
||||
bind(FrontendApplicationContribution).toService(MonitorModel);
|
||||
bind(MonitorWidget).toSelf();
|
||||
bindViewContribution(bind, MonitorViewContribution);
|
||||
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
|
||||
|
||||
@@ -96,11 +96,11 @@ export class MonitorConnection {
|
||||
const result = await this.monitorService.disconnect(this.state.connectionId);
|
||||
if (result) {
|
||||
console.log(`<<< Disposed connection. Was: ${MonitorConnection.State.toString(this.state)}`);
|
||||
this.state = undefined;
|
||||
this.onConnectionChangedEmitter.fire(undefined);
|
||||
} else {
|
||||
console.warn(`<<< Could not dispose connection. Activate connection: ${MonitorConnection.State.toString(this.state)}`);
|
||||
}
|
||||
this.state = undefined;
|
||||
this.onConnectionChangedEmitter.fire(undefined);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { injectable } from 'inversify';
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { Emitter, Event } from '@theia/core/lib/common/event';
|
||||
import { MonitorConfig } from '../../common/protocol/monitor-service';
|
||||
import { FrontendApplicationContribution, LocalStorageService } from '@theia/core/lib/browser';
|
||||
|
||||
@injectable()
|
||||
export class MonitorModel {
|
||||
export class MonitorModel implements FrontendApplicationContribution {
|
||||
|
||||
protected static STORAGE_ID = 'arduino-monitor-model';
|
||||
|
||||
@inject(LocalStorageService)
|
||||
protected readonly localStorageService: LocalStorageService;
|
||||
|
||||
protected readonly onChangeEmitter: Emitter<void>;
|
||||
protected _autoscroll: boolean;
|
||||
@@ -19,6 +25,14 @@ export class MonitorModel {
|
||||
this.onChangeEmitter = new Emitter<void>();
|
||||
}
|
||||
|
||||
onStart(): void {
|
||||
this.localStorageService.getData<MonitorModel.State>(MonitorModel.STORAGE_ID).then(state => {
|
||||
if (state) {
|
||||
this.restoreState(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get onChange(): Event<void> {
|
||||
return this.onChangeEmitter.event;
|
||||
}
|
||||
@@ -29,6 +43,7 @@ export class MonitorModel {
|
||||
|
||||
toggleAutoscroll(): void {
|
||||
this._autoscroll = !this._autoscroll;
|
||||
this.storeState();
|
||||
}
|
||||
|
||||
get timestamp(): boolean {
|
||||
@@ -37,6 +52,7 @@ export class MonitorModel {
|
||||
|
||||
toggleTimestamp(): void {
|
||||
this._timestamp = !this._timestamp;
|
||||
this.storeState();
|
||||
}
|
||||
|
||||
get baudRate(): MonitorConfig.BaudRate {
|
||||
@@ -45,7 +61,7 @@ export class MonitorModel {
|
||||
|
||||
set baudRate(baudRate: MonitorConfig.BaudRate) {
|
||||
this._baudRate = baudRate;
|
||||
this.onChangeEmitter.fire(undefined);
|
||||
this.storeState().then(() => this.onChangeEmitter.fire(undefined));
|
||||
}
|
||||
|
||||
get lineEnding(): MonitorModel.EOL {
|
||||
@@ -54,10 +70,10 @@ export class MonitorModel {
|
||||
|
||||
set lineEnding(lineEnding: MonitorModel.EOL) {
|
||||
this._lineEnding = lineEnding;
|
||||
this.onChangeEmitter.fire(undefined);
|
||||
this.storeState().then(() => this.onChangeEmitter.fire(undefined));
|
||||
}
|
||||
|
||||
restore(state: MonitorModel.State) {
|
||||
protected restoreState(state: MonitorModel.State) {
|
||||
this._autoscroll = state.autoscroll;
|
||||
this._timestamp = state.timestamp;
|
||||
this._baudRate = state.baudRate;
|
||||
@@ -65,13 +81,13 @@ export class MonitorModel {
|
||||
this.onChangeEmitter.fire(undefined);
|
||||
}
|
||||
|
||||
store(): MonitorModel.State {
|
||||
return {
|
||||
protected async storeState(): Promise<void> {
|
||||
this.localStorageService.setData(MonitorModel.STORAGE_ID, {
|
||||
autoscroll: this._autoscroll,
|
||||
timestamp: this._timestamp,
|
||||
baudRate: this._baudRate,
|
||||
lineEnding: this._lineEnding
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
|
||||
}
|
||||
}
|
||||
|
||||
async registerToolbarItems(registry: TabBarToolbarRegistry) {
|
||||
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
||||
registry.registerItem({
|
||||
id: 'monitor-autoscroll',
|
||||
render: () => this.renderAutoScrollButton(),
|
||||
@@ -106,7 +106,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
|
||||
}
|
||||
|
||||
protected readonly toggleAutoScroll = () => this.doToggleAutoScroll();
|
||||
protected async doToggleAutoScroll() {
|
||||
protected async doToggleAutoScroll(): Promise<void> {
|
||||
this.model.toggleAutoscroll();
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export class MonitorViewContribution extends AbstractViewContribution<MonitorWid
|
||||
}
|
||||
|
||||
protected readonly toggleTimestamp = () => this.doToggleTimestamp();
|
||||
protected async doToggleTimestamp() {
|
||||
protected async doToggleTimestamp(): Promise<void> {
|
||||
this.model.toggleTimestamp();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { OptionsType } from 'react-select/src/types';
|
||||
import Select from 'react-select';
|
||||
import { Styles } from 'react-select/src/styles';
|
||||
import { MessageService } from '@theia/core/lib/common/message-service';
|
||||
import { ReactWidget, Message, Widget, StatefulWidget } from '@theia/core/lib/browser';
|
||||
import { ReactWidget, Message, Widget } from '@theia/core/lib/browser';
|
||||
import { MonitorServiceClientImpl } from './monitor-service-client-impl';
|
||||
import { MonitorConfig, MonitorService } from '../../common/protocol/monitor-service';
|
||||
import { AttachedSerialBoard, BoardsService } from '../../common/protocol/boards-service';
|
||||
@@ -111,7 +111,7 @@ export interface SelectOption<T> {
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
||||
export class MonitorWidget extends ReactWidget {
|
||||
|
||||
static readonly ID = 'serial-monitor';
|
||||
|
||||
@@ -155,7 +155,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
||||
this.lines = [];
|
||||
this.chunk = '';
|
||||
this.scrollOptions = undefined;
|
||||
// TODO onError
|
||||
}
|
||||
|
||||
@postConstruct()
|
||||
@@ -176,6 +175,7 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
||||
if (selectedBoard && selectedPort) {
|
||||
this.boardsService.getAttachedBoards().then(({ boards }) => {
|
||||
if (boards.filter(AttachedSerialBoard.is).some(board => BoardsConfig.Config.sameAs(config, board))) {
|
||||
this.clearConsole();
|
||||
this.connect();
|
||||
}
|
||||
});
|
||||
@@ -190,14 +190,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
|
||||
this.update();
|
||||
}
|
||||
|
||||
storeState(): MonitorModel.State {
|
||||
return this.model.store();
|
||||
}
|
||||
|
||||
restoreState(oldState: MonitorModel.State): void {
|
||||
this.model.restore(oldState);
|
||||
}
|
||||
|
||||
onBeforeAttach(msg: Message): void {
|
||||
super.onBeforeAttach(msg);
|
||||
this.clearConsole();
|
||||
|
||||
Reference in New Issue
Block a user