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

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

Issue 102123010: Add getter for hasTerminal, terminalColumns and terminalLines on stdout. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add include of thread.h and fix io_patch. Created 7 years 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_android.cc ('k') | runtime/bin/stdin_macos.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_LINUX)
7
8 #include <termios.h> // NOLINT
9
10 #include "bin/stdin.h"
11 #include "bin/fdutils.h"
12
13
14 namespace dart {
15 namespace bin {
16
17 int Stdin::ReadByte() {
18 FDUtils::SetBlocking(fileno(stdin));
19 int c = getchar();
20 if (c == EOF) {
21 c = -1;
22 }
23 FDUtils::SetNonBlocking(fileno(stdin));
24 return c;
25 }
26
27
28 bool Stdin::GetEchoMode() {
29 struct termios term;
30 tcgetattr(fileno(stdin), &term);
31 return (term.c_lflag & ECHO) != 0;
32 }
33
34
35 void Stdin::SetEchoMode(bool enabled) {
36 struct termios term;
37 tcgetattr(fileno(stdin), &term);
38 if (enabled) {
39 term.c_lflag |= ECHO|ECHONL;
40 } else {
41 term.c_lflag &= ~(ECHO|ECHONL);
42 }
43 tcsetattr(fileno(stdin), TCSANOW, &term);
44 }
45
46
47 bool Stdin::GetLineMode() {
48 struct termios term;
49 tcgetattr(fileno(stdin), &term);
50 return (term.c_lflag & ICANON) != 0;
51 }
52
53
54 void Stdin::SetLineMode(bool enabled) {
55 struct termios term;
56 tcgetattr(fileno(stdin), &term);
57 if (enabled) {
58 term.c_lflag |= ICANON;
59 } else {
60 term.c_lflag &= ~(ICANON);
61 }
62 tcsetattr(fileno(stdin), TCSANOW, &term);
63 }
64
65 } // namespace bin
66 } // namespace dart
67
68 #endif // defined(TARGET_OS_LINUX)
69
OLDNEW
« no previous file with comments | « runtime/bin/stdin_android.cc ('k') | runtime/bin/stdin_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698