org.crsh.telnet.term.console
Class ConsoleTerm

java.lang.Object
  extended by org.crsh.telnet.term.console.ConsoleTerm
All Implemented Interfaces:
Closeable, Appendable, Term, Screenable, ScreenContext

public class ConsoleTerm
extends Object

    
implements Term

    

Implements the interface.


Field Summary
private  TermIOBuffer buffer
          .
private  LinkedList<CharSequence> history
          .
private  CharSequence historyBuffer
          .
private  int historyCursor
          .
private  TermIO io
          .
private  Logger log
          .
private  TermIOWriter writer
          .
 
Constructor Summary
ConsoleTerm(TermIO io)
           
 
Method Summary
 void addToHistory(CharSequence line)
          Append a line to the term history.
 Appendable append(char c)
           
 Screenable append(CharSequence s)
           
 Appendable append(CharSequence csq, int start, int end)
           
 Screenable append(Style style)
           
 void close()
           
 Screenable cls()
           
 void flush()
          Flush the stream.
 CharSequence getBuffer()
          Returns the current buffer content to the cursor;
 Appendable getDirectBuffer()
          Returns the direct buffer, any char appended in the returned appendable will translate into an insertion in the buffer.
 int getHeight()
          Returns the screen height in chars.
 String getProperty(String name)
          Retrieves the value of a property specified by this Term
 int getWidth()
          Returns the screen width in chars.
 TermEvent read()
          Read the next term event.
 boolean releaseAlternateBuffer()
          Release control of the alternate buffer.
 void setEcho(boolean echo)
          Set the echo mode on the term.
 boolean takeAlternateBuffer()
          Take control of the alternate buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final Logger log
.


history

private final LinkedList<CharSequence> history
.


historyBuffer

private CharSequence historyBuffer
.


historyCursor

private int historyCursor
.


io

private final TermIO io
.


buffer

private final TermIOBuffer buffer
.


writer

private final TermIOWriter writer
.

Constructor Detail

ConsoleTerm

public ConsoleTerm(TermIO io)
Method Detail

getWidth

public int getWidth()
Description copied from interface: ScreenContext
Returns the screen width in chars. When the value is not positive it means the value could not be determined.

Specified by:
getWidth in interface ScreenContext
Returns:
the term width

getHeight

public int getHeight()
Description copied from interface: ScreenContext
Returns the screen height in chars. When the value is not positive it means the value could not be determined.

Specified by:
getHeight in interface ScreenContext
Returns:
the term height

getProperty

public String getProperty(String name)
Description copied from interface: Term
Retrieves the value of a property specified by this Term

Specified by:
getProperty in interface Term
Parameters:
name - name of the term property
Returns:
value of the term property

setEcho

public void setEcho(boolean echo)
Description copied from interface: Term
Set the echo mode on the term.

Specified by:
setEcho in interface Term
Parameters:
echo - the echo mode

takeAlternateBuffer

public boolean takeAlternateBuffer()
                            throws IOException
Description copied from interface: Term
Take control of the alternate buffer. When the alternate buffer is already used nothing happens. The buffer switch should occur when then ScreenContext.flush() method is invoked.

Specified by:
takeAlternateBuffer in interface Term
Returns:
true if the alternate buffer is shown
Throws:
IOException

releaseAlternateBuffer

public boolean releaseAlternateBuffer()
                               throws IOException
Description copied from interface: Term
Release control of the alternate buffer. When the normal buffer is already used nothing happens. The buffer switch should occur when then ScreenContext.flush() method is invoked.

Specified by:
releaseAlternateBuffer in interface Term
Returns:
true if the usual buffer is shown
Throws:
IOException

read

public TermEvent read()
               throws IOException
Description copied from interface: Term
Read the next term event. This operation is a blocking operation that blocks until data is available or until term is closed.

Specified by:
read in interface Term
Returns:
the next term event
Throws:
IOException - any io exception

getDirectBuffer

public Appendable getDirectBuffer()
Description copied from interface: Term
Returns the direct buffer, any char appended in the returned appendable will translate into an insertion in the buffer.

Specified by:
getDirectBuffer in interface Term
Returns:
the insert buffer.

addToHistory

public void addToHistory(CharSequence line)
Description copied from interface: Term
Append a line to the term history.

Specified by:
addToHistory in interface Term
Parameters:
line - the history line to append

getBuffer

public CharSequence getBuffer()
Description copied from interface: Term
Returns the current buffer content to the cursor;

Specified by:
getBuffer in interface Term
Returns:
the buffer

flush

public void flush()
Description copied from interface: ScreenContext
Flush the stream.

Specified by:
flush in interface ScreenContext

close

public void close()
Specified by:
close in interface Closeable

append

public Screenable append(CharSequence s)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(char c)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Appendable append(CharSequence csq,
                         int start,
                         int end)
                  throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public Screenable append(Style style)
                  throws IOException
Specified by:
append in interface Screenable
Throws:
IOException

cls

public Screenable cls()
               throws IOException
Specified by:
cls in interface Screenable
Throws:
IOException


Copyright © 2015 eXo Platform SAS. All Rights Reserved.