return display;
}
+ /**
+ * Get the visible display + scrollback buffer, offset by a specified
+ * number of rows from the bottom.
+ *
+ * @param visibleHeight the total height of the display to show
+ * @param scrollBottom the number of rows from the bottom to scroll back
+ * @return a copy of the display + scrollback buffers
+ */
+ public final List<DisplayLine> getVisibleDisplay(final int visibleHeight,
+ final int scrollBottom) {
+
+ assert (visibleHeight >= 0);
+ assert (scrollBottom >= 0);
+
+ int visibleBottom = scrollback.size() + display.size() - scrollBottom;
+
+ List<DisplayLine> preceedingBlankLines = new ArrayList<DisplayLine>();
+ int visibleTop = visibleBottom - visibleHeight;
+ if (visibleTop < 0) {
+ for (int i = visibleTop; i < 0; i++) {
+ preceedingBlankLines.add(getBlankDisplayLine());
+ }
+ visibleTop = 0;
+ }
+ assert (visibleTop >= 0);
+
+ List<DisplayLine> displayLines = new ArrayList<DisplayLine>();
+ displayLines.addAll(scrollback);
+ displayLines.addAll(display);
+
+ List<DisplayLine> visibleLines = new ArrayList<DisplayLine>();
+ visibleLines.addAll(preceedingBlankLines);
+ visibleLines.addAll(displayLines.subList(visibleTop, visibleBottom));
+
+ // Fill in the blank lines on bottom
+ int bottomBlankLines = visibleHeight - visibleLines.size();
+ assert (bottomBlankLines >= 0);
+ for (int i = 0; i < bottomBlankLines; i++) {
+ visibleLines.add(getBlankDisplayLine());
+ }
+
+ return copyBuffer(visibleLines);
+ }
+
+ /**
+ * Copy a display buffer.
+ *
+ * @param buffer the buffer to copy
+ * @return a deep copy of the buffer's data
+ */
+ private List<DisplayLine> copyBuffer(final List<DisplayLine> buffer) {
+ ArrayList<DisplayLine> result = new ArrayList<DisplayLine>(buffer.size());
+ for (DisplayLine line: buffer) {
+ result.add(new DisplayLine(line));
+ }
+ return result;
+ }
+
/**
* Get the display width.
*
*/
private void setToggle(final boolean value) {
boolean decPrivateModeFlag = false;
+
for (int i = 0; i < collectBuffer.length(); i++) {
if (collectBuffer.charAt(i) == '?') {
decPrivateModeFlag = true;
}
}
}
+
+ if (p[0].equals("10")) {
+ if (p[1].equals("?")) {
+ // Respond with foreground color.
+ java.awt.Color color = jexer.backend.SwingTerminal.attrToForegroundColor(currentState.attr);
+
+ writeRemote(String.format(
+ "\033]10;rgb:%04x/%04x/%04x\033\\",
+ color.getRed() << 8,
+ color.getGreen() << 8,
+ color.getBlue() << 8));
+ }
+ }
+
+ if (p[0].equals("11")) {
+ if (p[1].equals("?")) {
+ // Respond with background color.
+ java.awt.Color color = jexer.backend.SwingTerminal.attrToBackgroundColor(currentState.attr);
+
+ writeRemote(String.format(
+ "\033]11;rgb:%04x/%04x/%04x\033\\",
+ color.getRed() << 8,
+ color.getGreen() << 8,
+ color.getBlue() << 8));
+ }
+ }
}
// Go to SCAN_GROUND state
}
}
+ /**
+ * Respond to xterm sixel query.
+ */
+ private void xtermSixelQuery() {
+ int item = getCsiParam(0, 0);
+ int action = getCsiParam(1, 0);
+ int value = getCsiParam(2, 0);
+
+ switch (item) {
+ case 1:
+ if (action == 1) {
+ // Report number of color registers.
+ writeRemote(String.format("\033[?%d;%d;%dS", item, 0, 1024));
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ // We will not support this option.
+ writeRemote(String.format("\033[?%d;%dS", item, action));
+ }
+
/**
* Run this input character through the ECMA48 state machine.
*
case 'S':
// Scroll up X lines (default 1)
if (type == DeviceType.XTERM) {
- su();
+ boolean xtermPrivateModeFlag = false;
+ for (int i = 0; i < collectBuffer.length(); i++) {
+ if (collectBuffer.charAt(i) == '?') {
+ xtermPrivateModeFlag = true;
+ break;
+ }
+ }
+ if (xtermPrivateModeFlag) {
+ xtermSixelQuery();
+ } else {
+ su();
+ }
}
break;
case 'T':
case 'S':
// Scroll up X lines (default 1)
if (type == DeviceType.XTERM) {
- su();
+ boolean xtermPrivateModeFlag = false;
+ for (int i = 0; i < collectBuffer.length(); i++) {
+ if (collectBuffer.charAt(i) == '?') {
+ xtermPrivateModeFlag = true;
+ break;
+ }
+ }
+ if (xtermPrivateModeFlag) {
+ xtermSixelQuery();
+ } else {
+ su();
+ }
}
break;
case 'T':
}
// 00-17, 19, 1C-1F, 20-7E --> put
- // TODO
if (ch <= 0x17) {
+ // We ignore all DCS except sixel.
return;
}
if (ch == 0x19) {
+ // We ignore all DCS except sixel.
return;
}
if ((ch >= 0x1C) && (ch <= 0x1F)) {
+ // We ignore all DCS except sixel.
return;
}
if ((ch >= 0x20) && (ch <= 0x7E)) {
+ // We ignore all DCS except sixel.
return;
}