From 9c4b3e59f468cde28b3de41bef2a300758806c36 Mon Sep 17 00:00:00 2001 From: fuwa Date: Mon, 29 Jul 2019 14:23:33 +0000 Subject: [PATCH] sync state when terminal receive stdout --- cyberwow/lib/state.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 1cb1853..1c65775 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -251,6 +251,14 @@ class SyncedState extends HookedState { processInput.add(line); } + void append(String msg) { + stdout.addLast(msg); + while (stdout.length > config.stdoutLineBufferSize) { + stdout.removeFirst(); + } + syncState(); + } + void onPageChanged(int value) { this.pageIndex = value; } @@ -263,7 +271,7 @@ class SyncedState extends HookedState { if (!synced) break; // print('synced: print stdout loop'); - stdout.addLast(line); + append(line); log.info(line); } }