terminal

Module for supporting cursor and color manipulation on the console.

The main interface for this module is the Terminal struct, which encapsulates the functions of the terminal. Creating an instance of this struct will perform console initialization; when the struct goes out of scope, any changes in console settings will be automatically reverted.

Note: on Posix, it traps SIGINT and translates it into an input event. You should keep your event loop moving and keep an eye open for this to exit cleanly; simply break your event loop upon receiving a UserInterruptionEvent. (Without the signal handler, ctrl+c can leave your terminal in a bizarre state.)

As a user, if you have to forcibly kill your program and the event doesn't work, there's still ctrl+\

Members

Classes

LineGetter
class LineGetter

FIXME: support lines that wrap FIXME: better controls maybe

Enums

Color
enum Color

Defines the list of standard colors understood by Terminal.

ConsoleInputFlags
enum ConsoleInputFlags

When capturing input, what events are you interested in?

ConsoleOutputType
enum ConsoleOutputType

Defines how terminal output should be handled.

ForceOption
enum ForceOption

Some methods will try not to send unnecessary commands to the screen. You can override their judgement using a ForceOption parameter, if present

ModifierState
enum ModifierState
Undocumented in source.
ModifierState
enum ModifierState
Undocumented in source.

Functions

SHGetFolderPathA
HRESULT SHGetFolderPathA(HWND , int , HANDLE , DWORD , LPSTR )
Undocumented in source but is binding to Windows. You might be able to learn more by searching the web for its name.
hangupSignalHandler
void hangupSignalHandler(int sigNumber)
Undocumented in source. Be warned that the author may not have intended to support it.
interruptSignalHandler
void interruptSignalHandler(int sigNumber)
Undocumented in source. Be warned that the author may not have intended to support it.
main
void main()
Undocumented in source. Be warned that the author may not have intended to support it.
sizeSignalHandler
void sizeSignalHandler(int sigNumber)
Undocumented in source. Be warned that the author may not have intended to support it.

Interfaces

CustomEvent
interface CustomEvent
Undocumented in source.

Manifest constants

Bright
enum Bright;
Undocumented in source.
CSIDL_APPDATA
enum CSIDL_APPDATA;
Undocumented in source.
SIGWINCH
enum SIGWINCH;
Undocumented in source.

Static variables

hangedUp
bool hangedUp;

similar to interrupted.

interrupted
bool interrupted;

you might periodically check this in a long operation and abort if it is set. Remember it is volatile. It is also sent through the input event loop via RealTimeConsoleInput

windowSizeChanged
bool windowSizeChanged;
Undocumented in source.

Structs

CharacterEvent
struct CharacterEvent

Input event for characters

EndOfFileEvent
struct EndOfFileEvent

Sent upon receiving end-of-file from stdin.

HangupEvent
struct HangupEvent

If the user hangs up (for example, closes the terminal emulator without exiting the app), this is sent. If you receive it, you should generally cleanly exit.

InputEvent
struct InputEvent

GetNextEvent returns this. Check the type, then use get to get the more detailed input

MouseEvent
struct MouseEvent

.

NonCharacterKeyEvent
struct NonCharacterKeyEvent
Undocumented in source.
PasteEvent
struct PasteEvent

.

RealTimeConsoleInput
struct RealTimeConsoleInput

Encapsulates the stream of input events received from the terminal input.

SignalFired
struct SignalFired
Undocumented in source.
SizeChangedEvent
struct SizeChangedEvent

.

Terminal
struct Terminal

Encapsulates the I/O capabilities of a terminal.

UserInterruptionEvent
struct UserInterruptionEvent

the user hitting ctrl+c will send this You should drop what you're doing and perhaps exit when this happens.

Meta