org.crsh.term.console
Class ConsoleTerm

java.lang.Object
  extended by org.crsh.term.console.ConsoleTerm
All Implemented Interfaces:
Closeable, Flushable, Pipe<Chunk>, Term

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.
 void close()
          Close the term.
 void flush()
          Flush the term buffer.
 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 term height in chars.
 String getProperty(String name)
          Retrieves the value of a property specified by this Term
 int getWidth()
          Returns the term width in chars.
 void provide(Chunk element)
          Provide an element.
 TermEvent read()
          Read the next term event.
 void setEcho(boolean echo)
          Set the echo mode on the term.
 
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: Term
Returns the term width in chars. When the value is not positive it means the value could not be determined.

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

getHeight

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

Specified by:
getHeight in interface Term
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

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: Term
Flush the term buffer.

Specified by:
flush in interface Flushable
Specified by:
flush in interface Term

close

public void close()
Description copied from interface: Term
Close the term. If threads are blocked in the Term.read() operation, those thread should be unblocked.

Specified by:
close in interface Closeable
Specified by:
close in interface Term

provide

public void provide(Chunk element)
             throws IOException
Description copied from interface: Pipe
Provide an element.

Specified by:
provide in interface Pipe<Chunk>
Parameters:
element - the provided element
Throws:
IOException


Copyright © 2013 eXo Platform SAS. All Rights Reserved.