public abstract class Buffer
extends java.lang.Object
Lines
.Modifier | Constructor and Description |
---|---|
protected |
Buffer(int maxLines,
int renderWidth)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addBufferListener(@NotNull BufferListener listener)
Adds a listener to notify of changes.
|
void |
addLine(@NotNull Line line)
Appends a
Line to the end of the buffer. |
void |
addTextSegment(@NotNull Line line,
@NotNull java.lang.String text,
boolean bold,
boolean italic,
boolean underline,
@NotNull FontID fontID,
@NotNull java.awt.Color color,
@NotNull java.awt.Color selectionColor)
Appends a
TextSegment to the end of a line. |
void |
clear()
Clears all lines from the buffer.
|
int |
coordinateToPosition(int x,
int y)
Returns the text position for a coordinate.
|
int |
getLastCount()
Returns the number of merged lines.
|
@NotNull Line |
getLine(int line)
Returns one
Line by line index. |
protected abstract int |
getSegmentWidth(@NotNull TextSegment segment,
int characters)
Returns the width of a prefix of a
TextSegment . |
@NotNull java.lang.Object |
getSyncObject()
Returns the object to synchronize on when calling
lines(int) . |
@NotNull java.lang.String |
getText(int beginSelection,
int endSelection)
Returns the selected text.
|
int |
getTotalHeight()
Returns the total height of all lines.
|
@NotNull java.lang.Iterable<Line> |
lines(int line)
Returns an
Iterator for the lines in this buffer. |
boolean |
mergeLines(@NotNull java.lang.String text,
int type,
int subtype,
@Nullable java.awt.Color color)
Checks whether a new text line should be merged with a preceding line.
|
protected abstract @NotNull TextSegment |
newTextSegment(@NotNull java.lang.String text,
boolean bold,
boolean italic,
boolean underline,
@NotNull FontID fontID,
@NotNull java.awt.Color color,
@NotNull java.awt.Color selectionColor)
Creates a new segment.
|
void |
prune()
Prunes excess lines.
|
void |
removeBufferListener(@NotNull BufferListener listener)
Removes a listener to be notified of changes.
|
void |
replaceLine(@NotNull Line line)
Replaces the last
Line of this buffer. |
void |
setRenderWidth(int renderWidth)
Updates the width to render.
|
void |
setShowSentCommands(boolean showSentCommands)
Sets whether commands sent to the server are shown.
|
void |
setShowTimestamps(boolean showTimestamps)
Sets whether timestamps are shown.
|
int |
size()
Returns the number of lines.
|
protected Buffer(int maxLines, int renderWidth)
maxLines
- the maximum number of lines the buffer can holdrenderWidth
- the width to renderpublic void setRenderWidth(int renderWidth)
renderWidth
- the width to renderpublic void setShowSentCommands(boolean showSentCommands)
showSentCommands
- whether commands sent to the server are shownpublic void setShowTimestamps(boolean showTimestamps)
showTimestamps
- whether timestamps are shownpublic void clear()
public void addLine(@NotNull @NotNull Line line)
Line
to the end of the buffer.line
- the line to appendpublic void replaceLine(@NotNull @NotNull Line line)
Line
of this buffer.line
- the replacing linepublic void prune()
@NotNull public @NotNull Line getLine(int line)
Line
by line index. The first line has the index
0
.line
- the line indexpublic int getTotalHeight()
@NotNull public @NotNull java.lang.Iterable<Line> lines(int line)
Iterator
for the lines in this buffer.line
- the initial line index of the list iteratorpublic int size()
public void addBufferListener(@NotNull @NotNull BufferListener listener)
listener
- the listenerpublic void removeBufferListener(@NotNull @NotNull BufferListener listener)
listener
- the listener@NotNull public @NotNull java.lang.Object getSyncObject()
lines(int)
.public boolean mergeLines(@NotNull @NotNull java.lang.String text, int type, int subtype, @Nullable @Nullable java.awt.Color color)
text
- the text line contentstype
- the message typesubtype
- the message subtypecolor
- the text line colorpublic int getLastCount()
mergeLines(String, int, int, Color)
did return
true
.public void addTextSegment(@NotNull @NotNull Line line, @NotNull @NotNull java.lang.String text, boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull java.awt.Color color, @NotNull @NotNull java.awt.Color selectionColor)
TextSegment
to the end of a line.line
- the linetext
- the text to displaybold
- whether bold face is enableditalic
- whether italic face is enabledunderline
- whether underlining is enabledfontID
- the font to usecolor
- the color to useselectionColor
- the selection color to use@NotNull protected abstract @NotNull TextSegment newTextSegment(@NotNull @NotNull java.lang.String text, boolean bold, boolean italic, boolean underline, @NotNull @NotNull FontID fontID, @NotNull @NotNull java.awt.Color color, @NotNull @NotNull java.awt.Color selectionColor)
text
- the text to displaybold
- whether bold face is enableditalic
- whether italic face is enabledunderline
- whether underlining is enabledfontID
- the font to usecolor
- the color to useselectionColor
- the selection color to usepublic int coordinateToPosition(int x, int y)
x
- the x coordinatey
- the y coordinateprotected abstract int getSegmentWidth(@NotNull @NotNull TextSegment segment, int characters)
TextSegment
.segment
- the text segmentcharacters
- the number of characters in the prefix@NotNull public @NotNull java.lang.String getText(int beginSelection, int endSelection)
beginSelection
- the first selected characterendSelection
- the first character after the selection