org.crsh.text
Class VirtualScreen

java.lang.Object
  extended by org.crsh.text.VirtualScreen
All Implemented Interfaces:
Appendable, Screenable, ScreenContext

public class VirtualScreen
extends Object
implements ScreenContext

A virtual screen that can be scrolled. This class is thread safe, as it can be used concurrently by two threads, for example one thread can provide new elements while another thread is repainting the buffer to the screen, both threads can either modify the underlying data structure. Paint could also be called concurrently by two threads, one that just provided a new element and wants to repaint the structure and another that changes the current cursor and asks for a repaint too.

Author:
Julien Viet

Constructor Summary
VirtualScreen(ScreenContext out)
           
 
Method Summary
 Screenable append(char c)
           
 Screenable append(CharSequence s)
           
 Screenable append(CharSequence csq, int start, int end)
           
 Screenable append(Style style)
           
 Screenable cls()
           
 void flush()
          Flush the stream.
 int getHeight()
          Returns the screen height in chars.
 int getWidth()
          Returns the screen width in chars.
 boolean isPainted()
           
 boolean isPainting()
           
 boolean isRefresh()
           
 int nextPage()
           
 boolean nextRow()
           
 VirtualScreen paint()
          Pain the underlying screen context.
 boolean previousRow()
           
 boolean update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualScreen

public VirtualScreen(ScreenContext out)
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

append

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

append

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

append

public Screenable 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

paint

public VirtualScreen paint()
                    throws IOException
Pain the underlying screen context.

Returns:
this screen buffer
Throws:
IOException - any io exception

previousRow

public boolean previousRow()
                    throws IOException
Throws:
IOException

isPainted

public boolean isPainted()
Returns:
true if the buffer is painted

isRefresh

public boolean isRefresh()
Returns:
true if the buffer is stale and needs a full repaint

isPainting

public boolean isPainting()
Returns:
true if the buffer is waiting for input to become painted

nextRow

public boolean nextRow()
                throws IOException
Throws:
IOException

nextPage

public int nextPage()
             throws IOException
Throws:
IOException

update

public boolean update()
               throws IOException
Throws:
IOException

flush

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

Specified by:
flush in interface ScreenContext
Throws:
IOException - any io exception


Copyright © 2015 eXo Platform SAS. All Rights Reserved.