frysk.util
Class PtyTerminal

java.lang.Object
  extended by jline.Terminal
      extended by frysk.util.PtyTerminal
All Implemented Interfaces:
ConsoleOperations
Direct Known Subclasses:
ObservingTerminal

public class PtyTerminal
extends Terminal

Class that implements the jline Terminal abstract class using frysk.sys.termios calls. This copies jline.PtyTerminal pretty closely.


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
PtyTerminal(File file)
           
PtyTerminal(FileDescriptor fd)
           
PtyTerminal(String fname)
           
 
Method Summary
 boolean getEcho()
          Returns true if the terminal will echo all characters type.
 FileDescriptor getFd()
           
 int getTerminalHeight()
          Returns the value of "stty size" height param.
 int getTerminalWidth()
          Returns the value of "stty size" width param.
 void initializeTerminal()
          Remove line-buffered input by invoking "stty -icanon min 1" against the current terminal.
 boolean isSupported()
          Returns true if this terminal is capable of initializing the terminal to use jline.
 int readVirtualKey(InputStream in)
          Reads a virtual key from the console.
static void setToCharBufferedConsole(FileDescriptor fd)
          Set console to character buffered settings.
static void setToInitConsole(FileDescriptor fd)
          Set console to initial terminal settings.
 
Methods inherited from class jline.Terminal
afterReadLine, beforeReadLine, getTerminal, isANSISupported, readCharacter, setupTerminal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PtyTerminal

public PtyTerminal(FileDescriptor fd)

PtyTerminal

public PtyTerminal(File file)

PtyTerminal

public PtyTerminal(String fname)
Method Detail

getFd

public FileDescriptor getFd()

initializeTerminal

public void initializeTerminal()
                        throws IOException,
                               InterruptedException
Remove line-buffered input by invoking "stty -icanon min 1" against the current terminal.

Specified by:
initializeTerminal in class Terminal
Throws:
IOException
InterruptedException

setToInitConsole

public static void setToInitConsole(FileDescriptor fd)
Set console to initial terminal settings.


setToCharBufferedConsole

public static void setToCharBufferedConsole(FileDescriptor fd)
Set console to character buffered settings. Used for fhpd.


readVirtualKey

public int readVirtualKey(InputStream in)
                   throws IOException
Description copied from class: Terminal
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.

Overrides:
readVirtualKey in class Terminal
Parameters:
in - the InputStream to read from
Returns:
the virtual key (e.g., ConsoleOperations#VK_UP)
Throws:
IOException

isSupported

public boolean isSupported()
Description copied from class: Terminal
Returns true if this terminal is capable of initializing the terminal to use jline.

Specified by:
isSupported in class Terminal

getEcho

public boolean getEcho()
Description copied from class: Terminal
Returns true if the terminal will echo all characters type.

Specified by:
getEcho in class Terminal

getTerminalWidth

public int getTerminalWidth()
Returns the value of "stty size" width param.

Specified by:
getTerminalWidth in class Terminal

getTerminalHeight

public int getTerminalHeight()
Returns the value of "stty size" height param.

Specified by:
getTerminalHeight in class Terminal