C# Class kOS.Screen.TermWindow

Inheritance: UnityEngine.MonoBehaviour
Show file Open project: KSP-KOS/KOS Class Usage Examples

Public Methods

Method Description
Awake ( ) : void
ClearScreen ( ) : void
Close ( ) : void
DetachAllTelnets ( ) : void
GetFocus ( ) : void
GetRect ( ) : Rect
GetSoundMaker ( ) : kOS.Safe.Sound.ISoundMaker
LoadTexture ( String relativePath, Texture2D &targetTexture ) : void
LoseFocus ( ) : void
NumTelnets ( ) : int
OnDestroy ( ) : void
Open ( ) : void
OpenPopupEditor ( kOS.Persistence.Volume v, GlobalPath path ) : void
Print ( string str ) : void
ProcessOneInputChar ( char ch, TelnetSingletonServer whichTelnet, bool doQueuing = true ) : void

Respond to one single input character in Unicode, using the pretend virtual Unicode terminal keycodes described in the UnicodeCommand enum. To keep things simple, all key input is coerced into single Unicode chars even if the actual keypress takes multiple characters to express in its native form (i.e. ESC [ A means left-arrow on a VT100 terminal. If a telnet is talking via VT100 codes, that ESC [ A will get converted into a single UnicdeCommand.LEFTCURSORONE character before being sent here.)
This method is public because it is also how other mods should send input to the terminal if they want some other source to send simulated keystrokes.

TermWindow ( ) : System
Toggle ( ) : void

Protected Methods

Method Description
AdjustColor ( Color baseColor, float brightness ) : Color
CheckResizeDrag ( ) : void
DrawTelnetStatus ( ) : void

Draw a little status line at the bottom as a reminder that you are sharing the terminal with a telnet session:

Private Methods

Method Description
AttachTelnet ( TelnetSingletonServer server ) : void
AttachTo ( SharedObjects sharedObj ) : void
Beep ( ) : bool

Attempts to make Unity start a playthrough of the beep audio clip. The playthrough will continue on its own in the background while the rest of the code continues on. It will do nothing if the previous beep is still being played. (We only gave ourselves one audio beep source per GUI terminal so we can't play beeps simultaneously.)
Addendum: It will redirect into a visual beep if that is called for instead.

BuildPanelSkin ( ) : GUISkin
CalcualteTitle ( ) : string
ChangeTitle ( string newTitle ) : void
DetachTelnet ( TelnetSingletonServer server ) : void
GetNewestBuffer ( ) : void

Get the newest copy of the screen buffer once, for use in all calculations for a while. This was added when telnet clients were added. The execution cost of obtaining a buffer snapshot from the ScreenBuffer class is non-trivial, and therefore shouldn't be done over and over for each telnet client that needs it within the span of a short time. This gets it once for all of them to borrow. All calls will re-use this copy for a while, until the next terminal refresh (1/20th of a second, at the moment).

HowManyColumnsFit ( ) : int
HowManyRowsFit ( ) : int
LoadAudio ( ) : void
LoadFontArray ( ) : void
Lock ( ) : void
NotifyOfScreenResize ( IScreenBuffer sb ) : int
OnGUI ( ) : void
OnHideUI ( ) : void
OnShowUI ( ) : void
ProcessKeyEvents ( ) : void

Process the GUI event handler key events that are being seen the by GUI terminal, by translating them into values from the UnicodeCommand enum first if need be, and then passing them through to ProcessOneInputChar().

ProcessTelnetInput ( ) : void

Read all pending input from all telnet clients attached and process it all. Hopefully this won't bog down anything, as we don't expect to get lots of chars at once from keyboard input in a single update. The amount of characters pending in the queues should be very small since this is flushing it out every update. It could potentially be large if someone does a big cut-n-paste into their terminal window and their telnet client therefore sends a wall of text within the span of one Update(). Premature optimization is bad, so we'll wait to see if that is a problem later.

ProcessUnconsumedInput ( ) : void

When the input queue is not empty and the program or command is done such that the input cursor is now all the way back to the interpreter awaiting new input, send that queue out to the interpreter. This allows you to type the next command blindly while waiting for the previous one to finish. This is how people used to terminals would expect things to work.

RepaintTelnet ( TelnetSingletonServer telnet, bool fullSync ) : void

Do the repaint of the telnet session.

RepaintTelnetFull ( TelnetSingletonServer telnet ) : void

Cover the case where the whole screen needs to be repainted from scratch.

ResizeAndRepaintTelnet ( TelnetSingletonServer telnet, int width, int height, bool unconditional ) : void

Tell the telnet session to resize itself

SendTitleToTelnet ( TelnetSingletonServer telnet ) : void
ShowCharacterByAscii ( char ch, int x, int y, bool reversingScreen, int charWidth, int charHeight, float brightness ) : void
SpecialKey ( char key, bool doQueuing = true ) : void
TelnetOutputUpdate ( ) : void
TerminalGui ( int windowId ) : void
Type ( char ch, bool doQueuing = true ) : void
Unlock ( ) : void
Update ( ) : void
UpdateGUIBeeps ( ) : void

Method Details

AdjustColor() protected method

protected AdjustColor ( Color baseColor, float brightness ) : Color
baseColor Color
brightness float
return Color

Awake() public method

public Awake ( ) : void
return void

CheckResizeDrag() protected method

protected CheckResizeDrag ( ) : void
return void

ClearScreen() public method

public ClearScreen ( ) : void
return void

Close() public method

public Close ( ) : void
return void

DetachAllTelnets() public method

public DetachAllTelnets ( ) : void
return void

DrawTelnetStatus() protected method

Draw a little status line at the bottom as a reminder that you are sharing the terminal with a telnet session:
protected DrawTelnetStatus ( ) : void
return void

GetFocus() public method

public GetFocus ( ) : void
return void

GetRect() public method

public GetRect ( ) : Rect
return UnityEngine.Rect

GetSoundMaker() public method

public GetSoundMaker ( ) : kOS.Safe.Sound.ISoundMaker
return kOS.Safe.Sound.ISoundMaker

LoadTexture() public method

public LoadTexture ( String relativePath, Texture2D &targetTexture ) : void
relativePath String
targetTexture UnityEngine.Texture2D
return void

LoseFocus() public method

public LoseFocus ( ) : void
return void

NumTelnets() public method

public NumTelnets ( ) : int
return int

OnDestroy() public method

public OnDestroy ( ) : void
return void

Open() public method

public Open ( ) : void
return void

OpenPopupEditor() public method

public OpenPopupEditor ( kOS.Persistence.Volume v, GlobalPath path ) : void
v kOS.Persistence.Volume
path GlobalPath
return void

Print() public method

public Print ( string str ) : void
str string
return void

ProcessOneInputChar() public method

Respond to one single input character in Unicode, using the pretend virtual Unicode terminal keycodes described in the UnicodeCommand enum. To keep things simple, all key input is coerced into single Unicode chars even if the actual keypress takes multiple characters to express in its native form (i.e. ESC [ A means left-arrow on a VT100 terminal. If a telnet is talking via VT100 codes, that ESC [ A will get converted into a single UnicdeCommand.LEFTCURSORONE character before being sent here.)
This method is public because it is also how other mods should send input to the terminal if they want some other source to send simulated keystrokes.
public ProcessOneInputChar ( char ch, TelnetSingletonServer whichTelnet, bool doQueuing = true ) : void
ch char The character, which might be a UnicodeCommand char
whichTelnet TelnetSingletonServer If this came from a telnet session, which one did it come from? /// Set to null in order to say it wasn't from a telnet but was from the interactive GUI
doQueuing bool true if the keypress should get queued if we're not ready for it /// right now. If false, then the keypress will be ignored if we're not ready for it.
return void

TermWindow() public method

public TermWindow ( ) : System
return System

Toggle() public method

public Toggle ( ) : void
return void