diff --git a/assets/select_background.png b/assets/select_background.png index 9f61515..c3c8144 100644 Binary files a/assets/select_background.png and b/assets/select_background.png differ diff --git a/lib/main.dart b/lib/main.dart index d79b77d..ee281b8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -311,8 +311,8 @@ class ReplBody extends StatefulWidget { class _ReplBodyState extends State { final TextEditingController _controller = TextEditingController(); FocusNode replNode = FocusNode(); - var prevSubmitList = []; var outputList = []; + var containerId = 'none'; @override void initState() { @@ -347,7 +347,17 @@ class _ReplBodyState extends State { stream: widget.channel.stream, builder: (context, snapshot) { if (snapshot.hasData) { - outputList.add(snapshot.data); + Map outputData = jsonDecode(snapshot.data); + if (outputData["containerId"] != null) { + containerId = outputData["containerId"]; + } + if (outputData["output"] != null) { + if (outputData["output"].substring(0,4) == '>>> ') { + outputList.add(outputData["output"].substring(4)); + } else { + outputList.add(outputData["output"]); + } + } } debugPrint('$outputList'); if (!snapshot.hasData) { @@ -438,6 +448,7 @@ class _ReplBodyState extends State { void _sendSubmit() { if (_controller.text.isNotEmpty) { //widget.channel.sink.add(_controller.text); + outputList.add('>>> ' + _controller.text); widget.channel.sink.add( json.encode( {"action": "input", @@ -445,9 +456,7 @@ class _ReplBodyState extends State { } ) ); - prevSubmitList.add(_controller.text); _controller.clear(); - debugPrint('$prevSubmitList'); } } @@ -465,8 +474,8 @@ class _ReplBodyState extends State { class CompilerPage extends StatelessWidget { CompilerPage({Key key, this.name}) : super(key: key); final String name; - final String channelName = 'wss://echo.websocket.org'; // For testing websocket - //final String channelName = 'wss://s4tdw93cwd.execute-api.us-east-1.amazonaws.com/default/'; + //final String channelName = 'wss://echo.websocket.org'; // For testing websocket + final String channelName = 'wss://s4tdw93cwd.execute-api.us-east-1.amazonaws.com/default/'; @override Widget build(BuildContext context) { @@ -525,8 +534,8 @@ class _CompilerBodyState extends State { FocusNode replNode = FocusNode(); bool _firstRun = true; bool _visible = false; - var prevSubmitList = []; var outputList = []; + var containerId = 'none'; @override void initState() { @@ -635,7 +644,14 @@ class _CompilerBodyState extends State { stream: widget.channel.stream, builder: (context, snapshot) { if (snapshot.hasData) { - outputList.add(snapshot.data); + Map outputData = jsonDecode(snapshot.data); + if (outputData["containerId"] != null) { + containerId = outputData["containerId"]; + } + if (outputData["output"] != null) { + outputList.add(outputData["output"]); + } + //outputList.add(snapshot.data); } debugPrint('$outputList'); if (!snapshot.hasData) { @@ -743,8 +759,11 @@ class _CompilerBodyState extends State { else { widget.channel.sink.add( json.encode( - {"action": "input", - "input": _topController.text, + { + "action": "launch", + "lang": widget.name.toLowerCase(), + "mode": "compile", + "prog": _topController.text, } ) ); @@ -756,6 +775,7 @@ class _CompilerBodyState extends State { void _sendSubmit() { if (_bottomController.text.isNotEmpty) { //widget.channel.sink.add(_controller.text); + outputList.add(_bottomController.text); widget.channel.sink.add( json.encode( {"action": "input", @@ -763,9 +783,7 @@ class _CompilerBodyState extends State { } ) ); - prevSubmitList.add(_bottomController.text); _bottomController.clear(); - debugPrint('$prevSubmitList'); } }