Ejemplo n.º 1
0
        public FormRenderer(IConsoleDriver consoleDriver, bool cursorVisible = true)
        {
            _consoleDriver = consoleDriver;
            _cursorVisible = cursorVisible;

            _offscreenBuffer = new OffscreenBuffer(_consoleDriver);
        }
Ejemplo n.º 2
0
        static ConsoleDriver()
        {
            // Put the actual new statements into separate methods to avoid initalizing
            // three classes when only one is needed.
            if (!IsConsole)
            {
                driver = CreateNullConsoleDriver();
            }
            else if (Environment.IsRunningOnWindows)
            {
                driver = CreateWindowsConsoleDriver();
            }
            else
            {
                string term = Environment.GetEnvironmentVariable("TERM");

                // Perhaps we should let the Terminfo driver return a
                // success/failure flag based on the terminal properties
                if (term == "dumb")
                {
                    is_console = false;
                    driver     = CreateNullConsoleDriver();
                }
                else
                {
                    driver = CreateTermInfoDriver(term);
                }
            }
        }
Ejemplo n.º 3
0
 public static TPage StartWith <TPage>(IConsoleDriver driver)
     where TPage : Page, new()
 {
     return(new TPage {
         Driver = driver
     });
 }
Ejemplo n.º 4
0
        public void Flush(IConsoleDriver consoleDriver)
        {
            var idx = 0;

            for (var row = 0; row < Height; row++)
            {
                var span     = 1;
                var spanning = false;
                var spanCol  = 0;
                for (var col = 0; col < Width; col++)
                {
                    var next = col < Width - 1 ? _buffer[idx + 1] : null;
                    var cc   = _buffer[idx];
                    if (spanning || _dirtyMap[idx] != DirtyStatus.Clean)
                    {
                        if (cc.Equals(next))
                        {
                            span++;
                            spanning = true;
                        }
                        else
                        {
                            consoleDriver.WriteCharactersAt(spanCol, row, span, cc.Character, cc.Attributes);
                            span     = 1;
                            spanning = false;
                            spanCol  = col + 1;
                        }
                    }
                    else
                    {
                        spanCol++;
                    }
                    _dirtyMap[idx] = DirtyStatus.Clean;
                    idx++;
                }
            }


            if (Cursor.ActionPending == VirtualConsoleCursorAction.Show)
            {
                consoleDriver.SetCursorVisibility(isVisible: true);
                Cursor.VisibilityChanged(isVisible: true);
            }

            if (Cursor.MovementPending)
            {
                consoleDriver.SetCursorAt(Cursor.Position.Left, Cursor.Position.Top);
                Cursor.MovementPending = false;
            }
            else if (Cursor.ActionPending == VirtualConsoleCursorAction.Hide)
            {
                consoleDriver.SetCursorVisibility(isVisible: false);
                Cursor.VisibilityChanged(isVisible: false);
            }


            IsDirty = false;
        }
Ejemplo n.º 5
0
        public RenderScope(OffscreenBuffer offscreenBuffer, IConsoleDriver consoleDriver, int cursorBottom, int writtenLineCount)
        {
            _offscreenBuffer  = offscreenBuffer;
            _consoleDriver    = consoleDriver;
            _cursorBottom     = cursorBottom;
            _writtenLineCount = writtenLineCount;

            _offscreenBuffer.ClearBuffer();
        }
Ejemplo n.º 6
0
        public PageTests()
        {
            capture = Substitute.For <ICaptureOutput>();
            driver  = Substitute.For <IConsoleDriver>();
            driver
            .Output
            .Returns(capture);

            driver
            .Keyboard
            .Returns(Substitute.For <IKeyboardSimulator>());
        }
Ejemplo n.º 7
0
        public static IConsoleDriver SetDriver
        (
            [NotNull] IConsoleDriver driver
        )
        {
            Code.NotNull(driver, "driver");

            IConsoleDriver previousDriver = _driver;

            _driver = driver;

            return(previousDriver);
        }
Ejemplo n.º 8
0
 static ConsoleDriver()
 {
     if (!IsConsole)
     {
         driver = new NullConsoleDriver();
     }
     else if (Environment.IsRunningOnWindows)
     {
         driver = new WindowsConsoleDriver();
     }
     else
     {
         driver = new TermInfoDriver(Environment.GetEnvironmentVariable("TERM"));
     }
 }
Ejemplo n.º 9
0
        public static void Initialize(bool alreadyActive)
        {
            if (PlatformHelper.Is(Platform.MacOS) || PlatformHelper.Is(Platform.Linux))
            {
                Driver = new LinuxConsoleDriver();
            }
            else if (PlatformHelper.Is(Platform.Windows))
            {
                Driver = new WindowsConsoleDriver();
            }
            else
            {
                throw new PlatformNotSupportedException("Was unable to determine console driver for platform " + PlatformHelper.Current);
            }

            Driver.Initialize(alreadyActive);
        }
Ejemplo n.º 10
0
		static ConsoleDriver ()
		{
			// Put the actual new statements into separate methods to avoid initalizing
			// three classes when only one is needed.
			if (!IsConsole) {
				driver = CreateNullConsoleDriver ();
			} else if (Environment.IsRunningOnWindows) {
				driver = CreateWindowsConsoleDriver ();
			} else {
				string term = Environment.GetEnvironmentVariable ("TERM");

				// Perhaps we should let the Terminfo driver return a
				// success/failure flag based on the terminal properties
				if (term == "dumb"){
					is_console = false;
					driver = CreateNullConsoleDriver ();
				} else
					driver = CreateTermInfoDriver (term);
			}
		}
Ejemplo n.º 11
0
        public static void Initialize(bool alreadyActive)
        {
            switch (Utility.CurrentOs)
            {
            case Platform.MacOS:
            case Platform.Linux:
            {
                Driver = new LinuxConsoleDriver();
                break;
            }

            case Platform.Windows:
            {
                Driver = new WindowsConsoleDriver();
                break;
            }
            }

            Driver.Initialize(alreadyActive);
        }
Ejemplo n.º 12
0
 public EventPumper(IConsoleDriver console) => _console = console;
Ejemplo n.º 13
0
 public ScreenBuffer(IConsoleDriver consoleDriver)
 {
     _consoleDriver = consoleDriver;
 }
Ejemplo n.º 14
0
 ITvision2Options ITvision2Options.UseConsoleDriver(IConsoleDriver driverToUse)
 {
     ConsoleDriver = driverToUse;
     return(this);
 }
Ejemplo n.º 15
0
 public WindowResizedHook(IConsoleDriver driver)
 {
     _driver = driver;
 }
Ejemplo n.º 16
0
        public OffscreenBuffer(IConsoleDriver consoleDriver)
        {
            _consoleDriver = consoleDriver;

            _cursorBottom = _consoleDriver.CursorTop;
        }
 public static TPage StartWith <TPage>(this IConsoleDriver driver)
     where TPage : Page, new()
 {
     return(Page.StartWith <TPage>(driver));
 }
 public static IConsoleDriver Sleep(this IConsoleDriver driver, int milliseconds)
 {
     Thread.Sleep(milliseconds);
     return(driver);
 }
Ejemplo n.º 19
0
 public ViewportFactory(IConsoleDriver console)
 {
     _console = console;
 }
Ejemplo n.º 20
0
 public FormRenderer(IConsoleDriver consoleDriver)
 {
     _offscreenBuffer = new OffscreenBuffer(consoleDriver);
 }