in ui/src/com/jediterm/terminal/ui/TerminalPanel.java [779:871]
public void paintComponent(final Graphics g) {
resetColorCache();
final Graphics2D gfx = (Graphics2D) g;
setupAntialiasing(gfx);
gfx.setColor(getBackground());
gfx.fillRect(0, 0, getWidth(), getHeight());
try {
myTerminalTextBuffer.lock();
// update myClientScrollOrigin as scrollArea might have been invoked after last WeakRedrawTimer action
updateScrolling(false);
myTerminalTextBuffer.processHistoryAndScreenLines(myClientScrollOrigin, myTermSize.getRows(), new StyledTextConsumer() {
final int columnCount = getColumnCount();
@Override
public void consume(int x, int y, @NotNull TextStyle style, @NotNull CharBuffer characters, int startRow) {
int row = y - startRow;
drawCharacters(x, row, style, characters, gfx, myFillCharacterBackgroundIncludingLineSpacing);
if (myFindResult != null) {
List<Pair<Integer, Integer>> ranges = myFindResult.getRanges(characters);
if (ranges != null && !ranges.isEmpty()) {
TextStyle foundPatternStyle = getFoundPattern(style);
for (Pair<Integer, Integer> range : ranges) {
CharBuffer foundPatternChars = characters.subBuffer(range);
drawCharacters(x + range.getFirst(), row, foundPatternStyle, foundPatternChars, gfx);
}
}
}
if (mySelection != null) {
Pair<Integer, Integer> interval = mySelection.intersect(x, row + myClientScrollOrigin, characters.length());
if (interval != null) {
TextStyle selectionStyle = getSelectionStyle(style);
CharBuffer selectionChars = characters.subBuffer(interval.getFirst() - x, interval.getSecond());
drawCharacters(interval.getFirst(), row, selectionStyle, selectionChars, gfx);
}
}
}
@Override
public void consumeNul(int x, int y, int nulIndex, TextStyle style, CharBuffer characters, int startRow) {
int row = y - startRow;
if (mySelection != null) {
// compute intersection with all NUL areas, non-breaking
Pair<Integer, Integer> interval = mySelection.intersect(nulIndex, row + myClientScrollOrigin, columnCount - nulIndex);
if (interval != null) {
TextStyle selectionStyle = getSelectionStyle(style);
drawCharacters(x, row, selectionStyle, characters, gfx);
return;
}
}
drawCharacters(x, row, style, characters, gfx);
}
@Override
public void consumeQueue(int x, int y, int nulIndex, int startRow) {
if (x < columnCount) {
consumeNul(x, y, nulIndex, TextStyle.EMPTY, new CharBuffer(CharUtils.EMPTY_CHAR, columnCount - x), startRow);
}
}
});
int cursorY = myCursor.getCoordY();
if (cursorY < getRowCount() && !hasUncommittedChars()) {
int cursorX = myCursor.getCoordX();
Pair<Character, TextStyle> sc = myTerminalTextBuffer.getStyledCharAt(cursorX, cursorY);
String cursorChar = "" + sc.getFirst();
if (Character.isHighSurrogate(sc.getFirst())) {
cursorChar += myTerminalTextBuffer.getStyledCharAt(cursorX + 1, cursorY).getFirst();
}
TextStyle normalStyle = sc.getSecond() != null ? sc.getSecond() : myStyleState.getCurrent();
TextStyle cursorStyle;
if (inSelection(cursorX, cursorY)) {
cursorStyle = getSelectionStyle(normalStyle);
}
else {
cursorStyle = normalStyle;
}
myCursor.drawCursor(cursorChar, gfx, cursorStyle);
}
} finally {
myTerminalTextBuffer.unlock();
}
resetColorCache();
drawInputMethodUncommitedChars(gfx);
drawMargins(gfx, getWidth(), getHeight());
}