From 64d53aa0fa1255feea5034eef3aaf8ad81d57e6b Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 26 Mar 2015 14:53:38 -0700 Subject: [PATCH] Move terminal example from //sky/examples to //examples We're trying to clean up the //sky/examples directory to focus on mobile use cases for the fn framework. Terminal is both focused on desktop and uses the older custom-element framework. R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/1038813005 --- examples/terminal/README.md | 9 - examples/terminal/index.sky | 26 --- examples/terminal/terminal.sky | 218 ---------------------- examples/terminal/terminal_display.dart | 16 -- examples/terminal/terminal_file_impl.dart | 124 ------------ 5 files changed, 393 deletions(-) delete mode 100644 examples/terminal/README.md delete mode 100644 examples/terminal/index.sky delete mode 100644 examples/terminal/terminal.sky delete mode 100644 examples/terminal/terminal_display.dart delete mode 100644 examples/terminal/terminal_file_impl.dart diff --git a/examples/terminal/README.md b/examples/terminal/README.md deleted file mode 100644 index 3ac0dd29b8..0000000000 --- a/examples/terminal/README.md +++ /dev/null @@ -1,9 +0,0 @@ -Terminal -======== - -This is a prototype "terminal" application that can connect to any Mojo -application (providing the |terminal.TerminalClient| interface) and provide -interactive terminal facilities via an implementation of |mojo.files.File|. -I.e., once connected, the application can write to/read from the terminal by -performing the corresponding operations on a "file" (thus replicating -decades-old technology, poorly). diff --git a/examples/terminal/index.sky b/examples/terminal/index.sky deleted file mode 100644 index 2244afcedb..0000000000 --- a/examples/terminal/index.sky +++ /dev/null @@ -1,26 +0,0 @@ -#!mojo mojo:sky_viewer - - - - - diff --git a/examples/terminal/terminal.sky b/examples/terminal/terminal.sky deleted file mode 100644 index 246bdfccf6..0000000000 --- a/examples/terminal/terminal.sky +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - diff --git a/examples/terminal/terminal_display.dart b/examples/terminal/terminal_display.dart deleted file mode 100644 index c932825dcd..0000000000 --- a/examples/terminal/terminal_display.dart +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; - -// Interface for a terminal display, able to accept bytes (from the computer) -// and typically displaying them (or possibly handling them as escape codes, -// etc.) and able to get bytes from the "user". -abstract class TerminalDisplay { - void putChar(int byte); - Future getChar(); - - // TODO(vtl): Should probably also have facilities for putting many bytes at a - // time or getting as many bytes as available. -} diff --git a/examples/terminal/terminal_file_impl.dart b/examples/terminal/terminal_file_impl.dart deleted file mode 100644 index 041765a8c4..0000000000 --- a/examples/terminal/terminal_file_impl.dart +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:core'; -import 'package:mojo/public/dart/core.dart'; -import 'package:mojo/services/files/public/interfaces/file.mojom.dart' as files; -import 'package:mojo/services/files/public/interfaces/types.mojom.dart' as files; - -import 'terminal_display.dart'; - -// This implements a |mojo.files.File| that acts like a (pseudo)terminal. Bytes -// written to the |File| will be read by this implementation and passed on to -// the (Dart) |TerminalDisplay| (using |putChar()|). A read from the |File| will -// be completed if/when |TerminalDisplay| makes a byte available (via -// |getChar()|). -// TODO(vtl): This implementation is very incomplete. -class TerminalFileImpl implements files.File { - final files.FileStub stub; - final TerminalDisplay _display; - - TerminalFileImpl(this._display) : stub = new files.FileStub.unbound() { - stub.impl = this; - } - - // |files.File| implementation: - - @override - Future close(Function responseFactory) async { - // TODO(vtl): We should probably do more than just say OK. - return responseFactory(files.Error_OK); - } - - @override - Future read(int numBytesToRead, int offset, int whence, - Function responseFactory) async { - if (numBytesToRead < 0) { - return responseFactory(files.Error_INVALID_ARGUMENT, null); - } - - // TODO(vtl): Error if |offset|/|whence| not appropriate. - - if (numBytesToRead == 0) { - return responseFactory(files.Error_OK, []); - } - - return responseFactory(files.Error_OK, [await _display.getChar()]); - } - - @override - Future write(List bytesToWrite, int offset, int whence, - Function responseFactory) async { - // TODO(vtl): Error if |offset|/|whence| not appropriate. - - for (var c in bytesToWrite) { - _display.putChar(c); - } - return responseFactory(files.Error_OK, bytesToWrite.length); - } - - @override - Future readToStream(MojoDataPipeProducer source, int offset, int whence, - int numBytesToRead, Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future writeFromStream(MojoDataPipeConsumer sink, int offset, int whence, - Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future tell(Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED, 0); - } - - @override - Future seek(int offset, int whence, Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED, 0); - } - - @override - Future stat(Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED, null); - } - - @override - Future truncate(int size, Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future touch(files.TimespecOrNow atime, files.TimespecOrNow mtime, - Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future dup(Object file, Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future reopen(Object file, int openFlags, Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED); - } - - @override - Future asBuffer(Function responseFactory) async { - // TODO(vtl) - return responseFactory(files.Error_UNIMPLEMENTED, null); - } -}