SystemTerminal class
Namespace: Arlecchino · Assembly: Arlecchino.Core
The real console, registered by default and replaceable through UseTerminal<T>(). On Windows it turns virtual terminal output on, virtual terminal input off, and borrows Ctrl+C while it has the terminal.
public sealed class SystemTerminal : IArlecchinoTerminal
Implements IArlecchinoTerminal
Constructors
| Member | Summary |
|---|---|
SystemTerminal() | Prepares the console: UTF-8 output, hidden cursor, and escape sequences where the platform allows them. A console that refuses them drops color to ColorSupport.None. |
Properties
| Member | Summary |
|---|---|
Height | Window height, or a fixed height when output is redirected. |
KeyAvailable | Whether a key is waiting, and always false when input is redirected. With the Windows mouse on, the answer comes from the console's own event queue. |
MouseAvailable | Whether a mouse event is waiting. Only ever true while the Windows mouse is on. |
Width | Window width, or a fixed width when output is redirected. |
Methods
| Member | Summary |
|---|---|
CopyToClipboard(string) | Copies through the terminal as base64, the only way to the clipboard of whoever is watching a remote session, and then through ClipboardPrograms, which a silent terminal is not. |
DisableMouse() | Stops mouse reporting and gives the console back the mode it had. |
DisablePaste() | Turns bracketed paste off again. |
EnableMouse() | Starts reporting presses, releases, drags and the wheel: as SGR reports in the key stream, or record by record on Windows. Quick-edit mode is turned off while this is on. |
EnablePaste() | Turns on bracketed paste. Terminals that do not know the mode ignore it. |
EnterFullScreen() | Switches to the alternate screen and hides the cursor. The keyboard protocol is left unasked for, since asking it moves the function keys onto sequences the runtime reads as other keys. |
GiveBackControlKeys() | Gives Ctrl+C back to the console, which the shell and any program the terminal is lent to expect to have it. Doing so twice, or without having taken it, changes nothing. |
LeaveFullScreen() | Returns to the normal screen and makes the cursor visible again. |
ReadKey() | Takes the next key without echoing it. |
ReadMouse() | Takes the next mouse event read from the console's event queue. |
TakeControlKeys() | Takes Ctrl+C off the Windows console, which raises it as a signal — and raises the same signal for Ctrl+Shift+C, since both type the same character. Whether it was the console's is remembered, so it is given back as found. |
Unread(KeyPress) | Puts a key back, so the next read returns it. |
Write(string) | Writes a composed frame, and everything else this terminal says, through the one writer it was given — or the console's own, when it was given none. |
Constructors in detail
SystemTerminal()
public SystemTerminal();
Prepares the console: UTF-8 output, hidden cursor, and escape sequences where the platform allows them. A console that refuses them drops color to ColorSupport.None.
Properties in detail
Height
public int Height { get; }
Window height, or a fixed height when output is redirected.
Type int
KeyAvailable
public bool KeyAvailable { get; }
Whether a key is waiting, and always false when input is redirected. With the Windows mouse on, the answer comes from the console's own event queue.
Type bool
MouseAvailable
public bool MouseAvailable { get; }
Whether a mouse event is waiting. Only ever true while the Windows mouse is on.
Type bool
Width
public int Width { get; }
Window width, or a fixed width when output is redirected.
Type int
Methods in detail
CopyToClipboard(string)
public void CopyToClipboard(string text);
Copies through the terminal as base64, the only way to the clipboard of whoever is watching a remote session, and then through ClipboardPrograms, which a silent terminal is not.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | What to copy. |
DisableMouse()
public void DisableMouse();
Stops mouse reporting and gives the console back the mode it had.
DisablePaste()
public void DisablePaste();
Turns bracketed paste off again.
EnableMouse()
public void EnableMouse();
Starts reporting presses, releases, drags and the wheel: as SGR reports in the key stream, or record by record on Windows. Quick-edit mode is turned off while this is on.
EnablePaste()
public void EnablePaste();
Turns on bracketed paste. Terminals that do not know the mode ignore it.
EnterFullScreen()
public void EnterFullScreen();
Switches to the alternate screen and hides the cursor. The keyboard protocol is left unasked for, since asking it moves the function keys onto sequences the runtime reads as other keys.
GiveBackControlKeys()
public void GiveBackControlKeys();
Gives Ctrl+C back to the console, which the shell and any program the terminal is lent to expect to have it. Doing so twice, or without having taken it, changes nothing.
LeaveFullScreen()
public void LeaveFullScreen();
Returns to the normal screen and makes the cursor visible again.
ReadKey()
public KeyPress ReadKey();
Takes the next key without echoing it.
Returns KeyPress — The key that was pressed.
ReadMouse()
public MouseEvent ReadMouse();
Takes the next mouse event read from the console's event queue.
Returns MouseEvent — What the mouse did, in frame cells.
Exceptions
| Type | Thrown when |
|---|---|
InvalidOperationException | The mouse is not being read on this platform. |
TakeControlKeys()
public void TakeControlKeys();
Takes Ctrl+C off the Windows console, which raises it as a signal — and raises the same signal for Ctrl+Shift+C, since both type the same character. Whether it was the console's is remembered, so it is given back as found.
Unread(KeyPress)
public void Unread(KeyPress key);
Puts a key back, so the next read returns it.
Parameters
| Name | Type | Description |
|---|---|---|
key | KeyPress | The key to put back. |
Write(string)
public void Write(string text);
Writes a composed frame, and everything else this terminal says, through the one writer it was given — or the console's own, when it was given none.
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Text with escape sequences already embedded. |