jline

Class Terminal

public abstract class Terminal extends Object implements ConsoleOperations

Representation of the input terminal for a platform. Handles any initialization that the platform may need to perform in order to allow the ConsoleReader to correctly handle input.

Author: Marc Prud'hommeaux

Method Summary
voidafterReadLine(ConsoleReader reader, String prompt, Character mask)
Invokes after the console reads a line with the prompt and mask.
voidbeforeReadLine(ConsoleReader reader, String prompt, Character mask)
Invokes before the console reads a line with the prompt and mask.
abstract voiddisableEcho()
Disable character echoing.
abstract voidenableEcho()
Enable character echoing.
InputStreamgetDefaultBindings()
abstract booleangetEcho()
Returns true if the terminal will echo all characters type.
static TerminalgetTerminal()
abstract intgetTerminalHeight()
Returns the current height of the terminal (in lines)
abstract intgetTerminalWidth()
Returns the current width of the terminal (in characters)
abstract voidinitializeTerminal()
Initialize any system settings that are required for the console to be able to handle input correctly, such as setting tabtop, buffered input, and character echo.
booleanisANSISupported()
Returns true if the current console supports ANSI codes.
abstract booleanisEchoEnabled()
Returns false if character echoing is disabled.
abstract booleanisSupported()
Returns true if this terminal is capable of initializing the terminal to use jline.
intreadCharacter(InputStream in)
Read a single character from the input stream.
intreadVirtualKey(InputStream in)
Reads a virtual key from the console.
static voidresetTerminal()
Reset the current terminal to null.
static TerminalsetupTerminal()

Configure and return the Terminal instance for the current platform.

Method Detail

afterReadLine

public void afterReadLine(ConsoleReader reader, String prompt, Character mask)
Invokes after the console reads a line with the prompt and mask.

beforeReadLine

public void beforeReadLine(ConsoleReader reader, String prompt, Character mask)
Invokes before the console reads a line with the prompt and mask.

disableEcho

public abstract void disableEcho()
Disable character echoing. This can be used to manually re-enable character if the ConsoleReader has been disabled.

enableEcho

public abstract void enableEcho()
Enable character echoing. This can be used to re-enable character if the ConsoleReader is no longer being used.

getDefaultBindings

public InputStream getDefaultBindings()

getEcho

public abstract boolean getEcho()
Returns true if the terminal will echo all characters type.

getTerminal

public static Terminal getTerminal()

See Also: Terminal

getTerminalHeight

public abstract int getTerminalHeight()
Returns the current height of the terminal (in lines)

getTerminalWidth

public abstract int getTerminalWidth()
Returns the current width of the terminal (in characters)

initializeTerminal

public abstract void initializeTerminal()
Initialize any system settings that are required for the console to be able to handle input correctly, such as setting tabtop, buffered input, and character echo.

isANSISupported

public boolean isANSISupported()
Returns true if the current console supports ANSI codes.

isEchoEnabled

public abstract boolean isEchoEnabled()
Returns false if character echoing is disabled.

isSupported

public abstract boolean isSupported()
Returns true if this terminal is capable of initializing the terminal to use jline.

readCharacter

public int readCharacter(InputStream in)
Read a single character from the input stream. This might enable a terminal implementation to better handle nuances of the console.

readVirtualKey

public int readVirtualKey(InputStream in)
Reads a virtual key from the console. Typically, this will just be the raw character that was entered, but in some cases, multiple input keys will need to be translated into a single virtual key.

Parameters: in the InputStream to read from

Returns: the virtual key (e.g., ConsoleOperations)

resetTerminal

public static void resetTerminal()
Reset the current terminal to null.

setupTerminal

public static Terminal setupTerminal()

Configure and return the Terminal instance for the current platform. This will initialize any system settings that are required for the console to be able to handle input correctly, such as setting tabtop, buffered input, and character echo.

This class will use the Terminal implementation specified in the jline.terminal system property, or, if it is unset, by detecting the operating system from the os.name system property and instantiating either the WindowsTerminalTest or UnixTerminal.

See Also: Terminal

Copyright © 2002-2010 null. All Rights Reserved.