This commit is contained in:
@@ -120,7 +120,7 @@ public class J3270App extends JFrame implements ConnectionListener, ScreenUpdate
|
|||||||
|
|
||||||
// Actions menu
|
// Actions menu
|
||||||
JMenu actionsMenu = createMenu("Actions");
|
JMenu actionsMenu = createMenu("Actions");
|
||||||
actionsMenu.add(createMenuItem("Clear", KeyEvent.VK_L, () -> {
|
actionsMenu.add(createMenuItem("Clear", KeyEvent.VK_K, () -> {
|
||||||
if (client != null)
|
if (client != null)
|
||||||
client.sendClear();
|
client.sendClear();
|
||||||
terminalPanel.repaint();
|
terminalPanel.repaint();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class TerminalPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
private int getRenderOffsetX() {
|
private int getRenderOffsetX() {
|
||||||
int termCols = 80;
|
int termCols = 80;
|
||||||
if (client != null) termCols = client.getScreenBuffer().getCols();
|
if (client != null) termCols = client.getScreenBuffer().getDisplayCols();
|
||||||
int gridW = termCols * cellWidth;
|
int gridW = termCols * cellWidth;
|
||||||
int extra = getWidth() - gridW;
|
int extra = getWidth() - gridW;
|
||||||
return Math.max(padding, extra / 2);
|
return Math.max(padding, extra / 2);
|
||||||
@@ -81,10 +81,11 @@ public class TerminalPanel extends JPanel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the vertical render offset to center the grid within the panel.
|
* Compute the vertical render offset to center the grid within the panel.
|
||||||
|
* Must use getDisplayRows() to match paintComponent's iteration.
|
||||||
*/
|
*/
|
||||||
private int getRenderOffsetY() {
|
private int getRenderOffsetY() {
|
||||||
int termRows = 24;
|
int termRows = 24;
|
||||||
if (client != null) termRows = client.getScreenBuffer().getRows();
|
if (client != null) termRows = client.getScreenBuffer().getDisplayRows();
|
||||||
int gridH = termRows * cellHeight;
|
int gridH = termRows * cellHeight;
|
||||||
int extra = getHeight() - gridH;
|
int extra = getHeight() - gridH;
|
||||||
return Math.max(padding, extra / 2);
|
return Math.max(padding, extra / 2);
|
||||||
@@ -151,10 +152,12 @@ public class TerminalPanel extends JPanel {
|
|||||||
ScreenBuffer sb = client.getScreenBuffer();
|
ScreenBuffer sb = client.getScreenBuffer();
|
||||||
int ox = getRenderOffsetX();
|
int ox = getRenderOffsetX();
|
||||||
int oy = getRenderOffsetY();
|
int oy = getRenderOffsetY();
|
||||||
|
int displayCols = sb.getDisplayCols();
|
||||||
|
int displayRows = sb.getDisplayRows();
|
||||||
int col = (e.getX() - ox) / cellWidth;
|
int col = (e.getX() - ox) / cellWidth;
|
||||||
int row = (e.getY() - oy) / cellHeight;
|
int row = (e.getY() - oy) / cellHeight;
|
||||||
col = Math.max(0, Math.min(col, sb.getCols() - 1));
|
col = Math.max(0, Math.min(col, displayCols - 1));
|
||||||
row = Math.max(0, Math.min(row, sb.getRows() - 1));
|
row = Math.max(0, Math.min(row, displayRows - 1));
|
||||||
|
|
||||||
// Start selection
|
// Start selection
|
||||||
selectionStartRow = row;
|
selectionStartRow = row;
|
||||||
@@ -174,8 +177,8 @@ public class TerminalPanel extends JPanel {
|
|||||||
int oy = getRenderOffsetY();
|
int oy = getRenderOffsetY();
|
||||||
int col = (e.getX() - ox) / cellWidth;
|
int col = (e.getX() - ox) / cellWidth;
|
||||||
int row = (e.getY() - oy) / cellHeight;
|
int row = (e.getY() - oy) / cellHeight;
|
||||||
col = Math.max(0, Math.min(col, sb.getCols() - 1));
|
col = Math.max(0, Math.min(col, sb.getDisplayCols() - 1));
|
||||||
row = Math.max(0, Math.min(row, sb.getRows() - 1));
|
row = Math.max(0, Math.min(row, sb.getDisplayRows() - 1));
|
||||||
|
|
||||||
selectionEndRow = row;
|
selectionEndRow = row;
|
||||||
selectionEndCol = col;
|
selectionEndCol = col;
|
||||||
@@ -207,7 +210,8 @@ public class TerminalPanel extends JPanel {
|
|||||||
if (selectionStartRow == selectionEndRow && selectionStartCol == selectionEndCol) {
|
if (selectionStartRow == selectionEndRow && selectionStartCol == selectionEndCol) {
|
||||||
if (client != null && client.getConnectionState().isFullSession()) {
|
if (client != null && client.getConnectionState().isFullSession()) {
|
||||||
ScreenBuffer sb = client.getScreenBuffer();
|
ScreenBuffer sb = client.getScreenBuffer();
|
||||||
int newAddr = selectionStartRow * sb.getCols() + selectionStartCol;
|
int displayCols = sb.getDisplayCols();
|
||||||
|
int newAddr = selectionStartRow * displayCols + selectionStartCol;
|
||||||
sb.setCursorAddress(newAddr);
|
sb.setCursorAddress(newAddr);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
if (lightPenMode) {
|
if (lightPenMode) {
|
||||||
@@ -444,8 +448,8 @@ public class TerminalPanel extends JPanel {
|
|||||||
int termRows = 24;
|
int termRows = 24;
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
ScreenBuffer sb = client.getScreenBuffer();
|
ScreenBuffer sb = client.getScreenBuffer();
|
||||||
termCols = sb.getCols();
|
termCols = sb.getDisplayCols();
|
||||||
termRows = sb.getRows();
|
termRows = sb.getDisplayRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use minimal padding for the fit calculation
|
// Use minimal padding for the fit calculation
|
||||||
@@ -869,8 +873,8 @@ public class TerminalPanel extends JPanel {
|
|||||||
// Use the CURRENT screen dimensions (not max) to eliminate extra space.
|
// Use the CURRENT screen dimensions (not max) to eliminate extra space.
|
||||||
// When the host switches to alternate screen, onScreenSizeChanged fires
|
// When the host switches to alternate screen, onScreenSizeChanged fires
|
||||||
// and the frame re-packs.
|
// and the frame re-packs.
|
||||||
int displayCols = sb.getCols();
|
int displayCols = sb.getDisplayCols();
|
||||||
int displayRows = sb.getRows();
|
int displayRows = sb.getDisplayRows();
|
||||||
return new Dimension(displayCols * cellWidth + padding * 2,
|
return new Dimension(displayCols * cellWidth + padding * 2,
|
||||||
displayRows * cellHeight + padding * 2);
|
displayRows * cellHeight + padding * 2);
|
||||||
}
|
}
|
||||||
@@ -1084,6 +1088,13 @@ public class TerminalPanel extends JPanel {
|
|||||||
g2.fillRect(cx, cy, cellWidth, cellHeight);
|
g2.fillRect(cx, cy, cellWidth, cellHeight);
|
||||||
g2.setPaintMode();
|
g2.setPaintMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw Light Pen mode indicator
|
||||||
|
if (lightPenMode) {
|
||||||
|
g2.setFont(new Font(Font.MONOSPACED, Font.BOLD, 12));
|
||||||
|
g2.setColor(new Color(50, 255, 50));
|
||||||
|
g2.drawString("LP", ox + 2, oy + rows * cellHeight + 14);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color getColorForAttribute(ExtendedAttribute ea, ExtendedAttribute currentFieldEa, byte currentFA) {
|
private Color getColorForAttribute(ExtendedAttribute ea, ExtendedAttribute currentFieldEa, byte currentFA) {
|
||||||
@@ -1126,11 +1137,9 @@ public class TerminalPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
public void toggleLightPen() {
|
public void toggleLightPen() {
|
||||||
this.lightPenMode = !this.lightPenMode;
|
this.lightPenMode = !this.lightPenMode;
|
||||||
if (client != null && client.getGocaDecoder() != null) {
|
System.out.println("Light Pen mode: " + (this.lightPenMode ? "ON" : "OFF"));
|
||||||
client.getGocaDecoder().setGraphicsCursorActive(this.lightPenMode);
|
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLightPenMode() {
|
public boolean isLightPenMode() {
|
||||||
return this.lightPenMode;
|
return this.lightPenMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user