Ejemplo n.º 1
0
 public void Dispose()
 {
     Stream.Dispose();
     if (_currentMode != _oldMode)
     {
         if (Win32ConsoleInterop.SetConsoleMode(_handle, _oldMode))
         {
             _currentMode = _oldMode;
         }
     }
 }
Ejemplo n.º 2
0
        public void EnableRawInputMode()
        {
            if (Direction != ConsoleDirection.In)
            {
                throw new InvalidOperationException("cannot set raw mode on output handle");
            }

            // Put the console in character mode with no input processing.
            var newMode = _currentMode & ~(Win32ConsoleInterop.ENABLE_PROCESSED_INPUT |
                                           Win32ConsoleInterop.ENABLE_LINE_INPUT |
                                           Win32ConsoleInterop.ENABLE_ECHO_INPUT |
                                           Win32ConsoleInterop.ENABLE_MOUSE_INPUT);

            if (!Win32ConsoleInterop.SetConsoleMode(_handle, newMode))
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            _currentMode = newMode;
        }
Ejemplo n.º 3
0
        public void EnableVTMode()
        {
            int newMode;

            if (Direction == ConsoleDirection.Out)
            {
                // Put the console in character mode with no input processing.
                newMode = _currentMode | Win32ConsoleInterop.ENABLE_PROCESSED_OUTPUT | Win32ConsoleInterop.ENABLE_VIRTUAL_TERMINAL_PROCESSING | Win32ConsoleInterop.DISABLE_NEWLINE_AUTO_RETURN;
            }
            else
            {
                newMode = _currentMode | Win32ConsoleInterop.ENABLE_VIRTUAL_TERMINAL_INPUT;
            }

            if (!Win32ConsoleInterop.SetConsoleMode(_handle, newMode))
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            _currentMode = newMode;
        }