## jline
Class Terminal

    java.lang.Object
      jline.Terminal

All Implemented Interfaces:
  ConsoleOperations

Direct Known Subclasses:
  UnixTerminal, UnsupportedTerminal, WindowsTerminal

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

Field Summary

Fields inherited from interface jline.ConsoleOperations

`ADD, BACKSPACE, CHANGE_CASE, CHANGE_META, CLEAR_SCREEN, COMPLETE, CR, CTRL_B, CTRL_F, CTRL_N, CTRL_P, DELETE_META, DELETE_NEXT_CHAR, DELETE_PREV_CHAR, DELETE_PREV_WORD, END_WORD, EXIT, INSERT, KEYBOARD_BELL, KILL_LINE, KILL_LINE_PREV, MOVE_TO_BEG, MOVE_TO_END, NEWLINE, NEXT_CHAR, NEXT_HISTORY, NEXT_SPACE_WORD, NEXT_WORD, PASTE, PASTE_NEXT, PASTE_PREV, PREV_CHAR, PREV_HISTORY, PREV_SPACE_WORD, PREV_WORD, REDISPLAY, REPEAT_NEXT_CHAR, REPEAT_PREV_CHAR, REPEAT_SEARCH_NEXT, REPEAT_SEARCH_PREV, REPLACE_CHAR, REPLACE_MODE, RESET_LINE, SEARCH_NEXT, SEARCH_PREV, SUBSTITUTE_CHAR, SUBSTITUTE_LINE, TO_END_WORD, TO_NEXT_CHAR, TO_PREV_CHAR, UNDO, UNKNOWN`

Constructor Summary
`Terminal()`

Method Summary
`abstract boolean` `getEcho()` Returns true if the terminal will echo all characters type.
`static Terminal` `getTerminal()`
`abstract int` `getTerminalHeight()` Returns the current height of the terminal (in lines)
`abstract int` `getTerminalWidth()` Returns the current width of the terminal (in characters)
`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.
`boolean` `isANSISupported()` Returns true if the current console supports ANSI codes.
`abstract boolean` `isSupported()` Returns true if this terminal is capable of initializing the terminal to use jline.
`int` `readCharacter(InputStream in)` Read a single character from the input stream.
`int` `readVirtualKey(InputStream in)` Reads a virtual key from the console.
`static Terminal` `setupTerminal()` Configure and return the `Terminal` instance for the current platform.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Terminal

    public Terminal()

Method Detail

### getTerminal

    public static Terminal getTerminal()

  See Also:
    `setupTerminal()`

### 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 instantiateing either the `WindowsTerminal` or `UnixTerminal`.

  See Also:
    `initializeTerminal()`

### isANSISupported

    public boolean isANSISupported()

  Returns true if the current console supports ANSI codes.

### readCharacter

    public int readCharacter(InputStream in)
                      throws IOException

  Read a single character from the input stream. This might enable a terminal implementation to better handle nuances of the console.

  Throws:
    `IOException`

### readVirtualKey

    public int readVirtualKey(InputStream in)
                       throws IOException

  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#VK_UP`)
  Throws:
    `IOException`

### initializeTerminal

    public abstract void initializeTerminal()
                                     throws Exception

  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.

  Throws:
    `Exception`

### getTerminalWidth

    public abstract int getTerminalWidth()

  Returns the current width of the terminal (in characters)

### getTerminalHeight

    public abstract int getTerminalHeight()

  Returns the current height of the terminal (in lines)

### isSupported

    public abstract boolean isSupported()

  Returns true if this terminal is capable of initializing the terminal to use jline.

### getEcho

    public abstract boolean getEcho()

  Returns true if the terminal will echo all characters type.

Released under the terms of the BSD license