Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: runtime/bin/stdin_android.cc

Issue 19627004: Add echo and line modes to Stdin. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add macos and android version. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/stdin.cc ('k') | runtime/bin/stdin_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID)
7
8 #include <termios.h> // NOLINT
9
10 #include "bin/stdin.h"
11
12
13 namespace dart {
14 namespace bin {
15
16 int Stdin::ReadByte() {
17 int c = getchar();
18 if (c == EOF) {
19 c = -1;
20 }
21 return c;
22 }
23
24
25 void Stdin::SetEchoMode(bool enabled) {
26 struct termios term;
27 tcgetattr(fileno(stdin), &term);
28 if (enabled) {
29 term.c_lflag |= ECHO|ECHONL;
30 } else {
31 term.c_lflag &= ~(ECHO|ECHONL);
32 }
33 tcsetattr(fileno(stdin), TCSANOW, &term);
34 }
35
36
37 void Stdin::SetLineMode(bool enabled) {
38 struct termios term;
39 tcgetattr(fileno(stdin), &term);
40 if (enabled) {
41 term.c_lflag |= ICANON;
42 } else {
43 term.c_lflag &= ~(ICANON);
44 }
45 tcsetattr(fileno(stdin), TCSANOW, &term);
46 }
47
48 } // namespace bin
49 } // namespace dart
50
51 #endif // defined(TARGET_OS_ANDROID)
52
OLDNEW
« no previous file with comments | « runtime/bin/stdin.cc ('k') | runtime/bin/stdin_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698