limit stdout buffer size to 100 lines

pull/2/head
fuwa 5 years ago
parent 08fe7edbfb
commit 37f2492518

@ -34,4 +34,5 @@ const emuHost = '192.168.10.100';
const host = isEmu ? emuHost : '127.0.0.1';
const int hashLength = 12;
const stdoutLineBufferSize = 100;

@ -24,6 +24,7 @@ import 'dart:io';
import 'dart:developer';
import 'dart:async';
import 'dart:convert';
import 'dart:collection';
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
@ -136,19 +137,22 @@ class LoadingState extends HookedState {
await Future.wait([load(), showBanner()]);
}
SyncingState _next = SyncingState(setState, getNotification, status);
SyncingState _next = SyncingState(setState, getNotification);
return moveState(_next);
}
}
class SyncingState extends HookedState {
String stdout;
Queue<String> stdout = Queue();
bool synced = false;
SyncingState(f, s, this.stdout) : super (f, s);
SyncingState(f, s) : super (f, s);
void append(String msg) {
this.stdout += msg;
stdout.addLast(msg);
while (stdout.length > config.stdoutLineBufferSize) {
stdout.removeFirst();
}
syncState();
}
@ -194,7 +198,7 @@ class SyncingState extends HookedState {
}
class SyncedState extends HookedState {
String stdout;
Queue<String> stdout;
int height;
Stream<String> processOutput;
bool synced = true;
@ -213,7 +217,7 @@ class SyncedState extends HookedState {
await for (final line in processOutput) {
if (!synced) break;
// print('synced: print stdout loop');
stdout += line;
stdout.addLast(line);
log.info(line);
}
}
@ -252,14 +256,17 @@ class SyncedState extends HookedState {
class ReSyncingState extends HookedState {
String stdout;
Queue<String> stdout;
Stream<String> processOutput;
bool synced = false;
ReSyncingState(f, s, this.stdout, this.processOutput) : super (f, s);
void append(String msg) {
this.stdout += msg;
stdout.addLast(msg);
while (stdout.length > config.stdoutLineBufferSize) {
stdout.removeFirst();
}
syncState();
}

@ -53,7 +53,7 @@ Widget buildReSyncing(BuildContext context, ReSyncingState state) {
reverse: true,
child: Text
(
state.stdout,
state.stdout.join(),
style: TextStyle
(
fontFamily: 'RobotoMono',

@ -53,7 +53,7 @@ Widget buildSyncing(BuildContext context, SyncingState state) {
reverse: true,
child: Text
(
state.stdout,
state.stdout.join(),
style: TextStyle
(
fontFamily: 'RobotoMono',