}
/**
- * Update the cursor position.
+ * Update the visible cursor position to match the location of position
+ * and windowStart.
*/
protected void updateCursor() {
if ((position > getWidth()) && fixed) {
}
}
+ /**
+ * Normalize windowStart such that most of the field data if visible.
+ */
+ protected void normalizeWindowStart() {
+ if (fixed) {
+ // windowStart had better be zero, there is nothing to do here.
+ assert (windowStart == 0);
+ return;
+ }
+ windowStart = position - (getWidth() - 1);
+ if (windowStart < 0) {
+ windowStart = 0;
+ }
+
+ updateCursor();
+ }
+
/**
* Handle mouse button presses.
*
windowStart--;
}
}
+ normalizeWindowStart();
return;
}
text = text.substring(0, position)
+ text.substring(position + 1);
}
+ dispatch(false);
return;
}
}
}
dispatch(false);
+ normalizeWindowStart();
return;
}
* @return if true, this widget has a visible cursor
*/
public final boolean isCursorVisible() {
+ // If cursor is out of my bounds, it is not visible.
+ if ((cursorX >= width)
+ || (cursorX < 0)
+ || (cursorY >= height)
+ || (cursorY < 0)
+ ) {
+ return false;
+ }
+
+ // If cursor is out of my window's bounds, it is not visible.
+ if ((getCursorAbsoluteX() >= window.getAbsoluteX()
+ + window.getWidth() - 1)
+ || (getCursorAbsoluteX() < 0)
+ || (getCursorAbsoluteY() >= window.getAbsoluteY()
+ + window.getHeight() - 1)
+ || (getCursorAbsoluteY() < 0)
+ ) {
+ return false;
+ }
return cursorVisible;
}
if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) {
logical[X][Y].setTo(attr);
+
+ // If this happens to be the cursor position, make the position
+ // dirty.
+ if ((cursorX == X) && (cursorY == Y)) {
+ if (physical[cursorX][cursorY].getChar() == 'Q') {
+ physical[cursorX][cursorY].setChar('X');
+ } else {
+ physical[cursorX][cursorY].setChar('Q');
+ }
+ }
}
}
logical[X][Y].setTo(attr);
logical[X][Y].setChar(ch);
+
+ // If this happens to be the cursor position, make the position
+ // dirty.
+ if ((cursorX == X) && (cursorY == Y)) {
+ if (physical[cursorX][cursorY].getChar() == 'Q') {
+ physical[cursorX][cursorY].setChar('X');
+ } else {
+ physical[cursorX][cursorY].setChar('Q');
+ }
+ }
}
}
if ((X >= 0) && (X < width) && (Y >= 0) && (Y < height)) {
logical[X][Y].setChar(ch);
+
+ // If this happens to be the cursor position, make the position
+ // dirty.
+ if ((cursorX == X) && (cursorY == Y)) {
+ if (physical[cursorX][cursorY].getChar() == 'Q') {
+ physical[cursorX][cursorY].setChar('X');
+ } else {
+ physical[cursorX][cursorY].setChar('Q');
+ }
+ }
}
}
addPasswordField(35, row++, 15, false);
addLabel("Fixed-width password:", 1, row);
addPasswordField(35, row++, 15, true, "hunter2");
+ addLabel("Very long text field:", 1, row);
+ TField selected = addField(35, row++, 40, false,
+ "Very very long field text that should be outside the window");
row += 1;
addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
}
);
+ activate(selected);
+
statusBar = newStatusBar("Text fields");
statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");