Import std.term.terminal
FakeTerminal
class
Public Class FakeTerminal Extends Terminal
A Terminal for tests: it keeps everything written to it, which Output gives, and TakeOutput what's new, and gives what it's fed as keys, as a terminal would send them, then the end of the input. It's the size, colors, and kind it's made with, until a Resize.
Examples
Local terminal = FakeTerminal(40, 10)
terminal.WriteLine("hello")
Expect(terminal.TakeOutput() == "hello\n")
terminal.Feed("q")
Expect(terminal.ReadKey()?.IsChar('q') == True)
Expect(terminal.ReadKey() == Null)std/term/terminal.fb, line 402
-
Public New(columns: Int = 80, rows: Int = 24, colors: ColorLevel = ColorLevel.TRUE_COLOR, interactive: Bool = True)constructor #A terminal of
columnsandrowsthat shows the colorscolorssays, and isinteractive, as a terminal is, or not, as a pipe or a file is, for both what's written and keys. -
How many columns wide it is, as it was made or last resized.
-
How many rows high it is, as it was made or last resized.
-
The colors it shows, as it was made.
-
Whether it's interactive, as it was made, as a terminal is, rather than a pipe or a file.
-
Whether its input is interactive, which is as IsInteractive is.
-
Everything written to it.
-
What's been written since the last TakeOutput.
-
How many times it's been flushed.
-
The input mode it was last given: 0 for none, or 1 for raw, plus 2 for Ctrl+C as a key, and 4 for the mouse.
-
What the console would write to put the screen back, were the program to end now.
-
Takes
text's bytes as if they were typed, after what's fed before. Bytes fed one after another come as one, as a terminal's do when they're sent at once. -
Changes its size, after what's fed before, as a resize event says.
-
A pause after what's fed before, as when nothing is typed for a while: what's waiting for more, like an escape alone, is what it is, and a read that waits for a time gives nothing, as at its timeout. One that waits for as long as it takes goes on to what's after.
-
A pause of time after what's fed before: a read that waits that long or less gives nothing, as at its timeout, and leaves what's left of the pause, and one that waits longer goes on to what's after, as when the rest of a sequence or a paste comes a little late.
-
Keeps
text, which Output and TakeOutput give. -
Counts the flush, which Flushes gives.
-
Gives what was fed next in
into, and how many bytes; -1 at the end of what was fed; -2 for a Resize, once its size has changed; or after waiting through a Pause, 0 whentimeoutends before it. -
Keeps
mode, which InputMode gives. -
Keeps
leave, what leaves the alternate screen, which Leave gives.
Report an issue with this page or with FutureBlitz on GitHub.