Class ScreenBuffer
java.lang.Object
com.googlecode.lanterna.screen.ScreenBuffer
- All Implemented Interfaces:
Scrollable, TextImage
Defines a buffer used by AbstractScreen and its subclasses to keep its state of what's currently displayed and what
the edit buffer looks like. A ScreenBuffer is essentially a two-dimensional array of TextCharacter with some utility
methods to inspect and manipulate it in a safe way.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateScreenBuffer(BasicTextImage backend) ScreenBuffer(TerminalSize size, TextCharacter filler) Creates a new ScreenBuffer with a given size and a TextCharacter to initially fill it with -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) Copies the content from a TextImage into this buffer.voidCopies this TextImage's content to another TextImage.voidcopyTo(TextImage destination, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) Copies this TextImage's content to another TextImage.getCharacterAt(int column, int row) Returns the character stored at a particular position in this imagegetCharacterAt(TerminalPosition position) Returns the character stored at a particular position in this imagegetSize()////////////////////////////////////////////////////////////////////////////(package private) booleanisVeryDifferent(ScreenBuffer other, int threshold) Creates a TextGraphics object that targets this TextImage for all its drawing operations.resize(TerminalSize newSize, TextCharacter filler) Returns a copy of this image resized to a new size and using a specified filler character if the new size is larger than the old and we need to fill in empty areas.voidscrollLines(int firstLine, int lastLine, int distance) Scroll a range of lines of this TextImage according to given distance.voidsetAll(TextCharacter character) Sets the text image content to one specified character (including color and style)voidsetCharacterAt(int column, int row, TextCharacter character) Sets the character at a specific position in the image to a particular TextCharacter.voidsetCharacterAt(TerminalPosition position, TextCharacter character) Sets the character at a specific position in the image to a particular TextCharacter.toString()
-
Field Details
-
backend
-
-
Constructor Details
-
ScreenBuffer
Creates a new ScreenBuffer with a given size and a TextCharacter to initially fill it with- Parameters:
size- Size of the bufferfiller- What character to set as the initial content of the buffer
-
ScreenBuffer
-
-
Method Details
-
resize
Description copied from interface:TextImageReturns a copy of this image resized to a new size and using a specified filler character if the new size is larger than the old and we need to fill in empty areas. The copy will be independent from the one this method is invoked on, so modifying one will not affect the other. -
isVeryDifferent
-
getSize
//////////////////////////////////////////////////////////////////////////// -
getCharacterAt
Description copied from interface:TextImageReturns the character stored at a particular position in this image- Specified by:
getCharacterAtin interfaceTextImage- Parameters:
position- Coordinates of the character- Returns:
- TextCharacter stored at the specified position
-
getCharacterAt
Description copied from interface:TextImageReturns the character stored at a particular position in this image- Specified by:
getCharacterAtin interfaceTextImage- Parameters:
column- Column coordinate of the characterrow- Row coordinate of the character- Returns:
- TextCharacter stored at the specified position
-
setCharacterAt
Description copied from interface:TextImageSets the character at a specific position in the image to a particular TextCharacter. If the position is outside of the image's size, this method does nothing.- Specified by:
setCharacterAtin interfaceTextImage- Parameters:
position- Coordinates of the charactercharacter- What TextCharacter to assign at the specified position
-
setCharacterAt
Description copied from interface:TextImageSets the character at a specific position in the image to a particular TextCharacter. If the position is outside of the image's size, this method does nothing.- Specified by:
setCharacterAtin interfaceTextImage- Parameters:
column- Column coordinate of the characterrow- Row coordinate of the charactercharacter- What TextCharacter to assign at the specified position
-
setAll
Description copied from interface:TextImageSets the text image content to one specified character (including color and style) -
newTextGraphics
Description copied from interface:TextImageCreates a TextGraphics object that targets this TextImage for all its drawing operations.- Specified by:
newTextGraphicsin interfaceTextImage- Returns:
- TextGraphics object for this TextImage
-
copyTo
Description copied from interface:TextImageCopies this TextImage's content to another TextImage. If the destination TextImage is larger than this ScreenBuffer, the areas outside of the area that is written to will be untouched. -
copyTo
public void copyTo(TextImage destination, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) Description copied from interface:TextImageCopies this TextImage's content to another TextImage. If the destination TextImage is larger than this TextImage, the areas outside of the area that is written to will be untouched.- Specified by:
copyToin interfaceTextImage- Parameters:
destination- TextImage to copy tostartRowIndex- Which row in this image to copy fromrows- How many rows to copystartColumnIndex- Which column in this image to copy fromcolumns- How many columns to copydestinationRowOffset- Offset (in number of rows) in the target image where we want to first copied row to bedestinationColumnOffset- Offset (in number of columns) in the target image where we want to first copied column to be
-
copyFrom
public void copyFrom(TextImage source, int startRowIndex, int rows, int startColumnIndex, int columns, int destinationRowOffset, int destinationColumnOffset) Copies the content from a TextImage into this buffer.- Parameters:
source- Source to copy content fromstartRowIndex- Which row in the source image to start copying fromrows- How many rows to copystartColumnIndex- Which column in the source image to start copying fromcolumns- How many columns to copydestinationRowOffset- The row offset in this buffer of where to place the copied contentdestinationColumnOffset- The column offset in this buffer of where to place the copied content
-
scrollLines
public void scrollLines(int firstLine, int lastLine, int distance) Description copied from interface:TextImageScroll a range of lines of this TextImage according to given distance. TextImage implementations of this method do not throw IOException.- Specified by:
scrollLinesin interfaceScrollable- Specified by:
scrollLinesin interfaceTextImage- Parameters:
firstLine- first line of the range to be scrolled (top line is 0)lastLine- last (inclusive) line of the range to be scrolleddistance- if > 0: move lines up, else if < 0: move lines down.
-
toString
-