From 1cf73be5afc76179ec6c0250918ad732edbf575c Mon Sep 17 00:00:00 2001 From: Viet-Trung Luu Date: Thu, 19 Mar 2015 11:14:56 -0700 Subject: [PATCH] Make the terminal demo able (to try) to connect to anything. (Using the query string from the URL.) R=erg@chromium.org Review URL: https://codereview.chromium.org/1019323002 --- .../src/flutter/examples/terminal/index.sky | 20 ++++++++++++++++++- .../flutter/examples/terminal/terminal.sky | 18 ++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/examples/terminal/index.sky b/engine/src/flutter/examples/terminal/index.sky index 74d56221b9..2244afcedb 100644 --- a/engine/src/flutter/examples/terminal/index.sky +++ b/engine/src/flutter/examples/terminal/index.sky @@ -5,4 +5,22 @@ // found in the LICENSE file. --> - + + + diff --git a/engine/src/flutter/examples/terminal/terminal.sky b/engine/src/flutter/examples/terminal/terminal.sky index 8f964cd218..489e46e5d3 100644 --- a/engine/src/flutter/examples/terminal/terminal.sky +++ b/engine/src/flutter/examples/terminal/terminal.sky @@ -13,9 +13,10 @@ background-color: black; color: rgb(255, 191, 0); font-family: 'Courier', 'monospace'; + font-size: small; } .line { - white-space: pre; + white-space: nowrap; } @@ -60,7 +61,10 @@ class TerminalDisplayImpl extends SkyElement implements TerminalDisplay { // Initialize with the first line. _newLine(); - _connect(getAttribute('url')); + var url = getAttribute('url'); + if (url != null) { + connect(url); + } } void _handleKeyDown(KeyboardEvent event) { @@ -111,15 +115,19 @@ class TerminalDisplayImpl extends SkyElement implements TerminalDisplay { _newLine(); } - // TODO(vtl): Should we always auto-connect? Should there be facilities for - // programmatically connecting? (What if the |url| attribute isn't set?) - void _connect(String url) { + void connect(String url) { var terminalClient = new terminal.TerminalClientProxy.unbound(); embedder.connectToService(url, terminalClient); terminalClient.ptr.connectToTerminal(new TerminalFileImpl(this).stub); terminalClient.close(); } + void putString(String s) { + for (var i = 0; i < s.length; i++) { + putChar(s.codeUnitAt(i)); + } + } + // |TerminalDisplay| implementation: @override