Class DemoShell
A small local shell for demos: line editing, a few commands such as colors and figlet, and a telnet command that hands the terminal to a remote host. Runs in-process through LocalProgramConnection.
Assembly: DarkEffekt.Terminal.Core
Section titled “Assembly: DarkEffekt.Terminal.Core”public sealed class DemoShell : ITerminalProgramImplements:
DarkEffekt.Terminal.ITerminalProgram
Properties
Section titled “Properties”BannerFont
Section titled “BannerFont”The font the figlet command prints its text in. With none, the shell has no figlet command.
public FigletFont BannerFont { get; set; }CurrentLine
Section titled “CurrentLine”The line being edited, for tests and inspection.
public string CurrentLine { get; }CursorPosition
Section titled “CursorPosition”public int CursorPosition { get; }Methods
Section titled “Methods”AddCommand(string, string, Action<string>, string)
Section titled “AddCommand(string, string, Action<string>, string)”Adds a command of your own to the shell. It runs with the rest of the line as its argument, and the help command lists it with its usage in place of its name when given: “demo [NAME]”, arguments in capitals and optional ones in brackets. A command added under the name of one of the shell’s own replaces that one.
public void AddCommand(string name, string help, Action<string> run, string usage = null)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.String |
name |
System.String |
help |
System.Action<System.String> |
run |
System.String |
usage |
AddGroup(string, string)
Section titled “AddGroup(string, string)”Adds a group of commands under one word, such as screen:
each command in it runs as “screen power”, the word alone lists
them, and help lists the group as one line. A group added under
the name of an existing command or group replaces it.
public ShellCommandGroup AddGroup(string name, string help)Returns
Section titled “Returns”DarkEffekt.Terminal.ShellCommandGroup
Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.String |
name |
System.String |
help |
Confirm(string, Action)
Section titled “Confirm(string, Action)”Prints text and waits for a key: Enter runs the action, any other key returns to the prompt. For a command that should say what it is about to do first, such as one that hands the terminal to a game. Call this from a command added with AddCommand.
public void Confirm(string text, Action then)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.String |
text |
System.Action |
then |
Print(string)
Section titled “Print(string)”Writes text to the terminal, for a command added with AddCommand to answer with. End a line with “\r\n”.
public void Print(string text)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.String |
text |
RemoveCommand(string)
Section titled “RemoveCommand(string)”Takes a command out of the shell, one of its own or one added with AddCommand, and out of the help list: exit, say, where the shell should stay. The help command stays.
public void RemoveCommand(string name)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.String |
name |
Start(IProgramHost)
Section titled “Start(IProgramHost)”public void Start(IProgramHost host)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
| DarkEffekt.Terminal.IProgramHost | host |
OnInput(byte[])
Section titled “OnInput(byte[])”public void OnInput(byte[] data)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Byte[] |
data |
Attach(ITerminalConnection)
Section titled “Attach(ITerminalConnection)”Hands the terminal to a connection until it closes or Ctrl-] ends it, as the telnet command does with a host: the connection’s output goes to the screen, and everything typed goes to the connection. The shell opens the connection and disposes it. Call this from a command added with AddCommand.
public void Attach(ITerminalConnection remote)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
| DarkEffekt.Terminal.ITerminalConnection | remote |
OnResize(int, int)
Section titled “OnResize(int, int)”public void OnResize(int cols, int rows)Parameters
Section titled “Parameters”| Type | Name |
|---|---|
System.Int32 |
cols |
System.Int32 |
rows |
Stop()
Section titled “Stop()”public void Stop()