From 1d7e8d23749487bdd04e32fee5b8a12de5a9971a Mon Sep 17 00:00:00 2001 From: fuwa Date: Mon, 29 Jul 2019 15:03:21 +0000 Subject: [PATCH] detect exit from terminal --- cyberwow/lib/state.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index c9721d0..587dc1f 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -233,6 +233,7 @@ class SyncedState extends HookedState { int height; bool synced = true; + bool userExit = false; bool connected = true; Map getInfo = {}; List getConnections = []; @@ -250,6 +251,10 @@ class SyncedState extends HookedState { stdout.addLast('> ' + line + '\n'); syncState(); processInput.add(line); + + if (line == 'exit') { + userExit = true; + } } void append(final String msg) { @@ -281,7 +286,7 @@ class SyncedState extends HookedState { Future checkSync() async { await for (final _null in refresh.pull(getNotification, 'syncedState')) { - if (isExiting()) { + if (isExiting() || userExit) { log.fine('Synced state detected exiting'); break; } @@ -308,7 +313,7 @@ class SyncedState extends HookedState { await checkSync(); - if (isExiting()) { + if (isExiting() || userExit) { ExitingState _next = ExitingState ( setState, getNotification, isExiting, stdout, processOutput