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

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

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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
« no previous file with comments | « runtime/bin/stdio_unsupported.cc ('k') | runtime/bin/sync_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_WINDOWS) 8 #if defined(HOST_OS_WINDOWS)
9 9
10 #include "bin/stdio.h" 10 #include "bin/stdio.h"
(...skipping 16 matching lines...) Expand all
27 uint8_t buffer[1]; 27 uint8_t buffer[1];
28 DWORD read = 0; 28 DWORD read = 0;
29 BOOL success = ReadFile(h, buffer, 1, &read, NULL); 29 BOOL success = ReadFile(h, buffer, 1, &read, NULL);
30 if (!success && (GetLastError() != ERROR_BROKEN_PIPE)) { 30 if (!success && (GetLastError() != ERROR_BROKEN_PIPE)) {
31 return false; 31 return false;
32 } 32 }
33 *byte = (read == 1) ? buffer[0] : -1; 33 *byte = (read == 1) ? buffer[0] : -1;
34 return true; 34 return true;
35 } 35 }
36 36
37
38 bool Stdin::GetEchoMode(bool* enabled) { 37 bool Stdin::GetEchoMode(bool* enabled) {
39 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 38 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
40 DWORD mode; 39 DWORD mode;
41 if (!GetConsoleMode(h, &mode)) { 40 if (!GetConsoleMode(h, &mode)) {
42 return false; 41 return false;
43 } 42 }
44 *enabled = ((mode & ENABLE_ECHO_INPUT) != 0); 43 *enabled = ((mode & ENABLE_ECHO_INPUT) != 0);
45 return true; 44 return true;
46 } 45 }
47 46
48
49 bool Stdin::SetEchoMode(bool enabled) { 47 bool Stdin::SetEchoMode(bool enabled) {
50 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 48 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
51 DWORD mode; 49 DWORD mode;
52 if (!GetConsoleMode(h, &mode)) { 50 if (!GetConsoleMode(h, &mode)) {
53 return false; 51 return false;
54 } 52 }
55 if (enabled) { 53 if (enabled) {
56 mode |= ENABLE_ECHO_INPUT; 54 mode |= ENABLE_ECHO_INPUT;
57 } else { 55 } else {
58 mode &= ~ENABLE_ECHO_INPUT; 56 mode &= ~ENABLE_ECHO_INPUT;
59 } 57 }
60 return SetConsoleMode(h, mode); 58 return SetConsoleMode(h, mode);
61 } 59 }
62 60
63
64 bool Stdin::GetLineMode(bool* enabled) { 61 bool Stdin::GetLineMode(bool* enabled) {
65 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 62 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
66 DWORD mode; 63 DWORD mode;
67 if (!GetConsoleMode(h, &mode)) { 64 if (!GetConsoleMode(h, &mode)) {
68 return false; 65 return false;
69 } 66 }
70 *enabled = (mode & ENABLE_LINE_INPUT) != 0; 67 *enabled = (mode & ENABLE_LINE_INPUT) != 0;
71 return true; 68 return true;
72 } 69 }
73 70
74
75 bool Stdin::SetLineMode(bool enabled) { 71 bool Stdin::SetLineMode(bool enabled) {
76 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 72 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
77 DWORD mode; 73 DWORD mode;
78 if (!GetConsoleMode(h, &mode)) { 74 if (!GetConsoleMode(h, &mode)) {
79 return false; 75 return false;
80 } 76 }
81 if (enabled) { 77 if (enabled) {
82 mode |= ENABLE_LINE_INPUT; 78 mode |= ENABLE_LINE_INPUT;
83 } else { 79 } else {
84 mode &= ~ENABLE_LINE_INPUT; 80 mode &= ~ENABLE_LINE_INPUT;
85 } 81 }
86 return SetConsoleMode(h, mode); 82 return SetConsoleMode(h, mode);
87 } 83 }
88 84
89
90 bool Stdin::AnsiSupported(bool* supported) { 85 bool Stdin::AnsiSupported(bool* supported) {
91 ASSERT(supported != NULL); 86 ASSERT(supported != NULL);
92 HANDLE h = GetStdHandle(STD_INPUT_HANDLE); 87 HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
93 if (h == INVALID_HANDLE_VALUE) { 88 if (h == INVALID_HANDLE_VALUE) {
94 *supported = false; 89 *supported = false;
95 return true; 90 return true;
96 } 91 }
97 DWORD mode; 92 DWORD mode;
98 if (!GetConsoleMode(h, &mode)) { 93 if (!GetConsoleMode(h, &mode)) {
99 *supported = false; 94 *supported = false;
100 return true; 95 return true;
101 } 96 }
102 *supported = (mode & ENABLE_VIRTUAL_TERMINAL_INPUT) != 0; 97 *supported = (mode & ENABLE_VIRTUAL_TERMINAL_INPUT) != 0;
103 return true; 98 return true;
104 } 99 }
105 100
106
107 bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) { 101 bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
108 HANDLE h; 102 HANDLE h;
109 if (fd == 1) { 103 if (fd == 1) {
110 h = GetStdHandle(STD_OUTPUT_HANDLE); 104 h = GetStdHandle(STD_OUTPUT_HANDLE);
111 } else { 105 } else {
112 h = GetStdHandle(STD_ERROR_HANDLE); 106 h = GetStdHandle(STD_ERROR_HANDLE);
113 } 107 }
114 CONSOLE_SCREEN_BUFFER_INFO info; 108 CONSOLE_SCREEN_BUFFER_INFO info;
115 if (!GetConsoleScreenBufferInfo(h, &info)) { 109 if (!GetConsoleScreenBufferInfo(h, &info)) {
116 return false; 110 return false;
117 } 111 }
118 size[0] = info.srWindow.Right - info.srWindow.Left + 1; 112 size[0] = info.srWindow.Right - info.srWindow.Left + 1;
119 size[1] = info.srWindow.Bottom - info.srWindow.Top + 1; 113 size[1] = info.srWindow.Bottom - info.srWindow.Top + 1;
120 return true; 114 return true;
121 } 115 }
122 116
123
124 bool Stdout::AnsiSupported(intptr_t fd, bool* supported) { 117 bool Stdout::AnsiSupported(intptr_t fd, bool* supported) {
125 ASSERT(supported != NULL); 118 ASSERT(supported != NULL);
126 HANDLE h; 119 HANDLE h;
127 if (fd == 1) { 120 if (fd == 1) {
128 h = GetStdHandle(STD_OUTPUT_HANDLE); 121 h = GetStdHandle(STD_OUTPUT_HANDLE);
129 } else { 122 } else {
130 h = GetStdHandle(STD_ERROR_HANDLE); 123 h = GetStdHandle(STD_ERROR_HANDLE);
131 } 124 }
132 if (h == INVALID_HANDLE_VALUE) { 125 if (h == INVALID_HANDLE_VALUE) {
133 *supported = false; 126 *supported = false;
134 return true; 127 return true;
135 } 128 }
136 DWORD mode; 129 DWORD mode;
137 if (!GetConsoleMode(h, &mode)) { 130 if (!GetConsoleMode(h, &mode)) {
138 *supported = false; 131 *supported = false;
139 return true; 132 return true;
140 } 133 }
141 *supported = (mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0; 134 *supported = (mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
142 return true; 135 return true;
143 } 136 }
144 137
145 } // namespace bin 138 } // namespace bin
146 } // namespace dart 139 } // namespace dart
147 140
148 #endif // defined(HOST_OS_WINDOWS) 141 #endif // defined(HOST_OS_WINDOWS)
149 142
150 #endif // !defined(DART_IO_DISABLED) 143 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/stdio_unsupported.cc ('k') | runtime/bin/sync_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698