detect exit from terminal

pull/2/head
fuwa 5 years ago
parent 630c6ecc22
commit 1d7e8d2374

@ -233,6 +233,7 @@ class SyncedState extends HookedState {
int height; int height;
bool synced = true; bool synced = true;
bool userExit = false;
bool connected = true; bool connected = true;
Map<String, dynamic> getInfo = {}; Map<String, dynamic> getInfo = {};
List<dynamic> getConnections = []; List<dynamic> getConnections = [];
@ -250,6 +251,10 @@ class SyncedState extends HookedState {
stdout.addLast('> ' + line + '\n'); stdout.addLast('> ' + line + '\n');
syncState(); syncState();
processInput.add(line); processInput.add(line);
if (line == 'exit') {
userExit = true;
}
} }
void append(final String msg) { void append(final String msg) {
@ -281,7 +286,7 @@ class SyncedState extends HookedState {
Future<void> checkSync() async { Future<void> checkSync() async {
await for (final _null in refresh.pull(getNotification, 'syncedState')) { await for (final _null in refresh.pull(getNotification, 'syncedState')) {
if (isExiting()) { if (isExiting() || userExit) {
log.fine('Synced state detected exiting'); log.fine('Synced state detected exiting');
break; break;
} }
@ -308,7 +313,7 @@ class SyncedState extends HookedState {
await checkSync(); await checkSync();
if (isExiting()) { if (isExiting() || userExit) {
ExitingState _next = ExitingState ExitingState _next = ExitingState
( (
setState, getNotification, isExiting, stdout, processOutput setState, getNotification, isExiting, stdout, processOutput