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

Unified Diff: runtime/bin/stdin.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 missing files. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/stdin.cc
diff --git a/runtime/bin/stdin.cc b/runtime/bin/stdin.cc
index 6dba2130ad8e9526c2fe8b4092ebf565038e828c..2c2ebde8c896b754214ce086f6c1b191311f399e 100644
--- a/runtime/bin/stdin.cc
+++ b/runtime/bin/stdin.cc
@@ -4,8 +4,8 @@
#include "bin/builtin.h"
#include "bin/dartutils.h"
-#include "bin/thread.h"
#include "bin/utils.h"
+#include "bin/stdin.h"
#include "platform/globals.h"
#include "platform/thread.h"
@@ -19,11 +19,25 @@ namespace bin {
void FUNCTION_NAME(Stdin_ReadByte)(Dart_NativeArguments args) {
Dart_EnterScope();
- int c = getchar();
- if (c == EOF) {
- c = -1;
- }
- Dart_SetReturnValue(args, Dart_NewInteger(c));
+ Dart_SetReturnValue(args, Dart_NewInteger(Stdin::ReadByte()));
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(Stdin_SetEchoMode)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ bool enabled = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1));
+ Stdin::setEchoMode(enabled);
+ Dart_SetReturnValue(args, Dart_Null());
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(Stdin_SetLineMode)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ bool enabled = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1));
+ Stdin::setLineMode(enabled);
+ Dart_SetReturnValue(args, Dart_Null());
Dart_ExitScope();
}

Powered by Google App Engine
This is Rietveld 408576698