start method
Future<void>
start(
{ - bool testingDontWaitForBootup = false,
})
Implementation
Future<void> start({bool testingDontWaitForBootup = false}) async {
final initialRefreshCompleted = Completer<bool>();
var firstReceivePort = ReceivePort();
_isolate = await Isolate.spawn(terminalMain, firstReceivePort.sendPort);
_sendPort = await firstReceivePort.first;
firstReceivePort.close();
_sendPort!.send([_IsolateCommand.sendPort, _receivePort.sendPort]);
_receivePort.listen((message) {
_IsolateEvent action = message[0];
switch (action) {
case _IsolateEvent.bell:
this.onBell();
break;
case _IsolateEvent.titleChanged:
this.onTitleChange(message[1]);
break;
case _IsolateEvent.iconChanged:
this.onIconChange(message[1]);
break;
case _IsolateEvent.notifyChange:
_refreshEventDebouncer.notifyEvent(() {
poll();
});
break;
case _IsolateEvent.newState:
_lastState = message[1];
if (!initialRefreshCompleted.isCompleted) {
initialRefreshCompleted.complete(true);
}
this.notifyListeners();
break;
case _IsolateEvent.exit:
_isTerminated = true;
_backendExited.complete(message[1]);
break;
}
});
_sendPort!.send([
_IsolateCommand.init,
TerminalInitData(this.backend, this.platform, this.theme, this.maxLines)
]);
if (!testingDontWaitForBootup) {
await initialRefreshCompleted.future;
}
_isStarted = true;
}