From: Kevin Lamonte Date: Sun, 22 Mar 2015 04:00:42 +0000 (-0400) Subject: Refactoring - boolean getters and miscellaneous X-Git-Tag: fanfix-3.0.1^2~315 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=7c870d89433346ccb5505f8f9ba62d3fc18fe996;p=fanfix.git Refactoring - boolean getters and miscellaneous --- diff --git a/README.md b/README.md index ee5a265..24b437a 100644 --- a/README.md +++ b/README.md @@ -136,13 +136,6 @@ Many tasks remain before calling this version 1.0: - Block cursor - ECMA48Backend running on socket - TFileOpen -- Decide on naming convention: getText, getValue, getLabel: one or all - of them? -- Refactor: - - TKeypress: - - getCh() --> getChar() - - getAlt/getCtrl/getShift --> isAltDown / isCtrlDown / isShiftDown - - Other boolean getters --> isSomething - Document any properties used - Expose use of 'stty' diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 2b8f47e..8be6af5 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -569,7 +569,7 @@ public class TApplication implements Runnable { /** * Draw everything. */ - public final void drawAll() { + private void drawAll() { if (debugThreads) { System.err.printf("drawAll() enter\n"); } @@ -623,7 +623,7 @@ public class TApplication implements Runnable { for (TMenu menu: menus) { CellAttributes menuColor; CellAttributes menuMnemonicColor; - if (menu.getActive()) { + if (menu.isActive()) { menuColor = theme.getColor("tmenu.highlighted"); menuMnemonicColor = theme.getColor("tmenu.mnemonic.highlighted"); } else { @@ -638,7 +638,7 @@ public class TApplication implements Runnable { getScreen().putCharXY(x + 1 + menu.getMnemonic().getShortcutIdx(), 0, menu.getMnemonic().getShortcut(), menuMnemonicColor); - if (menu.getActive()) { + if (menu.isActive()) { menu.drawChildren(); // Reset the screen clipping so we can draw the next title. getScreen().resetClipping(); @@ -659,7 +659,7 @@ public class TApplication implements Runnable { TWidget activeWidget = null; if (sorted.size() > 0) { activeWidget = sorted.get(sorted.size() - 1).getActiveChild(); - if (activeWidget.visibleCursor()) { + if (activeWidget.isCursorVisible()) { getScreen().putCursor(true, activeWidget.getCursorAbsoluteX(), activeWidget.getCursorAbsoluteY()); cursor = true; @@ -885,11 +885,11 @@ public class TApplication implements Runnable { break; } if ((mouse.getType() == TMouseEvent.Type.MOUSE_MOTION) - && (!mouse.getMouse1()) - && (!mouse.getMouse2()) - && (!mouse.getMouse3()) - && (!mouse.getMouseWheelUp()) - && (!mouse.getMouseWheelDown()) + && (!mouse.isMouse1()) + && (!mouse.isMouse2()) + && (!mouse.isMouse3()) + && (!mouse.isMouseWheelUp()) + && (!mouse.isMouseWheelDown()) ) { break; } @@ -921,7 +921,7 @@ public class TApplication implements Runnable { item = accelerators.get(keypressLowercase); } if (item != null) { - if (item.getEnabled()) { + if (item.isEnabled()) { // Let the menu item dispatch item.dispatch(); return; @@ -947,7 +947,7 @@ public class TApplication implements Runnable { // Dispatch events to the active window ------------------------------- for (TWindow window: windows) { - if (window.getActive()) { + if (window.isActive()) { if (event instanceof TMouseEvent) { TMouseEvent mouse = (TMouseEvent) event; // Convert the mouse relative x/y to window coordinates @@ -1132,7 +1132,7 @@ public class TApplication implements Runnable { // Swap z/active between active window and the next in the list int activeWindowI = -1; for (int i = 0; i < windows.size(); i++) { - if (windows.get(i).getActive()) { + if (windows.get(i).isActive()) { activeWindowI = i; break; } @@ -1241,7 +1241,7 @@ public class TApplication implements Runnable { // See if they hit the menu bar if ((mouse.getType() == TMouseEvent.Type.MOUSE_DOWN) - && (mouse.getMouse1()) + && (mouse.isMouse1()) && (!modalWindowActive()) && (mouse.getAbsoluteY() == 0) ) { @@ -1268,7 +1268,7 @@ public class TApplication implements Runnable { // See if they hit the menu bar if ((mouse.getType() == TMouseEvent.Type.MOUSE_MOTION) - && (mouse.getMouse1()) + && (mouse.isMouse1()) && (activeMenu != null) && (mouse.getAbsoluteY() == 0) ) { @@ -1322,8 +1322,8 @@ public class TApplication implements Runnable { } // We will be switching to another window - assert (windows.get(0).getActive()); - assert (!window.getActive()); + assert (windows.get(0).isActive()); + assert (!window.isActive()); windows.get(0).setActive(false); windows.get(0).setZ(window.getZ()); window.setZ(0); @@ -1481,9 +1481,9 @@ public class TApplication implements Runnable { // Default: only menu shortcuts // Process Alt-F, Alt-E, etc. menu shortcut keys - if (!keypress.getKey().getIsKey() - && keypress.getKey().getAlt() - && !keypress.getKey().getCtrl() + if (!keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() && (activeMenu == null) ) { @@ -1491,7 +1491,7 @@ public class TApplication implements Runnable { for (TMenu menu: menus) { if (Character.toLowerCase(menu.getMnemonic().getShortcut()) - == Character.toLowerCase(keypress.getKey().getCh()) + == Character.toLowerCase(keypress.getKey().getChar()) ) { activeMenu = menu; menu.setActive(true); diff --git a/src/jexer/TButton.java b/src/jexer/TButton.java index 5e5edd0..ce04f5c 100644 --- a/src/jexer/TButton.java +++ b/src/jexer/TButton.java @@ -145,10 +145,10 @@ public final class TButton extends TWidget { shadowColor.setForeColor(Color.BLACK); shadowColor.setBold(false); - if (!getEnabled()) { + if (!isEnabled()) { buttonColor = getTheme().getColor("tbutton.disabled"); menuMnemonicColor = getTheme().getColor("tbutton.disabled"); - } else if (getAbsoluteActive()) { + } else if (isAbsoluteActive()) { buttonColor = getTheme().getColor("tbutton.active"); menuMnemonicColor = getTheme().getColor("tbutton.mnemonic.highlighted"); } else { @@ -191,7 +191,7 @@ public final class TButton extends TWidget { public void onMouseDown(final TMouseEvent mouse) { this.mouse = mouse; - if ((mouseOnButton()) && (mouse.getMouse1())) { + if ((mouseOnButton()) && (mouse.isMouse1())) { // Begin button press inButtonPress = true; } @@ -206,7 +206,7 @@ public final class TButton extends TWidget { public void onMouseUp(final TMouseEvent mouse) { this.mouse = mouse; - if (inButtonPress && mouse.getMouse1()) { + if (inButtonPress && mouse.isMouse1()) { inButtonPress = false; // Dispatch the event if (action != null) { diff --git a/src/jexer/TCheckbox.java b/src/jexer/TCheckbox.java index b33d1f5..1562ca0 100644 --- a/src/jexer/TCheckbox.java +++ b/src/jexer/TCheckbox.java @@ -30,11 +30,11 @@ */ package jexer; +import static jexer.TKeypress.kbSpace; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; -import static jexer.TKeypress.*; /** * TCheckbox implements an on/off checkbox. @@ -46,6 +46,24 @@ public final class TCheckbox extends TWidget { */ private boolean checked = false; + /** + * Get checked value. + * + * @return if true, this is checked + */ + public final boolean isChecked() { + return checked; + } + + /** + * Set checked value. + * + * @param checked new checked value. + */ + public final void setChecked(final boolean checked) { + this.checked = checked; + } + /** * Label for this checkbox. */ @@ -61,7 +79,7 @@ public final class TCheckbox extends TWidget { * @param checked initial check state */ public TCheckbox(final TWidget parent, final int x, final int y, - final String label, final boolean checked) { + final String label, final boolean checked) { // Set parent and window super(parent, x, y, label.length() + 4, 1); @@ -69,7 +87,7 @@ public final class TCheckbox extends TWidget { this.label = label; this.checked = checked; - setHasCursor(true); + setCursorVisible(true); setCursorX(1); } @@ -81,9 +99,9 @@ public final class TCheckbox extends TWidget { */ private boolean mouseOnCheckbox(final TMouseEvent mouse) { if ((mouse.getY() == 0) - && (mouse.getX() >= 0) - && (mouse.getX() <= 2) - ) { + && (mouse.getX() >= 0) + && (mouse.getX() <= 2) + ) { return true; } return false; @@ -96,7 +114,7 @@ public final class TCheckbox extends TWidget { public void draw() { CellAttributes checkboxColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { checkboxColor = getTheme().getColor("tcheckbox.active"); } else { checkboxColor = getTheme().getColor("tcheckbox.inactive"); @@ -119,7 +137,7 @@ public final class TCheckbox extends TWidget { */ @Override public void onMouseDown(final TMouseEvent mouse) { - if ((mouseOnCheckbox(mouse)) && (mouse.getMouse1())) { + if ((mouseOnCheckbox(mouse)) && (mouse.isMouse1())) { // Switch state checked = !checked; } diff --git a/src/jexer/TField.java b/src/jexer/TField.java index 083efdd..07a457b 100644 --- a/src/jexer/TField.java +++ b/src/jexer/TField.java @@ -141,7 +141,7 @@ public class TField extends TWidget { // Set parent and window super(parent, x, y, width, 1); - setHasCursor(true); + setCursorVisible(true); this.fixed = fixed; this.text = text; this.enterAction = enterAction; @@ -190,7 +190,7 @@ public class TField extends TWidget { public void draw() { CellAttributes fieldColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { fieldColor = getTheme().getColor("tfield.active"); } else { fieldColor = getTheme().getColor("tfield.inactive"); @@ -230,7 +230,7 @@ public class TField extends TWidget { public void onMouseDown(final TMouseEvent mouse) { this.mouse = mouse; - if ((mouseOnField()) && (mouse.getMouse1())) { + if ((mouseOnField()) && (mouse.isMouse1())) { // Move cursor int deltaX = mouse.getX() - getCursorX(); position += deltaX; @@ -333,16 +333,16 @@ public class TField extends TWidget { return; } - if (!keypress.getKey().getIsKey() - && !keypress.getKey().getAlt() - && !keypress.getKey().getCtrl() + if (!keypress.getKey().isFnKey() + && !keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() ) { // Plain old keystroke, process it if ((position == text.length()) && (text.length() < getWidth())) { // Append case - appendChar(keypress.getKey().getCh()); + appendChar(keypress.getKey().getChar()); } else if ((position < text.length()) && (text.length() < getWidth())) { @@ -350,12 +350,12 @@ public class TField extends TWidget { if (insertMode == false) { // Replace character text = text.substring(0, position) - + keypress.getKey().getCh() + + keypress.getKey().getChar() + text.substring(position + 1); position++; } else { // Insert character - insertChar(keypress.getKey().getCh()); + insertChar(keypress.getKey().getChar()); } } else if ((position < text.length()) && (text.length() >= getWidth())) { @@ -366,7 +366,7 @@ public class TField extends TWidget { } else if ((fixed == true) && (insertMode == false)) { // Overwrite the last character, maybe move position text = text.substring(0, position) - + keypress.getKey().getCh() + + keypress.getKey().getChar() + text.substring(position + 1); if (position < getWidth() - 1) { position++; @@ -374,23 +374,23 @@ public class TField extends TWidget { } else if ((fixed == false) && (insertMode == false)) { // Overwrite the last character, definitely move position text = text.substring(0, position) - + keypress.getKey().getCh() + + keypress.getKey().getChar() + text.substring(position + 1); position++; } else { if (position == text.length()) { // Append this character - appendChar(keypress.getKey().getCh()); + appendChar(keypress.getKey().getChar()); } else { // Insert this character - insertChar(keypress.getKey().getCh()); + insertChar(keypress.getKey().getChar()); } } } else { assert (!fixed); // Append this character - appendChar(keypress.getKey().getCh()); + appendChar(keypress.getKey().getChar()); } dispatch(false); return; diff --git a/src/jexer/THScroller.java b/src/jexer/THScroller.java index 3539ff4..511bce9 100644 --- a/src/jexer/THScroller.java +++ b/src/jexer/THScroller.java @@ -291,7 +291,7 @@ public final class THScroller extends TWidget { return; } - if ((mouse.getMouse1()) + if ((mouse.isMouse1()) && (inScroll) && (mouse.getX() > 0) && (mouse.getX() < getWidth() - 1) diff --git a/src/jexer/TKeypress.java b/src/jexer/TKeypress.java index 8143f15..531251b 100644 --- a/src/jexer/TKeypress.java +++ b/src/jexer/TKeypress.java @@ -173,31 +173,31 @@ public final class TKeypress { public static final int ESC = 43; /** - * If true, ch is meaningless, use fnKey instead. + * If true, ch is meaningless, use keyCode instead. */ - private boolean isKey; + private boolean isFunctionKey; /** - * Getter for isKey. + * Getter for isFunctionKey. * - * @return if true, ch is meaningless, use fnKey instead + * @return if true, ch is meaningless, use keyCode instead */ - public boolean getIsKey() { - return isKey; + public boolean isFnKey() { + return isFunctionKey; } /** * Will be set to F1, F2, HOME, END, etc. if isKey is true. */ - private int fnKey; + private int keyCode; /** - * Getter for fnKey. + * Getter for function key code. * - * @return fnKey value (only valid is isKey is true) + * @return function key code int value (only valid is isKey is true) */ - public int getFnKey() { - return fnKey; + public int getKeyCode() { + return keyCode; } /** @@ -210,7 +210,7 @@ public final class TKeypress { * * @return alt value */ - public boolean getAlt() { + public boolean isAlt() { return alt; } @@ -224,7 +224,7 @@ public final class TKeypress { * * @return ctrl value */ - public boolean getCtrl() { + public boolean isCtrl() { return ctrl; } @@ -238,7 +238,7 @@ public final class TKeypress { * * @return shift value */ - public boolean getShift() { + public boolean isShift() { return shift; } @@ -252,7 +252,7 @@ public final class TKeypress { * * @return the character (only valid if isKey is false) */ - public char getCh() { + public char getChar() { return ch; } @@ -267,14 +267,14 @@ public final class TKeypress { * @param shift if true, SHIFT was pressed with this keystroke */ public TKeypress(final boolean isKey, final int fnKey, final char ch, - final boolean alt, final boolean ctrl, final boolean shift) { - - this.isKey = isKey; - this.fnKey = fnKey; - this.ch = ch; - this.alt = alt; - this.ctrl = ctrl; - this.shift = shift; + final boolean alt, final boolean ctrl, final boolean shift) { + + this.isFunctionKey = isKey; + this.keyCode = fnKey; + this.ch = ch; + this.alt = alt; + this.ctrl = ctrl; + this.shift = shift; } /** @@ -290,12 +290,12 @@ public final class TKeypress { } TKeypress that = (TKeypress) rhs; - return ((isKey == that.isKey) - && (fnKey == that.fnKey) - && (ch == that.ch) - && (alt == that.alt) - && (ctrl == that.ctrl) - && (shift == that.shift)); + return ((isFunctionKey == that.isFunctionKey) + && (keyCode == that.keyCode) + && (ch == that.ch) + && (alt == that.alt) + && (ctrl == that.ctrl) + && (shift == that.shift)); } /** @@ -308,9 +308,9 @@ public final class TKeypress { int A = 13; int B = 23; int hash = A; - hash = (B * hash) + (isKey ? 1 : 0); - hash = (B * hash) + fnKey; - hash = (B * hash) + (int)ch; + hash = (B * hash) + (isFunctionKey ? 1 : 0); + hash = (B * hash) + keyCode; + hash = (B * hash) + ch; hash = (B * hash) + (alt ? 1 : 0); hash = (B * hash) + (ctrl ? 1 : 0); hash = (B * hash) + (shift ? 1 : 0); @@ -324,138 +324,138 @@ public final class TKeypress { */ @Override public String toString() { - if (isKey) { - switch (fnKey) { + if (isFunctionKey) { + switch (keyCode) { case F1: return String.format("%s%s%sF1", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F2: return String.format("%s%s%sF2", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F3: return String.format("%s%s%sF3", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F4: return String.format("%s%s%sF4", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F5: return String.format("%s%s%sF5", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F6: return String.format("%s%s%sF6", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F7: return String.format("%s%s%sF7", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F8: return String.format("%s%s%sF8", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F9: return String.format("%s%s%sF9", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F10: return String.format("%s%s%sF10", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F11: return String.format("%s%s%sF11", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case F12: return String.format("%s%s%sF12", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case HOME: return String.format("%s%s%sHOME", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case END: return String.format("%s%s%sEND", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case PGUP: return String.format("%s%s%sPGUP", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case PGDN: return String.format("%s%s%sPGDN", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case INS: return String.format("%s%s%sINS", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case DEL: return String.format("%s%s%sDEL", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case RIGHT: return String.format("%s%s%sRIGHT", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case LEFT: return String.format("%s%s%sLEFT", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case UP: return String.format("%s%s%sUP", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case DOWN: return String.format("%s%s%sDOWN", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case TAB: return String.format("%s%s%sTAB", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case BTAB: return String.format("%s%s%sBTAB", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case ENTER: return String.format("%s%s%sENTER", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); case ESC: return String.format("%s%s%sESC", - ctrl ? "Ctrl+" : "", - alt ? "Alt+" : "", - shift ? "Shift+" : ""); + ctrl ? "Ctrl+" : "", + alt ? "Alt+" : "", + shift ? "Shift+" : ""); default: return String.format("--UNKNOWN--"); } @@ -481,7 +481,7 @@ public final class TKeypress { } else if (alt && shift && ctrl) { // Ctrl-Alt-Shift-X return String.format("Ctrl+Alt+Shift+%c", - Character.toUpperCase(ch)); + Character.toUpperCase(ch)); } else { // X return String.format("%c", ch); @@ -496,8 +496,9 @@ public final class TKeypress { * @return a new instance with the key converted */ public TKeypress toLowerCase() { - TKeypress newKey = new TKeypress(isKey, fnKey, ch, alt, ctrl, shift); - if (!isKey && (ch >= 'A') && (ch <= 'Z') && !ctrl && !alt) { + TKeypress newKey = new TKeypress(isFunctionKey, keyCode, ch, alt, ctrl, + shift); + if (!isFunctionKey && (ch >= 'A') && (ch <= 'Z') && !ctrl && !alt) { newKey.shift = false; newKey.ch += 32; } @@ -511,8 +512,9 @@ public final class TKeypress { * @return a new instance with the key converted */ public TKeypress toUpperCase() { - TKeypress newKey = new TKeypress(isKey, fnKey, ch, alt, ctrl, shift); - if (!isKey && (ch >= 'a') && (ch <= 'z') && !ctrl && !alt) { + TKeypress newKey = new TKeypress(isFunctionKey, keyCode, ch, alt, ctrl, + shift); + if (!isFunctionKey && (ch >= 'a') && (ch <= 'z') && !ctrl && !alt) { newKey.shift = true; newKey.ch -= 32; } @@ -521,432 +523,432 @@ public final class TKeypress { // Special "no-key" keypress, used to ignore undefined keystrokes public static final TKeypress kbNoKey = new TKeypress(true, - TKeypress.NONE, ' ', false, false, false); + TKeypress.NONE, ' ', false, false, false); // Normal keys public static final TKeypress kbF1 = new TKeypress(true, - TKeypress.F1, ' ', false, false, false); + TKeypress.F1, ' ', false, false, false); public static final TKeypress kbF2 = new TKeypress(true, - TKeypress.F2, ' ', false, false, false); + TKeypress.F2, ' ', false, false, false); public static final TKeypress kbF3 = new TKeypress(true, - TKeypress.F3, ' ', false, false, false); + TKeypress.F3, ' ', false, false, false); public static final TKeypress kbF4 = new TKeypress(true, - TKeypress.F4, ' ', false, false, false); + TKeypress.F4, ' ', false, false, false); public static final TKeypress kbF5 = new TKeypress(true, - TKeypress.F5, ' ', false, false, false); + TKeypress.F5, ' ', false, false, false); public static final TKeypress kbF6 = new TKeypress(true, - TKeypress.F6, ' ', false, false, false); + TKeypress.F6, ' ', false, false, false); public static final TKeypress kbF7 = new TKeypress(true, - TKeypress.F7, ' ', false, false, false); + TKeypress.F7, ' ', false, false, false); public static final TKeypress kbF8 = new TKeypress(true, - TKeypress.F8, ' ', false, false, false); + TKeypress.F8, ' ', false, false, false); public static final TKeypress kbF9 = new TKeypress(true, - TKeypress.F9, ' ', false, false, false); + TKeypress.F9, ' ', false, false, false); public static final TKeypress kbF10 = new TKeypress(true, - TKeypress.F10, ' ', false, false, false); + TKeypress.F10, ' ', false, false, false); public static final TKeypress kbF11 = new TKeypress(true, - TKeypress.F11, ' ', false, false, false); + TKeypress.F11, ' ', false, false, false); public static final TKeypress kbF12 = new TKeypress(true, - TKeypress.F12, ' ', false, false, false); + TKeypress.F12, ' ', false, false, false); public static final TKeypress kbAltF1 = new TKeypress(true, - TKeypress.F1, ' ', true, false, false); + TKeypress.F1, ' ', true, false, false); public static final TKeypress kbAltF2 = new TKeypress(true, - TKeypress.F2, ' ', true, false, false); + TKeypress.F2, ' ', true, false, false); public static final TKeypress kbAltF3 = new TKeypress(true, - TKeypress.F3, ' ', true, false, false); + TKeypress.F3, ' ', true, false, false); public static final TKeypress kbAltF4 = new TKeypress(true, - TKeypress.F4, ' ', true, false, false); + TKeypress.F4, ' ', true, false, false); public static final TKeypress kbAltF5 = new TKeypress(true, - TKeypress.F5, ' ', true, false, false); + TKeypress.F5, ' ', true, false, false); public static final TKeypress kbAltF6 = new TKeypress(true, - TKeypress.F6, ' ', true, false, false); + TKeypress.F6, ' ', true, false, false); public static final TKeypress kbAltF7 = new TKeypress(true, - TKeypress.F7, ' ', true, false, false); + TKeypress.F7, ' ', true, false, false); public static final TKeypress kbAltF8 = new TKeypress(true, - TKeypress.F8, ' ', true, false, false); + TKeypress.F8, ' ', true, false, false); public static final TKeypress kbAltF9 = new TKeypress(true, - TKeypress.F9, ' ', true, false, false); + TKeypress.F9, ' ', true, false, false); public static final TKeypress kbAltF10 = new TKeypress(true, - TKeypress.F10, ' ', true, false, false); + TKeypress.F10, ' ', true, false, false); public static final TKeypress kbAltF11 = new TKeypress(true, - TKeypress.F11, ' ', true, false, false); + TKeypress.F11, ' ', true, false, false); public static final TKeypress kbAltF12 = new TKeypress(true, - TKeypress.F12, ' ', true, false, false); + TKeypress.F12, ' ', true, false, false); public static final TKeypress kbCtrlF1 = new TKeypress(true, - TKeypress.F1, ' ', false, true, false); + TKeypress.F1, ' ', false, true, false); public static final TKeypress kbCtrlF2 = new TKeypress(true, - TKeypress.F2, ' ', false, true, false); + TKeypress.F2, ' ', false, true, false); public static final TKeypress kbCtrlF3 = new TKeypress(true, - TKeypress.F3, ' ', false, true, false); + TKeypress.F3, ' ', false, true, false); public static final TKeypress kbCtrlF4 = new TKeypress(true, - TKeypress.F4, ' ', false, true, false); + TKeypress.F4, ' ', false, true, false); public static final TKeypress kbCtrlF5 = new TKeypress(true, - TKeypress.F5, ' ', false, true, false); + TKeypress.F5, ' ', false, true, false); public static final TKeypress kbCtrlF6 = new TKeypress(true, - TKeypress.F6, ' ', false, true, false); + TKeypress.F6, ' ', false, true, false); public static final TKeypress kbCtrlF7 = new TKeypress(true, - TKeypress.F7, ' ', false, true, false); + TKeypress.F7, ' ', false, true, false); public static final TKeypress kbCtrlF8 = new TKeypress(true, - TKeypress.F8, ' ', false, true, false); + TKeypress.F8, ' ', false, true, false); public static final TKeypress kbCtrlF9 = new TKeypress(true, - TKeypress.F9, ' ', false, true, false); + TKeypress.F9, ' ', false, true, false); public static final TKeypress kbCtrlF10 = new TKeypress(true, - TKeypress.F10, ' ', false, true, false); + TKeypress.F10, ' ', false, true, false); public static final TKeypress kbCtrlF11 = new TKeypress(true, - TKeypress.F11, ' ', false, true, false); + TKeypress.F11, ' ', false, true, false); public static final TKeypress kbCtrlF12 = new TKeypress(true, - TKeypress.F12, ' ', false, true, false); + TKeypress.F12, ' ', false, true, false); public static final TKeypress kbShiftF1 = new TKeypress(true, - TKeypress.F1, ' ', false, false, true); + TKeypress.F1, ' ', false, false, true); public static final TKeypress kbShiftF2 = new TKeypress(true, - TKeypress.F2, ' ', false, false, true); + TKeypress.F2, ' ', false, false, true); public static final TKeypress kbShiftF3 = new TKeypress(true, - TKeypress.F3, ' ', false, false, true); + TKeypress.F3, ' ', false, false, true); public static final TKeypress kbShiftF4 = new TKeypress(true, - TKeypress.F4, ' ', false, false, true); + TKeypress.F4, ' ', false, false, true); public static final TKeypress kbShiftF5 = new TKeypress(true, - TKeypress.F5, ' ', false, false, true); + TKeypress.F5, ' ', false, false, true); public static final TKeypress kbShiftF6 = new TKeypress(true, - TKeypress.F6, ' ', false, false, true); + TKeypress.F6, ' ', false, false, true); public static final TKeypress kbShiftF7 = new TKeypress(true, - TKeypress.F7, ' ', false, false, true); + TKeypress.F7, ' ', false, false, true); public static final TKeypress kbShiftF8 = new TKeypress(true, - TKeypress.F8, ' ', false, false, true); + TKeypress.F8, ' ', false, false, true); public static final TKeypress kbShiftF9 = new TKeypress(true, - TKeypress.F9, ' ', false, false, true); + TKeypress.F9, ' ', false, false, true); public static final TKeypress kbShiftF10 = new TKeypress(true, - TKeypress.F10, ' ', false, false, true); + TKeypress.F10, ' ', false, false, true); public static final TKeypress kbShiftF11 = new TKeypress(true, - TKeypress.F11, ' ', false, false, true); + TKeypress.F11, ' ', false, false, true); public static final TKeypress kbShiftF12 = new TKeypress(true, - TKeypress.F12, ' ', false, false, true); + TKeypress.F12, ' ', false, false, true); public static final TKeypress kbEnter = new TKeypress(true, - TKeypress.ENTER, ' ', false, false, false); + TKeypress.ENTER, ' ', false, false, false); public static final TKeypress kbTab = new TKeypress(true, - TKeypress.TAB, ' ', false, false, false); + TKeypress.TAB, ' ', false, false, false); public static final TKeypress kbEsc = new TKeypress(true, - TKeypress.ESC, ' ', false, false, false); + TKeypress.ESC, ' ', false, false, false); public static final TKeypress kbHome = new TKeypress(true, - TKeypress.HOME, ' ', false, false, false); + TKeypress.HOME, ' ', false, false, false); public static final TKeypress kbEnd = new TKeypress(true, - TKeypress.END, ' ', false, false, false); + TKeypress.END, ' ', false, false, false); public static final TKeypress kbPgUp = new TKeypress(true, - TKeypress.PGUP, ' ', false, false, false); + TKeypress.PGUP, ' ', false, false, false); public static final TKeypress kbPgDn = new TKeypress(true, - TKeypress.PGDN, ' ', false, false, false); + TKeypress.PGDN, ' ', false, false, false); public static final TKeypress kbIns = new TKeypress(true, - TKeypress.INS, ' ', false, false, false); + TKeypress.INS, ' ', false, false, false); public static final TKeypress kbDel = new TKeypress(true, - TKeypress.DEL, ' ', false, false, false); + TKeypress.DEL, ' ', false, false, false); public static final TKeypress kbUp = new TKeypress(true, - TKeypress.UP, ' ', false, false, false); + TKeypress.UP, ' ', false, false, false); public static final TKeypress kbDown = new TKeypress(true, - TKeypress.DOWN, ' ', false, false, false); + TKeypress.DOWN, ' ', false, false, false); public static final TKeypress kbLeft = new TKeypress(true, - TKeypress.LEFT, ' ', false, false, false); + TKeypress.LEFT, ' ', false, false, false); public static final TKeypress kbRight = new TKeypress(true, - TKeypress.RIGHT, ' ', false, false, false); + TKeypress.RIGHT, ' ', false, false, false); public static final TKeypress kbAltEnter = new TKeypress(true, - TKeypress.ENTER, ' ', true, false, false); + TKeypress.ENTER, ' ', true, false, false); public static final TKeypress kbAltTab = new TKeypress(true, - TKeypress.TAB, ' ', true, false, false); + TKeypress.TAB, ' ', true, false, false); public static final TKeypress kbAltEsc = new TKeypress(true, - TKeypress.ESC, ' ', true, false, false); + TKeypress.ESC, ' ', true, false, false); public static final TKeypress kbAltHome = new TKeypress(true, - TKeypress.HOME, ' ', true, false, false); + TKeypress.HOME, ' ', true, false, false); public static final TKeypress kbAltEnd = new TKeypress(true, - TKeypress.END, ' ', true, false, false); + TKeypress.END, ' ', true, false, false); public static final TKeypress kbAltPgUp = new TKeypress(true, - TKeypress.PGUP, ' ', true, false, false); + TKeypress.PGUP, ' ', true, false, false); public static final TKeypress kbAltPgDn = new TKeypress(true, - TKeypress.PGDN, ' ', true, false, false); + TKeypress.PGDN, ' ', true, false, false); public static final TKeypress kbAltIns = new TKeypress(true, - TKeypress.INS, ' ', true, false, false); + TKeypress.INS, ' ', true, false, false); public static final TKeypress kbAltDel = new TKeypress(true, - TKeypress.DEL, ' ', true, false, false); + TKeypress.DEL, ' ', true, false, false); public static final TKeypress kbAltUp = new TKeypress(true, - TKeypress.UP, ' ', true, false, false); + TKeypress.UP, ' ', true, false, false); public static final TKeypress kbAltDown = new TKeypress(true, - TKeypress.DOWN, ' ', true, false, false); + TKeypress.DOWN, ' ', true, false, false); public static final TKeypress kbAltLeft = new TKeypress(true, - TKeypress.LEFT, ' ', true, false, false); + TKeypress.LEFT, ' ', true, false, false); public static final TKeypress kbAltRight = new TKeypress(true, - TKeypress.RIGHT, ' ', true, false, false); + TKeypress.RIGHT, ' ', true, false, false); public static final TKeypress kbCtrlEnter = new TKeypress(true, - TKeypress.ENTER, ' ', false, true, false); + TKeypress.ENTER, ' ', false, true, false); public static final TKeypress kbCtrlTab = new TKeypress(true, - TKeypress.TAB, ' ', false, true, false); + TKeypress.TAB, ' ', false, true, false); public static final TKeypress kbCtrlEsc = new TKeypress(true, - TKeypress.ESC, ' ', false, true, false); + TKeypress.ESC, ' ', false, true, false); public static final TKeypress kbCtrlHome = new TKeypress(true, - TKeypress.HOME, ' ', false, true, false); + TKeypress.HOME, ' ', false, true, false); public static final TKeypress kbCtrlEnd = new TKeypress(true, - TKeypress.END, ' ', false, true, false); + TKeypress.END, ' ', false, true, false); public static final TKeypress kbCtrlPgUp = new TKeypress(true, - TKeypress.PGUP, ' ', false, true, false); + TKeypress.PGUP, ' ', false, true, false); public static final TKeypress kbCtrlPgDn = new TKeypress(true, - TKeypress.PGDN, ' ', false, true, false); + TKeypress.PGDN, ' ', false, true, false); public static final TKeypress kbCtrlIns = new TKeypress(true, - TKeypress.INS, ' ', false, true, false); + TKeypress.INS, ' ', false, true, false); public static final TKeypress kbCtrlDel = new TKeypress(true, - TKeypress.DEL, ' ', false, true, false); + TKeypress.DEL, ' ', false, true, false); public static final TKeypress kbCtrlUp = new TKeypress(true, - TKeypress.UP, ' ', false, true, false); + TKeypress.UP, ' ', false, true, false); public static final TKeypress kbCtrlDown = new TKeypress(true, - TKeypress.DOWN, ' ', false, true, false); + TKeypress.DOWN, ' ', false, true, false); public static final TKeypress kbCtrlLeft = new TKeypress(true, - TKeypress.LEFT, ' ', false, true, false); + TKeypress.LEFT, ' ', false, true, false); public static final TKeypress kbCtrlRight = new TKeypress(true, - TKeypress.RIGHT, ' ', false, true, false); + TKeypress.RIGHT, ' ', false, true, false); public static final TKeypress kbShiftEnter = new TKeypress(true, - TKeypress.ENTER, ' ', false, false, true); + TKeypress.ENTER, ' ', false, false, true); public static final TKeypress kbShiftTab = new TKeypress(true, - TKeypress.TAB, ' ', false, false, true); + TKeypress.TAB, ' ', false, false, true); public static final TKeypress kbBackTab = new TKeypress(true, - TKeypress.BTAB, ' ', false, false, false); + TKeypress.BTAB, ' ', false, false, false); public static final TKeypress kbShiftEsc = new TKeypress(true, - TKeypress.ESC, ' ', false, false, true); + TKeypress.ESC, ' ', false, false, true); public static final TKeypress kbShiftHome = new TKeypress(true, - TKeypress.HOME, ' ', false, false, true); + TKeypress.HOME, ' ', false, false, true); public static final TKeypress kbShiftEnd = new TKeypress(true, - TKeypress.END, ' ', false, false, true); + TKeypress.END, ' ', false, false, true); public static final TKeypress kbShiftPgUp = new TKeypress(true, - TKeypress.PGUP, ' ', false, false, true); + TKeypress.PGUP, ' ', false, false, true); public static final TKeypress kbShiftPgDn = new TKeypress(true, - TKeypress.PGDN, ' ', false, false, true); + TKeypress.PGDN, ' ', false, false, true); public static final TKeypress kbShiftIns = new TKeypress(true, - TKeypress.INS, ' ', false, false, true); + TKeypress.INS, ' ', false, false, true); public static final TKeypress kbShiftDel = new TKeypress(true, - TKeypress.DEL, ' ', false, false, true); + TKeypress.DEL, ' ', false, false, true); public static final TKeypress kbShiftUp = new TKeypress(true, - TKeypress.UP, ' ', false, false, true); + TKeypress.UP, ' ', false, false, true); public static final TKeypress kbShiftDown = new TKeypress(true, - TKeypress.DOWN, ' ', false, false, true); + TKeypress.DOWN, ' ', false, false, true); public static final TKeypress kbShiftLeft = new TKeypress(true, - TKeypress.LEFT, ' ', false, false, true); + TKeypress.LEFT, ' ', false, false, true); public static final TKeypress kbShiftRight = new TKeypress(true, - TKeypress.RIGHT, ' ', false, false, true); + TKeypress.RIGHT, ' ', false, false, true); public static final TKeypress kbA = new TKeypress(false, - 0, 'a', false, false, false); + 0, 'a', false, false, false); public static final TKeypress kbB = new TKeypress(false, - 0, 'b', false, false, false); + 0, 'b', false, false, false); public static final TKeypress kbC = new TKeypress(false, - 0, 'c', false, false, false); + 0, 'c', false, false, false); public static final TKeypress kbD = new TKeypress(false, - 0, 'd', false, false, false); + 0, 'd', false, false, false); public static final TKeypress kbE = new TKeypress(false, - 0, 'e', false, false, false); + 0, 'e', false, false, false); public static final TKeypress kbF = new TKeypress(false, - 0, 'f', false, false, false); + 0, 'f', false, false, false); public static final TKeypress kbG = new TKeypress(false, - 0, 'g', false, false, false); + 0, 'g', false, false, false); public static final TKeypress kbH = new TKeypress(false, - 0, 'h', false, false, false); + 0, 'h', false, false, false); public static final TKeypress kbI = new TKeypress(false, - 0, 'i', false, false, false); + 0, 'i', false, false, false); public static final TKeypress kbJ = new TKeypress(false, - 0, 'j', false, false, false); + 0, 'j', false, false, false); public static final TKeypress kbK = new TKeypress(false, - 0, 'k', false, false, false); + 0, 'k', false, false, false); public static final TKeypress kbL = new TKeypress(false, - 0, 'l', false, false, false); + 0, 'l', false, false, false); public static final TKeypress kbM = new TKeypress(false, - 0, 'm', false, false, false); + 0, 'm', false, false, false); public static final TKeypress kbN = new TKeypress(false, - 0, 'n', false, false, false); + 0, 'n', false, false, false); public static final TKeypress kbO = new TKeypress(false, - 0, 'o', false, false, false); + 0, 'o', false, false, false); public static final TKeypress kbP = new TKeypress(false, - 0, 'p', false, false, false); + 0, 'p', false, false, false); public static final TKeypress kbQ = new TKeypress(false, - 0, 'q', false, false, false); + 0, 'q', false, false, false); public static final TKeypress kbR = new TKeypress(false, - 0, 'r', false, false, false); + 0, 'r', false, false, false); public static final TKeypress kbS = new TKeypress(false, - 0, 's', false, false, false); + 0, 's', false, false, false); public static final TKeypress kbT = new TKeypress(false, - 0, 't', false, false, false); + 0, 't', false, false, false); public static final TKeypress kbU = new TKeypress(false, - 0, 'u', false, false, false); + 0, 'u', false, false, false); public static final TKeypress kbV = new TKeypress(false, - 0, 'v', false, false, false); + 0, 'v', false, false, false); public static final TKeypress kbW = new TKeypress(false, - 0, 'w', false, false, false); + 0, 'w', false, false, false); public static final TKeypress kbX = new TKeypress(false, - 0, 'x', false, false, false); + 0, 'x', false, false, false); public static final TKeypress kbY = new TKeypress(false, - 0, 'y', false, false, false); + 0, 'y', false, false, false); public static final TKeypress kbZ = new TKeypress(false, - 0, 'z', false, false, false); + 0, 'z', false, false, false); public static final TKeypress kbSpace = new TKeypress(false, - 0, ' ', false, false, false); + 0, ' ', false, false, false); public static final TKeypress kbAltA = new TKeypress(false, - 0, 'a', true, false, false); + 0, 'a', true, false, false); public static final TKeypress kbAltB = new TKeypress(false, - 0, 'b', true, false, false); + 0, 'b', true, false, false); public static final TKeypress kbAltC = new TKeypress(false, - 0, 'c', true, false, false); + 0, 'c', true, false, false); public static final TKeypress kbAltD = new TKeypress(false, - 0, 'd', true, false, false); + 0, 'd', true, false, false); public static final TKeypress kbAltE = new TKeypress(false, - 0, 'e', true, false, false); + 0, 'e', true, false, false); public static final TKeypress kbAltF = new TKeypress(false, - 0, 'f', true, false, false); + 0, 'f', true, false, false); public static final TKeypress kbAltG = new TKeypress(false, - 0, 'g', true, false, false); + 0, 'g', true, false, false); public static final TKeypress kbAltH = new TKeypress(false, - 0, 'h', true, false, false); + 0, 'h', true, false, false); public static final TKeypress kbAltI = new TKeypress(false, - 0, 'i', true, false, false); + 0, 'i', true, false, false); public static final TKeypress kbAltJ = new TKeypress(false, - 0, 'j', true, false, false); + 0, 'j', true, false, false); public static final TKeypress kbAltK = new TKeypress(false, - 0, 'k', true, false, false); + 0, 'k', true, false, false); public static final TKeypress kbAltL = new TKeypress(false, - 0, 'l', true, false, false); + 0, 'l', true, false, false); public static final TKeypress kbAltM = new TKeypress(false, - 0, 'm', true, false, false); + 0, 'm', true, false, false); public static final TKeypress kbAltN = new TKeypress(false, - 0, 'n', true, false, false); + 0, 'n', true, false, false); public static final TKeypress kbAltO = new TKeypress(false, - 0, 'o', true, false, false); + 0, 'o', true, false, false); public static final TKeypress kbAltP = new TKeypress(false, - 0, 'p', true, false, false); + 0, 'p', true, false, false); public static final TKeypress kbAltQ = new TKeypress(false, - 0, 'q', true, false, false); + 0, 'q', true, false, false); public static final TKeypress kbAltR = new TKeypress(false, - 0, 'r', true, false, false); + 0, 'r', true, false, false); public static final TKeypress kbAltS = new TKeypress(false, - 0, 's', true, false, false); + 0, 's', true, false, false); public static final TKeypress kbAltT = new TKeypress(false, - 0, 't', true, false, false); + 0, 't', true, false, false); public static final TKeypress kbAltU = new TKeypress(false, - 0, 'u', true, false, false); + 0, 'u', true, false, false); public static final TKeypress kbAltV = new TKeypress(false, - 0, 'v', true, false, false); + 0, 'v', true, false, false); public static final TKeypress kbAltW = new TKeypress(false, - 0, 'w', true, false, false); + 0, 'w', true, false, false); public static final TKeypress kbAltX = new TKeypress(false, - 0, 'x', true, false, false); + 0, 'x', true, false, false); public static final TKeypress kbAltY = new TKeypress(false, - 0, 'y', true, false, false); + 0, 'y', true, false, false); public static final TKeypress kbAltZ = new TKeypress(false, - 0, 'z', true, false, false); + 0, 'z', true, false, false); public static final TKeypress kbCtrlA = new TKeypress(false, - 0, 'A', false, true, false); + 0, 'A', false, true, false); public static final TKeypress kbCtrlB = new TKeypress(false, - 0, 'B', false, true, false); + 0, 'B', false, true, false); public static final TKeypress kbCtrlC = new TKeypress(false, - 0, 'C', false, true, false); + 0, 'C', false, true, false); public static final TKeypress kbCtrlD = new TKeypress(false, - 0, 'D', false, true, false); + 0, 'D', false, true, false); public static final TKeypress kbCtrlE = new TKeypress(false, - 0, 'E', false, true, false); + 0, 'E', false, true, false); public static final TKeypress kbCtrlF = new TKeypress(false, - 0, 'F', false, true, false); + 0, 'F', false, true, false); public static final TKeypress kbCtrlG = new TKeypress(false, - 0, 'G', false, true, false); + 0, 'G', false, true, false); public static final TKeypress kbCtrlH = new TKeypress(false, - 0, 'H', false, true, false); + 0, 'H', false, true, false); public static final TKeypress kbCtrlI = new TKeypress(false, - 0, 'I', false, true, false); + 0, 'I', false, true, false); public static final TKeypress kbCtrlJ = new TKeypress(false, - 0, 'J', false, true, false); + 0, 'J', false, true, false); public static final TKeypress kbCtrlK = new TKeypress(false, - 0, 'K', false, true, false); + 0, 'K', false, true, false); public static final TKeypress kbCtrlL = new TKeypress(false, - 0, 'L', false, true, false); + 0, 'L', false, true, false); public static final TKeypress kbCtrlM = new TKeypress(false, - 0, 'M', false, true, false); + 0, 'M', false, true, false); public static final TKeypress kbCtrlN = new TKeypress(false, - 0, 'N', false, true, false); + 0, 'N', false, true, false); public static final TKeypress kbCtrlO = new TKeypress(false, - 0, 'O', false, true, false); + 0, 'O', false, true, false); public static final TKeypress kbCtrlP = new TKeypress(false, - 0, 'P', false, true, false); + 0, 'P', false, true, false); public static final TKeypress kbCtrlQ = new TKeypress(false, - 0, 'Q', false, true, false); + 0, 'Q', false, true, false); public static final TKeypress kbCtrlR = new TKeypress(false, - 0, 'R', false, true, false); + 0, 'R', false, true, false); public static final TKeypress kbCtrlS = new TKeypress(false, - 0, 'S', false, true, false); + 0, 'S', false, true, false); public static final TKeypress kbCtrlT = new TKeypress(false, - 0, 'T', false, true, false); + 0, 'T', false, true, false); public static final TKeypress kbCtrlU = new TKeypress(false, - 0, 'U', false, true, false); + 0, 'U', false, true, false); public static final TKeypress kbCtrlV = new TKeypress(false, - 0, 'V', false, true, false); + 0, 'V', false, true, false); public static final TKeypress kbCtrlW = new TKeypress(false, - 0, 'W', false, true, false); + 0, 'W', false, true, false); public static final TKeypress kbCtrlX = new TKeypress(false, - 0, 'X', false, true, false); + 0, 'X', false, true, false); public static final TKeypress kbCtrlY = new TKeypress(false, - 0, 'Y', false, true, false); + 0, 'Y', false, true, false); public static final TKeypress kbCtrlZ = new TKeypress(false, - 0, 'Z', false, true, false); + 0, 'Z', false, true, false); public static final TKeypress kbAltShiftA = new TKeypress(false, - 0, 'A', true, false, true); + 0, 'A', true, false, true); public static final TKeypress kbAltShiftB = new TKeypress(false, - 0, 'B', true, false, true); + 0, 'B', true, false, true); public static final TKeypress kbAltShiftC = new TKeypress(false, - 0, 'C', true, false, true); + 0, 'C', true, false, true); public static final TKeypress kbAltShiftD = new TKeypress(false, - 0, 'D', true, false, true); + 0, 'D', true, false, true); public static final TKeypress kbAltShiftE = new TKeypress(false, - 0, 'E', true, false, true); + 0, 'E', true, false, true); public static final TKeypress kbAltShiftF = new TKeypress(false, - 0, 'F', true, false, true); + 0, 'F', true, false, true); public static final TKeypress kbAltShiftG = new TKeypress(false, - 0, 'G', true, false, true); + 0, 'G', true, false, true); public static final TKeypress kbAltShiftH = new TKeypress(false, - 0, 'H', true, false, true); + 0, 'H', true, false, true); public static final TKeypress kbAltShiftI = new TKeypress(false, - 0, 'I', true, false, true); + 0, 'I', true, false, true); public static final TKeypress kbAltShiftJ = new TKeypress(false, - 0, 'J', true, false, true); + 0, 'J', true, false, true); public static final TKeypress kbAltShiftK = new TKeypress(false, - 0, 'K', true, false, true); + 0, 'K', true, false, true); public static final TKeypress kbAltShiftL = new TKeypress(false, - 0, 'L', true, false, true); + 0, 'L', true, false, true); public static final TKeypress kbAltShiftM = new TKeypress(false, - 0, 'M', true, false, true); + 0, 'M', true, false, true); public static final TKeypress kbAltShiftN = new TKeypress(false, - 0, 'N', true, false, true); + 0, 'N', true, false, true); public static final TKeypress kbAltShiftO = new TKeypress(false, - 0, 'O', true, false, true); + 0, 'O', true, false, true); public static final TKeypress kbAltShiftP = new TKeypress(false, - 0, 'P', true, false, true); + 0, 'P', true, false, true); public static final TKeypress kbAltShiftQ = new TKeypress(false, - 0, 'Q', true, false, true); + 0, 'Q', true, false, true); public static final TKeypress kbAltShiftR = new TKeypress(false, - 0, 'R', true, false, true); + 0, 'R', true, false, true); public static final TKeypress kbAltShiftS = new TKeypress(false, - 0, 'S', true, false, true); + 0, 'S', true, false, true); public static final TKeypress kbAltShiftT = new TKeypress(false, - 0, 'T', true, false, true); + 0, 'T', true, false, true); public static final TKeypress kbAltShiftU = new TKeypress(false, - 0, 'U', true, false, true); + 0, 'U', true, false, true); public static final TKeypress kbAltShiftV = new TKeypress(false, - 0, 'V', true, false, true); + 0, 'V', true, false, true); public static final TKeypress kbAltShiftW = new TKeypress(false, - 0, 'W', true, false, true); + 0, 'W', true, false, true); public static final TKeypress kbAltShiftX = new TKeypress(false, - 0, 'X', true, false, true); + 0, 'X', true, false, true); public static final TKeypress kbAltShiftY = new TKeypress(false, - 0, 'Y', true, false, true); + 0, 'Y', true, false, true); public static final TKeypress kbAltShiftZ = new TKeypress(false, - 0, 'Z', true, false, true); + 0, 'Z', true, false, true); /** * Backspace as ^H. */ public static final TKeypress kbBackspace = new TKeypress(false, - 0, 'H', false, true, false); + 0, 'H', false, true, false); /** * Backspace as ^?. */ public static final TKeypress kbBackspaceDel = new TKeypress(false, - 0, (char)0x7F, false, false, false); + 0, (char)0x7F, false, false, false); } diff --git a/src/jexer/TLabel.java b/src/jexer/TLabel.java index e57ad9b..ad30035 100644 --- a/src/jexer/TLabel.java +++ b/src/jexer/TLabel.java @@ -40,24 +40,24 @@ public final class TLabel extends TWidget { /** * Label text. */ - private String text = ""; + private String label = ""; /** * Get label text. * * @return label text */ - public String getText() { - return text; + public String getLabel() { + return label; } /** * Set label text. * - * @param text new label text + * @param label new label text */ - public void setText(final String text) { - this.text = text; + public void setLabel(final String label) { + this.label = label; } /** @@ -94,7 +94,7 @@ public final class TLabel extends TWidget { // Set parent and window super(parent, false, x, y, text.length(), 1); - this.text = text; + this.label = text; this.colorKey = colorKey; } @@ -108,7 +108,7 @@ public final class TLabel extends TWidget { CellAttributes background = getWindow().getBackground(); color.setBackColor(background.getBackColor()); - getScreen().putStrXY(0, 0, text, color); + getScreen().putStrXY(0, 0, label, color); } } diff --git a/src/jexer/TPasswordField.java b/src/jexer/TPasswordField.java index 8fd29d0..5cb9732 100644 --- a/src/jexer/TPasswordField.java +++ b/src/jexer/TPasswordField.java @@ -97,7 +97,7 @@ public final class TPasswordField extends TField { CellAttributes fieldColor; boolean showStars = false; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { fieldColor = getTheme().getColor("tfield.active"); } else { fieldColor = getTheme().getColor("tfield.inactive"); diff --git a/src/jexer/TRadioButton.java b/src/jexer/TRadioButton.java index 685f1f4..ddeec09 100644 --- a/src/jexer/TRadioButton.java +++ b/src/jexer/TRadioButton.java @@ -52,7 +52,7 @@ public final class TRadioButton extends TWidget { * @return if true then this is the one button in the group that is * selected */ - public boolean getSelected() { + public boolean isSelected() { return selected; } @@ -106,7 +106,7 @@ public final class TRadioButton extends TWidget { this.label = label; this.id = id; - setHasCursor(true); + setCursorVisible(true); setCursorX(1); } @@ -133,7 +133,7 @@ public final class TRadioButton extends TWidget { public void draw() { CellAttributes radioButtonColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { radioButtonColor = getTheme().getColor("tradiobutton.active"); } else { radioButtonColor = getTheme().getColor("tradiobutton.inactive"); @@ -157,7 +157,7 @@ public final class TRadioButton extends TWidget { */ @Override public void onMouseDown(final TMouseEvent mouse) { - if ((mouseOnRadioButton(mouse)) && (mouse.getMouse1())) { + if ((mouseOnRadioButton(mouse)) && (mouse.isMouse1())) { // Switch state selected = !selected; if (selected) { diff --git a/src/jexer/TRadioGroup.java b/src/jexer/TRadioGroup.java index e2e24a3..723148f 100644 --- a/src/jexer/TRadioGroup.java +++ b/src/jexer/TRadioGroup.java @@ -65,7 +65,7 @@ public final class TRadioGroup extends TWidget { * @param button new button that became selected */ void setSelected(final TRadioButton button) { - assert (button.getSelected()); + assert (button.isSelected()); if (selectedButton != null) { selectedButton.setSelected(false); } @@ -96,7 +96,7 @@ public final class TRadioGroup extends TWidget { public void draw() { CellAttributes radioGroupColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { radioGroupColor = getTheme().getColor("tradiogroup.active"); } else { radioGroupColor = getTheme().getColor("tradiogroup.inactive"); diff --git a/src/jexer/TTerminalWindow.java b/src/jexer/TTerminalWindow.java index 010cc49..f85e346 100644 --- a/src/jexer/TTerminalWindow.java +++ b/src/jexer/TTerminalWindow.java @@ -208,7 +208,7 @@ public class TTerminalWindow extends TWindow { Cell ch = line.charAt(i); Cell newCell = new Cell(); newCell.setTo(ch); - boolean reverse = line.isReverseColor() ^ ch.getReverse(); + boolean reverse = line.isReverseColor() ^ ch.isReverse(); newCell.setReverse(false); if (reverse) { newCell.setBackColor(ch.getForeColor()); @@ -265,12 +265,12 @@ public class TTerminalWindow extends TWindow { if (vScroller != null) { setCursorY(getCursorY() - vScroller.getValue()); } - setHasCursor(emulator.visibleCursor()); + setCursorVisible(emulator.isCursorVisible()); if (getCursorX() > getWidth() - 2) { - setHasCursor(false); + setCursorVisible(false); } if ((getCursorY() > getHeight() - 2) || (getCursorY() < 0)) { - setHasCursor(false); + setCursorVisible(false); } if (emulator.getScreenTitle().length() > 0) { // Only update the title if the shell is still alive @@ -444,11 +444,11 @@ public class TTerminalWindow extends TWindow { return; } - if (mouse.getMouseWheelUp()) { + if (mouse.isMouseWheelUp()) { vScroller.decrement(); return; } - if (mouse.getMouseWheelDown()) { + if (mouse.isMouseWheelDown()) { vScroller.increment(); return; } diff --git a/src/jexer/TText.java b/src/jexer/TText.java index 6d2fe27..64e96bb 100644 --- a/src/jexer/TText.java +++ b/src/jexer/TText.java @@ -30,16 +30,25 @@ */ package jexer; +import static jexer.TKeypress.kbDown; +import static jexer.TKeypress.kbEnd; +import static jexer.TKeypress.kbHome; +import static jexer.TKeypress.kbLeft; +import static jexer.TKeypress.kbPgDn; +import static jexer.TKeypress.kbPgUp; +import static jexer.TKeypress.kbRight; +import static jexer.TKeypress.kbUp; + import java.util.LinkedList; import java.util.List; import jexer.bits.CellAttributes; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; -import static jexer.TKeypress.*; /** - * TText implements a simple text windget. + * TText implements a simple scrollable text area. It reflows automatically on + * resize. */ public final class TText extends TWidget { @@ -81,7 +90,8 @@ public final class TText extends TWidget { /** * Convenience method used by TWindowLoggerOutput. * - * @param line new line to add + * @param line + * new line to add */ public void addLine(final String line) { if (text.length() == 0) { @@ -98,13 +108,13 @@ public final class TText extends TWidget { */ private void computeBounds() { maxLineWidth = 0; - for (String line: lines) { + for (String line : lines) { if (line.length() > maxLineWidth) { maxLineWidth = line.length(); } } - vScroller.setBottomValue(lines.size() - getHeight() + 1); + vScroller.setBottomValue((lines.size() - getHeight()) + 1); if (vScroller.getBottomValue() < 0) { vScroller.setBottomValue(0); } @@ -112,7 +122,7 @@ public final class TText extends TWidget { vScroller.setValue(vScroller.getBottomValue()); } - hScroller.setRightValue(maxLineWidth - getWidth() + 1); + hScroller.setRightValue((maxLineWidth - getWidth()) + 1); if (hScroller.getRightValue() < 0) { hScroller.setRightValue(0); } @@ -122,12 +132,14 @@ public final class TText extends TWidget { } /** - * Insert newlines into a string to wrap it to a maximum column. - * Terminate the final string with a newline. Note that interior - * newlines are converted to spaces. + * Insert newlines into a string to wrap it to a maximum column. Terminate + * the final string with a newline. Note that interior newlines are + * converted to spaces. * - * @param str the string - * @param n the maximum number of characters in a line + * @param str + * the string + * @param n + * the maximum number of characters in a line * @return the wrapped string */ private String wrap(final String str, final int n) { @@ -144,7 +156,7 @@ public final class TText extends TWidget { if (ch == ' ') { sb.append(word.toString()); sb.append(ch); - if (word.length() >= n - 1) { + if (word.length() >= (n - 1)) { sb.append('\n'); col = 0; } @@ -154,7 +166,7 @@ public final class TText extends TWidget { } col++; - if (col >= n - 1) { + if (col >= (n - 1)) { sb.append('\n'); col = 0; } @@ -164,7 +176,6 @@ public final class TText extends TWidget { return sb.toString(); } - /** * Resize text and scrollbars for a new width/height. */ @@ -173,10 +184,10 @@ public final class TText extends TWidget { lines.clear(); // Break up text into paragraphs - String [] paragraphs = text.split("\n\n"); - for (String p: paragraphs) { + String[] paragraphs = text.split("\n\n"); + for (String p : paragraphs) { String paragraph = wrap(p, getWidth() - 1); - for (String line: paragraph.split("\n")) { + for (String line : paragraph.split("\n")) { lines.add(line); } for (int i = 0; i < lineSpacing; i++) { @@ -186,8 +197,7 @@ public final class TText extends TWidget { // Start at the top if (vScroller == null) { - vScroller = new TVScroller(this, getWidth() - 1, 0, - getHeight() - 1); + vScroller = new TVScroller(this, getWidth() - 1, 0, getHeight() - 1); vScroller.setTopValue(0); vScroller.setValue(0); } else { @@ -198,8 +208,7 @@ public final class TText extends TWidget { // Start at the left if (hScroller == null) { - hScroller = new THScroller(this, 0, getHeight() - 1, - getWidth() - 1); + hScroller = new THScroller(this, 0, getHeight() - 1, getWidth() - 1); hScroller.setLeftValue(0); hScroller.setValue(0); } else { @@ -214,15 +223,21 @@ public final class TText extends TWidget { /** * Public constructor. * - * @param parent parent widget - * @param text text on the screen - * @param x column relative to parent - * @param y row relative to parent - * @param width width of text area - * @param height height of text area + * @param parent + * parent widget + * @param text + * text on the screen + * @param x + * column relative to parent + * @param y + * row relative to parent + * @param width + * width of text area + * @param height + * height of text area */ public TText(final TWidget parent, final String text, final int x, - final int y, final int width, final int height) { + final int y, final int width, final int height) { this(parent, text, x, y, width, height, "ttext"); } @@ -230,17 +245,25 @@ public final class TText extends TWidget { /** * Public constructor. * - * @param parent parent widget - * @param text text on the screen - * @param x column relative to parent - * @param y row relative to parent - * @param width width of text area - * @param height height of text area - * @param colorKey ColorTheme key color to use for foreground text. - * Default is "ttext" + * @param parent + * parent widget + * @param text + * text on the screen + * @param x + * column relative to parent + * @param y + * row relative to parent + * @param width + * width of text area + * @param height + * height of text area + * @param colorKey + * ColorTheme key color to use for foreground text. Default is + * "ttext" */ public TText(final TWidget parent, final String text, final int x, - final int y, final int width, final int height, final String colorKey) { + final int y, final int width, final int height, + final String colorKey) { // Set parent and window super(parent, x, y, width, height); @@ -272,16 +295,16 @@ public final class TText extends TWidget { } String formatString = "%-" + Integer.toString(getWidth() - 1) + "s"; getScreen().putStrXY(0, topY, String.format(formatString, line), - color); + color); topY++; - if (topY >= getHeight() - 1) { + if (topY >= (getHeight() - 1)) { break; } } // Pad the rest with blank lines - for (int i = topY; i < getHeight() - 1; i++) { + for (int i = topY; i < (getHeight() - 1); i++) { getScreen().hLineXY(0, i, getWidth() - 1, ' ', color); } @@ -290,15 +313,16 @@ public final class TText extends TWidget { /** * Handle mouse press events. * - * @param mouse mouse button press event + * @param mouse + * mouse button press event */ @Override public void onMouseDown(final TMouseEvent mouse) { - if (mouse.getMouseWheelUp()) { + if (mouse.isMouseWheelUp()) { vScroller.decrement(); return; } - if (mouse.getMouseWheelDown()) { + if (mouse.isMouseWheelDown()) { vScroller.increment(); return; } @@ -310,7 +334,8 @@ public final class TText extends TWidget { /** * Handle keystrokes. * - * @param keypress keystroke event + * @param keypress + * keystroke event */ @Override public void onKeypress(final TKeypressEvent keypress) { diff --git a/src/jexer/TVScroller.java b/src/jexer/TVScroller.java index 51fcd85..fd806e7 100644 --- a/src/jexer/TVScroller.java +++ b/src/jexer/TVScroller.java @@ -328,7 +328,7 @@ public final class TVScroller extends TWidget { return; } - if ((mouse.getMouse1()) && + if ((mouse.isMouse1()) && (inScroll) && (mouse.getY() > 0) && (mouse.getY() < getHeight() - 1) diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 6cb0f98..7ea1a42 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -133,7 +133,7 @@ public abstract class TWidget implements Comparable { * * @return if true, this widget will receive events */ - public final boolean getActive() { + public final boolean isActive() { return active; } @@ -267,7 +267,7 @@ public abstract class TWidget implements Comparable { * * @return if true, this widget can be tabbed to or receive events */ - public final boolean getEnabled() { + public final boolean isEnabled() { return enabled; } @@ -303,15 +303,15 @@ public abstract class TWidget implements Comparable { /** * If true, this widget has a cursor. */ - private boolean hasCursor = false; + private boolean cursorVisible = false; /** * Set visible cursor flag. * - * @param hasCursor if true, this widget has a cursor + * @param cursorVisible if true, this widget has a cursor */ - public final void setHasCursor(final boolean hasCursor) { - this.hasCursor = hasCursor; + public final void setCursorVisible(final boolean cursorVisible) { + this.cursorVisible = cursorVisible; } /** @@ -319,8 +319,8 @@ public abstract class TWidget implements Comparable { * * @return if true, this widget has a visible cursor */ - public final boolean visibleCursor() { - return hasCursor; + public final boolean isCursorVisible() { + return cursorVisible; } /** @@ -392,11 +392,11 @@ public abstract class TWidget implements Comparable { * @return true if this widget is active and all of its parents are * active. */ - public final boolean getAbsoluteActive() { + public final boolean isAbsoluteActive() { if (parent == this) { return active; } - return (active && parent.getAbsoluteActive()); + return (active && parent.isAbsoluteActive()); } /** @@ -405,7 +405,7 @@ public abstract class TWidget implements Comparable { * @return absolute screen column number for the cursor's X position */ public final int getCursorAbsoluteX() { - assert (hasCursor); + assert (cursorVisible); return getAbsoluteX() + cursorX; } @@ -415,7 +415,7 @@ public abstract class TWidget implements Comparable { * @return absolute screen row number for the cursor's Y position */ public final int getCursorAbsoluteY() { - assert (hasCursor); + assert (cursorVisible); return getAbsoluteY() + cursorY; } @@ -781,12 +781,12 @@ public abstract class TWidget implements Comparable { for (TWidget widget: children) { if (widget instanceof TButton) { TButton button = (TButton) widget; - if (button.getEnabled() - && !keypress.getKey().getIsKey() - && keypress.getKey().getAlt() - && !keypress.getKey().getCtrl() + if (button.isEnabled() + && !keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() && (Character.toLowerCase(button.getMnemonic().getShortcut()) - == Character.toLowerCase(keypress.getKey().getCh())) + == Character.toLowerCase(keypress.getKey().getChar())) ) { widget.handleEvent(new TKeypressEvent(kbEnter)); diff --git a/src/jexer/TWindow.java b/src/jexer/TWindow.java index e1d0299..82d187c 100644 --- a/src/jexer/TWindow.java +++ b/src/jexer/TWindow.java @@ -374,17 +374,17 @@ public class TWindow extends TWidget { if (!isModal() && (inWindowMove || inWindowResize || inKeyboardResize) ) { - assert (getActive()); + assert (isActive()); return getTheme().getColor("twindow.background.windowmove"); } else if (isModal() && inWindowMove) { - assert (getActive()); + assert (isActive()); return getTheme().getColor("twindow.background.modal"); } else if (isModal()) { - if (getActive()) { + if (isActive()) { return getTheme().getColor("twindow.background.modal"); } return getTheme().getColor("twindow.background.modal.inactive"); - } else if (getActive()) { + } else if (isActive()) { assert (!isModal()); return getTheme().getColor("twindow.background"); } else { @@ -402,18 +402,18 @@ public class TWindow extends TWidget { if (!isModal() && (inWindowMove || inWindowResize || inKeyboardResize) ) { - assert (getActive()); + assert (isActive()); return getTheme().getColor("twindow.border.windowmove"); } else if (isModal() && inWindowMove) { - assert (getActive()); + assert (isActive()); return getTheme().getColor("twindow.border.modal.windowmove"); } else if (isModal()) { - if (getActive()) { + if (isActive()) { return getTheme().getColor("twindow.border.modal"); } else { return getTheme().getColor("twindow.border.modal.inactive"); } - } else if (getActive()) { + } else if (isActive()) { assert (!isModal()); return getTheme().getColor("twindow.border"); } else { @@ -431,18 +431,18 @@ public class TWindow extends TWidget { if (!isModal() && (inWindowMove || inWindowResize || inKeyboardResize) ) { - assert (getActive()); + assert (isActive()); return 1; } else if (isModal() && inWindowMove) { - assert (getActive()); + assert (isActive()); return 1; } else if (isModal()) { - if (getActive()) { + if (isActive()) { return 2; } else { return 1; } - } else if (getActive()) { + } else if (isActive()) { return 2; } else { return 1; @@ -476,12 +476,12 @@ public class TWindow extends TWidget { putStrXY(titleLeft + 1, 0, title); putCharXY(titleLeft + title.length() + 1, 0, ' ', border); - if (getActive()) { + if (isActive()) { // Draw the close button putCharXY(2, 0, '[', border); putCharXY(4, 0, ']', border); - if (mouseOnClose() && mouse.getMouse1()) { + if (mouseOnClose() && mouse.isMouse1()) { putCharXY(3, 0, GraphicsChars.CP437[0x0F], !isModal() ? getTheme().getColor("twindow.border.windowmove") @@ -498,7 +498,7 @@ public class TWindow extends TWidget { putCharXY(getWidth() - 5, 0, '[', border); putCharXY(getWidth() - 3, 0, ']', border); - if (mouseOnMaximize() && mouse.getMouse1()) { + if (mouseOnMaximize() && mouse.isMouse1()) { putCharXY(getWidth() - 4, 0, GraphicsChars.CP437[0x0F], getTheme().getColor("twindow.border.windowmove")); } else { @@ -536,7 +536,7 @@ public class TWindow extends TWidget { inKeyboardResize = false; if ((mouse.getAbsoluteY() == getY()) - && mouse.getMouse1() + && mouse.isMouse1() && (getX() <= mouse.getAbsoluteX()) && (mouse.getAbsoluteX() < getX() + getWidth()) && !mouseOnClose() @@ -605,26 +605,26 @@ public class TWindow extends TWidget { public void onMouseUp(final TMouseEvent mouse) { this.mouse = mouse; - if ((inWindowMove) && (mouse.getMouse1())) { + if ((inWindowMove) && (mouse.isMouse1())) { // Stop moving window inWindowMove = false; return; } - if ((inWindowResize) && (mouse.getMouse1())) { + if ((inWindowResize) && (mouse.isMouse1())) { // Stop resizing window inWindowResize = false; return; } - if (mouse.getMouse1() && mouseOnClose()) { + if (mouse.isMouse1() && mouseOnClose()) { // Close window application.closeWindow(this); return; } if ((mouse.getAbsoluteY() == getY()) - && mouse.getMouse1() + && mouse.isMouse1() && mouseOnMaximize()) { if (maximized) { // Restore diff --git a/src/jexer/bits/Cell.java b/src/jexer/bits/Cell.java index 511963c..e756808 100644 --- a/src/jexer/bits/Cell.java +++ b/src/jexer/bits/Cell.java @@ -77,11 +77,11 @@ public final class Cell extends CellAttributes { public boolean isBlank() { if ((getForeColor().equals(Color.WHITE)) && (getBackColor().equals(Color.BLACK)) - && !getBold() - && !getBlink() - && !getReverse() - && !getUnderline() - && !getProtect() + && !isBold() + && !isBlink() + && !isReverse() + && !isUnderline() + && !isProtect() && (ch == ' ') ) { return true; @@ -178,6 +178,6 @@ public final class Cell extends CellAttributes { @Override public String toString() { return String.format("fore: %d back: %d bold: %s blink: %s ch %c", - getForeColor(), getBackColor(), getBold(), getBlink(), ch); + getForeColor(), getBackColor(), isBold(), isBlink(), ch); } } diff --git a/src/jexer/bits/CellAttributes.java b/src/jexer/bits/CellAttributes.java index d1aea2c..ad06525 100644 --- a/src/jexer/bits/CellAttributes.java +++ b/src/jexer/bits/CellAttributes.java @@ -45,7 +45,7 @@ public class CellAttributes { * * @return bold value */ - public final boolean getBold() { + public final boolean isBold() { return bold; } @@ -68,7 +68,7 @@ public class CellAttributes { * * @return blink value */ - public final boolean getBlink() { + public final boolean isBlink() { return blink; } @@ -91,7 +91,7 @@ public class CellAttributes { * * @return reverse value */ - public final boolean getReverse() { + public final boolean isReverse() { return reverse; } @@ -114,7 +114,7 @@ public class CellAttributes { * * @return underline value */ - public final boolean getUnderline() { + public final boolean isUnderline() { return underline; } @@ -137,7 +137,7 @@ public class CellAttributes { * * @return protect value */ - public final boolean getProtect() { + public final boolean isProtect() { return protect; } diff --git a/src/jexer/demos/Demo1.java b/src/jexer/demos/Demo1.java index 32272fb..f8ede85 100644 --- a/src/jexer/demos/Demo1.java +++ b/src/jexer/demos/Demo1.java @@ -426,8 +426,8 @@ class DemoMainWindow extends TWindow { new TAction() { public void DO() { - timerLabel.setText(String.format("Timer: %d", timerI)); - timerLabel.setWidth(timerLabel.getText().length()); + timerLabel.setLabel(String.format("Timer: %d", timerI)); + timerLabel.setWidth(timerLabel.getLabel().length()); if (timerI < 100) { timerI++; } diff --git a/src/jexer/event/TKeypressEvent.java b/src/jexer/event/TKeypressEvent.java index bf8a51a..19d87cf 100644 --- a/src/jexer/event/TKeypressEvent.java +++ b/src/jexer/event/TKeypressEvent.java @@ -87,7 +87,7 @@ public final class TKeypressEvent extends TInputEvent { public TKeypressEvent(final TKeypress key, final boolean alt, final boolean ctrl, final boolean shift) { - this.key = new TKeypress(key.getIsKey(), key.getFnKey(), key.getCh(), + this.key = new TKeypress(key.isFnKey(), key.getKeyCode(), key.getChar(), alt, ctrl, shift); } diff --git a/src/jexer/event/TMouseEvent.java b/src/jexer/event/TMouseEvent.java index 2f801cc..4a14865 100644 --- a/src/jexer/event/TMouseEvent.java +++ b/src/jexer/event/TMouseEvent.java @@ -161,7 +161,7 @@ public final class TMouseEvent extends TInputEvent { * * @return mouse1 */ - public boolean getMouse1() { + public boolean isMouse1() { return mouse1; } @@ -175,7 +175,7 @@ public final class TMouseEvent extends TInputEvent { * * @return mouse2 */ - public boolean getMouse2() { + public boolean isMouse2() { return mouse2; } @@ -189,7 +189,7 @@ public final class TMouseEvent extends TInputEvent { * * @return mouse3 */ - public boolean getMouse3() { + public boolean isMouse3() { return mouse3; } @@ -203,7 +203,7 @@ public final class TMouseEvent extends TInputEvent { * * @return mouseWheelUp */ - public boolean getMouseWheelUp() { + public boolean isMouseWheelUp() { return mouseWheelUp; } @@ -217,7 +217,7 @@ public final class TMouseEvent extends TInputEvent { * * @return mouseWheelDown */ - public boolean getMouseWheelDown() { + public boolean isMouseWheelDown() { return mouseWheelDown; } diff --git a/src/jexer/io/ECMA48Screen.java b/src/jexer/io/ECMA48Screen.java index aa71796..7e14317 100644 --- a/src/jexer/io/ECMA48Screen.java +++ b/src/jexer/io/ECMA48Screen.java @@ -133,10 +133,10 @@ public final class ECMA48Screen extends Screen { // Now emit only the modified attributes if ((lCell.getForeColor() != lastAttr.getForeColor()) && (lCell.getBackColor() != lastAttr.getBackColor()) - && (lCell.getBold() == lastAttr.getBold()) - && (lCell.getReverse() == lastAttr.getReverse()) - && (lCell.getUnderline() == lastAttr.getUnderline()) - && (lCell.getBlink() == lastAttr.getBlink()) + && (lCell.isBold() == lastAttr.isBold()) + && (lCell.isReverse() == lastAttr.isReverse()) + && (lCell.isUnderline() == lastAttr.isUnderline()) + && (lCell.isBlink() == lastAttr.isBlink()) ) { // Both colors changed, attributes the same sb.append(terminal.color(lCell.getForeColor(), @@ -147,27 +147,27 @@ public final class ECMA48Screen extends Screen { } } else if ((lCell.getForeColor() != lastAttr.getForeColor()) && (lCell.getBackColor() != lastAttr.getBackColor()) - && (lCell.getBold() != lastAttr.getBold()) - && (lCell.getReverse() != lastAttr.getReverse()) - && (lCell.getUnderline() != lastAttr.getUnderline()) - && (lCell.getBlink() != lastAttr.getBlink()) + && (lCell.isBold() != lastAttr.isBold()) + && (lCell.isReverse() != lastAttr.isReverse()) + && (lCell.isUnderline() != lastAttr.isUnderline()) + && (lCell.isBlink() != lastAttr.isBlink()) ) { // Everything is different sb.append(terminal.color(lCell.getForeColor(), lCell.getBackColor(), - lCell.getBold(), lCell.getReverse(), - lCell.getBlink(), - lCell.getUnderline())); + lCell.isBold(), lCell.isReverse(), + lCell.isBlink(), + lCell.isUnderline())); if (debugToStderr) { System.err.printf("2 Set all attributes\n"); } } else if ((lCell.getForeColor() != lastAttr.getForeColor()) && (lCell.getBackColor() == lastAttr.getBackColor()) - && (lCell.getBold() == lastAttr.getBold()) - && (lCell.getReverse() == lastAttr.getReverse()) - && (lCell.getUnderline() == lastAttr.getUnderline()) - && (lCell.getBlink() == lastAttr.getBlink()) + && (lCell.isBold() == lastAttr.isBold()) + && (lCell.isReverse() == lastAttr.isReverse()) + && (lCell.isUnderline() == lastAttr.isUnderline()) + && (lCell.isBlink() == lastAttr.isBlink()) ) { // Attributes same, foreColor different @@ -178,10 +178,10 @@ public final class ECMA48Screen extends Screen { } } else if ((lCell.getForeColor() == lastAttr.getForeColor()) && (lCell.getBackColor() != lastAttr.getBackColor()) - && (lCell.getBold() == lastAttr.getBold()) - && (lCell.getReverse() == lastAttr.getReverse()) - && (lCell.getUnderline() == lastAttr.getUnderline()) - && (lCell.getBlink() == lastAttr.getBlink()) + && (lCell.isBold() == lastAttr.isBold()) + && (lCell.isReverse() == lastAttr.isReverse()) + && (lCell.isUnderline() == lastAttr.isUnderline()) + && (lCell.isBlink() == lastAttr.isBlink()) ) { // Attributes same, backColor different sb.append(terminal.color(lCell.getBackColor(), false)); @@ -191,10 +191,10 @@ public final class ECMA48Screen extends Screen { } } else if ((lCell.getForeColor() == lastAttr.getForeColor()) && (lCell.getBackColor() == lastAttr.getBackColor()) - && (lCell.getBold() == lastAttr.getBold()) - && (lCell.getReverse() == lastAttr.getReverse()) - && (lCell.getUnderline() == lastAttr.getUnderline()) - && (lCell.getBlink() == lastAttr.getBlink()) + && (lCell.isBold() == lastAttr.isBold()) + && (lCell.isReverse() == lastAttr.isReverse()) + && (lCell.isUnderline() == lastAttr.isUnderline()) + && (lCell.isBlink() == lastAttr.isBlink()) ) { // All attributes the same, just print the char @@ -207,10 +207,10 @@ public final class ECMA48Screen extends Screen { // Just reset everything again sb.append(terminal.color(lCell.getForeColor(), lCell.getBackColor(), - lCell.getBold(), - lCell.getReverse(), - lCell.getBlink(), - lCell.getUnderline())); + lCell.isBold(), + lCell.isReverse(), + lCell.isBlink(), + lCell.isUnderline())); if (debugToStderr) { System.err.printf("6 Change all attributes\n"); diff --git a/src/jexer/io/Screen.java b/src/jexer/io/Screen.java index a0497b8..ec5309d 100644 --- a/src/jexer/io/Screen.java +++ b/src/jexer/io/Screen.java @@ -275,11 +275,11 @@ public abstract class Screen { dirty = true; logical[X][Y].setForeColor(attr.getForeColor()); logical[X][Y].setBackColor(attr.getBackColor()); - logical[X][Y].setBold(attr.getBold()); - logical[X][Y].setBlink(attr.getBlink()); - logical[X][Y].setReverse(attr.getReverse()); - logical[X][Y].setUnderline(attr.getUnderline()); - logical[X][Y].setProtect(attr.getProtect()); + logical[X][Y].setBold(attr.isBold()); + logical[X][Y].setBlink(attr.isBlink()); + logical[X][Y].setReverse(attr.isReverse()); + logical[X][Y].setUnderline(attr.isUnderline()); + logical[X][Y].setProtect(attr.isProtect()); } } @@ -343,11 +343,11 @@ public abstract class Screen { logical[X][Y].setChar(ch); logical[X][Y].setForeColor(attr.getForeColor()); logical[X][Y].setBackColor(attr.getBackColor()); - logical[X][Y].setBold(attr.getBold()); - logical[X][Y].setBlink(attr.getBlink()); - logical[X][Y].setReverse(attr.getReverse()); - logical[X][Y].setUnderline(attr.getUnderline()); - logical[X][Y].setProtect(attr.getProtect()); + logical[X][Y].setBold(attr.isBold()); + logical[X][Y].setBlink(attr.isBlink()); + logical[X][Y].setReverse(attr.isReverse()); + logical[X][Y].setUnderline(attr.isUnderline()); + logical[X][Y].setProtect(attr.isProtect()); } } diff --git a/src/jexer/io/SwingScreen.java b/src/jexer/io/SwingScreen.java index e06dc83..bdd74a7 100644 --- a/src/jexer/io/SwingScreen.java +++ b/src/jexer/io/SwingScreen.java @@ -159,7 +159,7 @@ public final class SwingScreen extends Screen { * blink * underline */ - if (attr.getBold()) { + if (attr.isBold()) { if (attr.getForeColor().equals(jexer.bits.Color.BLACK)) { return MYBOLD_BLACK; } else if (attr.getForeColor().equals(jexer.bits.Color.RED)) { diff --git a/src/jexer/menu/TMenu.java b/src/jexer/menu/TMenu.java index 56cbad5..165d951 100644 --- a/src/jexer/menu/TMenu.java +++ b/src/jexer/menu/TMenu.java @@ -128,7 +128,7 @@ public final class TMenu extends TWindow { public void draw() { CellAttributes background = getTheme().getColor("tmenu"); - assert (getAbsoluteActive()); + assert (isAbsoluteActive()); // Fill in the interior background for (int i = 0; i < getHeight(); i++) { @@ -221,7 +221,7 @@ public final class TMenu extends TWindow { // See if we should activate a different menu item for (TWidget widget: getChildren()) { - if ((mouse.getMouse1()) + if ((mouse.isMouse1()) && (widget.mouseWouldHit(mouse)) ) { // Activate this menu item @@ -276,14 +276,14 @@ public final class TMenu extends TWindow { } // Switch to a menuItem if it has an mnemonic - if (!keypress.getKey().getIsKey() - && !keypress.getKey().getAlt() - && !keypress.getKey().getCtrl()) { + if (!keypress.getKey().isFnKey() + && !keypress.getKey().isAlt() + && !keypress.getKey().isCtrl()) { for (TWidget widget: getChildren()) { TMenuItem item = (TMenuItem) widget; if ((item.getMnemonic() != null) && (Character.toLowerCase(item.getMnemonic().getShortcut()) - == Character.toLowerCase(keypress.getKey().getCh())) + == Character.toLowerCase(keypress.getKey().getChar())) ) { // Send an enter keystroke to it activate(item); @@ -295,7 +295,7 @@ public final class TMenu extends TWindow { // Dispatch the keypress to an active widget for (TWidget widget: getChildren()) { - if (widget.getActive()) { + if (widget.isActive()) { widget.handleEvent(keypress); return; } diff --git a/src/jexer/menu/TMenuItem.java b/src/jexer/menu/TMenuItem.java index 607341b..43ea8f0 100644 --- a/src/jexer/menu/TMenuItem.java +++ b/src/jexer/menu/TMenuItem.java @@ -200,11 +200,11 @@ public class TMenuItem extends TWidget { CellAttributes background = getTheme().getColor("tmenu"); CellAttributes menuColor; CellAttributes menuMnemonicColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { menuColor = getTheme().getColor("tmenu.highlighted"); menuMnemonicColor = getTheme().getColor("tmenu.mnemonic.highlighted"); } else { - if (getEnabled()) { + if (isEnabled()) { menuColor = getTheme().getColor("tmenu"); menuMnemonicColor = getTheme().getColor("tmenu.mnemonic"); } else { @@ -239,7 +239,7 @@ public class TMenuItem extends TWidget { * Dispatch event(s) due to selection or click. */ public void dispatch() { - assert (getEnabled()); + assert (isEnabled()); getApplication().addMenuEvent(new TMenuEvent(id)); if (checkable) { @@ -269,7 +269,7 @@ public class TMenuItem extends TWidget { */ @Override public void onMouseUp(final TMouseEvent mouse) { - if ((mouseOnMenuItem(mouse)) && (mouse.getMouse1())) { + if ((mouseOnMenuItem(mouse)) && (mouse.isMouse1())) { dispatch(); return; } diff --git a/src/jexer/menu/TSubMenu.java b/src/jexer/menu/TSubMenu.java index bd1815f..1f1b119 100644 --- a/src/jexer/menu/TSubMenu.java +++ b/src/jexer/menu/TSubMenu.java @@ -77,10 +77,10 @@ public final class TSubMenu extends TMenuItem { super.draw(); CellAttributes menuColor; - if (getAbsoluteActive()) { + if (isAbsoluteActive()) { menuColor = getTheme().getColor("tmenu.highlighted"); } else { - if (getEnabled()) { + if (isEnabled()) { menuColor = getTheme().getColor("tmenu"); } else { menuColor = getTheme().getColor("tmenu.disabled"); @@ -100,7 +100,7 @@ public final class TSubMenu extends TMenuItem { @Override public void onKeypress(final TKeypressEvent keypress) { - if (menu.getActive()) { + if (menu.isActive()) { menu.onKeypress(keypress); return; } @@ -146,9 +146,9 @@ public final class TSubMenu extends TMenuItem { */ @Override public void dispatch() { - assert (getEnabled()); - if (getAbsoluteActive()) { - if (!menu.getActive()) { + assert (isEnabled()); + if (isAbsoluteActive()) { + if (!menu.isActive()) { getApplication().addSubMenu(menu); menu.setActive(true); } @@ -162,7 +162,7 @@ public final class TSubMenu extends TMenuItem { */ @Override public TWidget getActiveChild() { - if (menu.getActive()) { + if (menu.isActive()) { return menu; } // Menu not active, return me diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index 22867e1..7b41594 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -614,7 +614,7 @@ public class ECMA48 implements Runnable { * * @return if true, the cursor is visible */ - public final boolean visibleCursor() { + public final boolean isCursorVisible() { return cursorVisible; } @@ -1145,11 +1145,11 @@ public class ECMA48 implements Runnable { * have a button down (i.e. drag-and-drop). */ if (mouse.getType() == TMouseEvent.Type.MOUSE_MOTION) { - if (!mouse.getMouse1() - && !mouse.getMouse2() - && !mouse.getMouse3() - && !mouse.getMouseWheelUp() - && !mouse.getMouseWheelDown() + if (!mouse.isMouse1() + && !mouse.isMouse2() + && !mouse.isMouse3() + && !mouse.isMouseWheelUp() + && !mouse.isMouseWheelDown() ) { return; } @@ -1168,15 +1168,15 @@ public class ECMA48 implements Runnable { sb.append('M'); if (mouse.getType() == TMouseEvent.Type.MOUSE_UP) { sb.append((char) (0x03 + 32)); - } else if (mouse.getMouse1()) { + } else if (mouse.isMouse1()) { sb.append((char) (0x00 + 32)); - } else if (mouse.getMouse2()) { + } else if (mouse.isMouse2()) { sb.append((char) (0x01 + 32)); - } else if (mouse.getMouse3()) { + } else if (mouse.isMouse3()) { sb.append((char) (0x02 + 32)); - } else if (mouse.getMouseWheelUp()) { + } else if (mouse.isMouseWheelUp()) { sb.append((char) (0x04 + 64)); - } else if (mouse.getMouseWheelDown()) { + } else if (mouse.isMouseWheelDown()) { sb.append((char) (0x05 + 64)); } else { sb.append((char) (0x03 + 32)); @@ -1207,16 +1207,16 @@ public class ECMA48 implements Runnable { */ private String keypressToString(final TKeypress keypress) { - if ((fullDuplex == false) && (!keypress.getIsKey())) { + if ((fullDuplex == false) && (!keypress.isFnKey())) { /* * If this is a control character, process it like it came from * the remote side. */ - if (keypress.getCh() < 0x20) { - handleControlChar(keypress.getCh()); + if (keypress.getChar() < 0x20) { + handleControlChar(keypress.getChar()); } else { // Local echo for everything else - printCharacter(keypress.getCh()); + printCharacter(keypress.getChar()); } } @@ -1226,18 +1226,18 @@ public class ECMA48 implements Runnable { } // Handle control characters - if ((keypress.getCtrl()) && (!keypress.getIsKey())) { + if ((keypress.isCtrl()) && (!keypress.isFnKey())) { StringBuilder sb = new StringBuilder(); - char ch = keypress.getCh(); + char ch = keypress.getChar(); ch -= 0x40; sb.append(ch); return sb.toString(); } // Handle alt characters - if ((keypress.getAlt()) && (!keypress.getIsKey())) { + if ((keypress.isAlt()) && (!keypress.isFnKey())) { StringBuilder sb = new StringBuilder("\033"); - char ch = keypress.getCh(); + char ch = keypress.getChar(); sb.append(ch); return sb.toString(); } @@ -1635,9 +1635,9 @@ public class ECMA48 implements Runnable { } // Non-alt, non-ctrl characters - if (!keypress.getIsKey()) { + if (!keypress.isFnKey()) { StringBuilder sb = new StringBuilder(); - sb.append(keypress.getCh()); + sb.append(keypress.getChar()); return sb.toString(); } return ""; @@ -3546,7 +3546,7 @@ public class ECMA48 implements Runnable { for (int i = start; i <= end; i++) { DisplayLine line = display.get(currentState.cursorY); if ((!honorProtected) - || ((honorProtected) && (!line.charAt(i).getProtect()))) { + || ((honorProtected) && (!line.charAt(i).isProtect()))) { switch (type) { case VT100: