IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Java.Externs.java.io.Console Class Reference

Static Public Member Functions

static string encoding ()
 
static bool echo (bool on)
 
static bool istty ()
 

Detailed Description

Definition at line 30 of file Console.cs.

Member Function Documentation

◆ echo()

static bool IKVM.Java.Externs.java.io.Console.echo ( bool on)
static

Definition at line 63 of file Console.cs.

64 {
65#if !FIRST_PASS
66 // HACK the only way to get this to work is by p/invoking the Win32 APIs
67 if (Environment.OSVersion.Platform == PlatformID.Win32NT)
68 {
69 IntPtr hStdIn = GetStdHandle(STD_INPUT_HANDLE);
70 if (hStdIn.ToInt64() == 0 || hStdIn.ToInt64() == -1)
71 {
72 throw new global::java.io.IOException("The handle is invalid");
73 }
74 int fdwMode;
75 if (GetConsoleMode(hStdIn, out fdwMode) == 0)
76 {
77 throw new global::java.io.IOException("GetConsoleMode failed");
78 }
79 bool old = (fdwMode & ENABLE_ECHO_INPUT) != 0;
80 if (on)
81 {
82 fdwMode |= ENABLE_ECHO_INPUT;
83 }
84 else
85 {
86 fdwMode &= ~ENABLE_ECHO_INPUT;
87 }
88 if (SetConsoleMode(hStdIn, fdwMode) == 0)
89 {
90 throw new global::java.io.IOException("SetConsoleMode failed");
91 }
92 return old;
93 }
94#endif
95 return true;
96 }

◆ encoding()

static string IKVM.Java.Externs.java.io.Console.encoding ( )
static

Definition at line 33 of file Console.cs.

34 {
35 int cp = 437;
36 try
37 {
38 cp = System.Console.InputEncoding.CodePage;
39 }
40 catch
41 {
42
43 }
44
45 if (cp >= 874 && cp <= 950)
46 return "ms" + cp;
47
48 return "cp" + cp;
49 }

◆ istty()

static bool IKVM.Java.Externs.java.io.Console.istty ( )
static

Definition at line 98 of file Console.cs.

99 {
100 // The JDK returns false here if stdin or stdout (not stderr) is redirected to a file
101 // or if there is no console associated with the current process.
102 // The best we can do is to look at the KeyAvailable property, which
103 // will throw an InvalidOperationException if stdin is redirected or not available
104 try
105 {
106 return System.Console.KeyAvailable || true;
107 }
108 catch (InvalidOperationException)
109 {
110 return false;
111 }
112 }

The documentation for this class was generated from the following file: