org.crsh.term.console
Class ConsoleTerm

java.lang.Object
  extended by org.crsh.term.console.ConsoleTerm
All Implemented Interfaces:
Closeable, Flushable, Consumer<Chunk>, ScreenContext<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()
           
 void flush()
           
 CharSequence getBuffer()
          Returns the current buffer content to the cursor;
 Class<Chunk> getConsumedType()
          Returns the class of the element generic type.
 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.
 void provide(Chunk element)
          Provide an element.
 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<Chunk>
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<Chunk>
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 Flushable.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 Flushable.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()
Specified by:
flush in interface Flushable

close

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

getConsumedType

public Class<Chunk> getConsumedType()
Description copied from interface: Consumer
Returns the class of the element generic type.

Specified by:
getConsumedType in interface Consumer<Chunk>
Returns:
the consumed type

provide

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

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


Copyright © 2014 eXo Platform SAS. All Rights Reserved.