This is a line getter that customizes the tab completion to fill in file names separated by spaces, like a command line thing.
FIXME: support lines that wrap FIXME: better controls maybe
Defines the list of standard colors understood by Terminal.
When capturing input, what events are you interested in?
Defines how terminal output should be handled.
Some methods will try not to send unnecessary commands to the screen. You can override their judgement using a ForceOption parameter, if present
View the source of this!
Adds default constructors that just forward to the superclass
similar to 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
Sent upon receiving end-of-file from stdin.
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.
RealTimeConsoleInput.nextEvent returns one of these. Check the type, then use the get method to get the more detailed information about the event.
The new style of keyboard event
.
.
Represents a 24-bit color.
Encapsulates the stream of input events received from the terminal input.
When you get this, check terminal.width and terminal.height to see the new size and react accordingly.
Encapsulates the I/O capabilities of a terminal.
the user hitting ctrl+c will send this You should drop what you're doing and perhaps exit when this happens.
The main interface for this module is the Terminal struct, which encapsulates the output functions and line-buffered input of the terminal, and RealTimeConsoleInput, which gives real time input.
Creating an instance of these structs 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+\
On Mac Terminal btw, a lot of hacks are needed and mouse support doesn't work. Most functions basically work now though.
WHAT I WON'T DO:
Anything else is cool if it does work, but I don't want to go out of my way for it.
This example will demonstrate the high-level getline interface.
The user will be able to type a line and navigate around it with cursor keys and even the mouse on some systems, as well as perform editing as they expect (e.g. the backspace and delete keys work normally) until they press enter. Then, the final line will be returned to your program, which the example will simply print back to the user.
1 import arsd.terminal; 2 3 void main() { 4 auto terminal = Terminal(ConsoleOutputType.linear); 5 string line = terminal.getline(); 6 terminal.writeln("You wrote: ", line); 7 }
This example demonstrates color output, using Terminal.color and the output functions like Terminal.writeln.
1 import arsd.terminal; 2 void main() { 3 auto terminal = Terminal(ConsoleOutputType.linear); 4 terminal.color(Color.green, Color.black); 5 terminal.writeln("Hello world, in green on black!"); 6 terminal.color(Color.DEFAULT, Color.DEFAULT); 7 terminal.writeln("And back to normal."); 8 }
Module for interacting with the user's terminal, including color output, cursor manipulation, and full-featured real-time mouse and keyboard input. Also includes high-level convenience methods, like Terminal.getline, which gives the user a line editor with history, completion, etc. See the examples.