From 00691e80f2f135f92be739e2b7e86775a2357276 Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Thu, 14 Feb 2019 18:19:19 -0600 Subject: [PATCH] retrofit from GJexer --- src/jexer/TApplication.java | 4 +- src/jexer/TCheckBox.java | 36 +++++- src/jexer/TLabel.java | 98 +++++++++++++-- src/jexer/TRadioButton.java | 48 +++++-- src/jexer/TRadioGroup.java | 38 +++++- src/jexer/TTerminalWindow.java | 14 +-- src/jexer/TWidget.java | 172 ++++++++++++++++++++++++-- src/jexer/backend/TWindowBackend.java | 30 +---- src/jexer/bits/ColorTheme.java | 25 ++++ 9 files changed, 392 insertions(+), 73 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index 161e161a..20406b1f 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -3317,7 +3317,7 @@ public class TApplication implements Runnable { public final TTerminalWindow openTerminal(final int x, final int y, final int flags, final String commandLine) { - return new TTerminalWindow(this, x, y, flags, commandLine.split("\\s")); + return new TTerminalWindow(this, x, y, flags, commandLine.split("\\s+")); } /** @@ -3334,7 +3334,7 @@ public class TApplication implements Runnable { public final TTerminalWindow openTerminal(final int x, final int y, final int flags, final String commandLine, final boolean closeOnExit) { - return new TTerminalWindow(this, x, y, flags, commandLine.split("\\s"), + return new TTerminalWindow(this, x, y, flags, commandLine.split("\\s+"), closeOnExit); } diff --git a/src/jexer/TCheckBox.java b/src/jexer/TCheckBox.java index 84c2e41a..9cdb3039 100644 --- a/src/jexer/TCheckBox.java +++ b/src/jexer/TCheckBox.java @@ -28,9 +28,12 @@ */ package jexer; +import static jexer.TKeypress.kbEnter; +import static jexer.TKeypress.kbEsc; import static jexer.TKeypress.kbSpace; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; +import jexer.bits.MnemonicString; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; @@ -49,9 +52,9 @@ public class TCheckBox extends TWidget { private boolean checked = false; /** - * Label for this checkbox. + * The shortcut and checkbox label. */ - private String label; + private MnemonicString mnemonic; /** * If true, use the window's background color. @@ -77,7 +80,7 @@ public class TCheckBox extends TWidget { // Set parent and window super(parent, x, y, label.length() + 4, 1); - this.label = label; + mnemonic = new MnemonicString(label); this.checked = checked; setCursorVisible(true); @@ -124,11 +127,18 @@ public class TCheckBox extends TWidget { */ @Override public void onKeypress(final TKeypressEvent keypress) { - if (keypress.equals(kbSpace)) { + if (keypress.equals(kbSpace) + || keypress.equals(kbEnter) + ) { checked = !checked; return; } + if (keypress.equals(kbEsc)) { + checked = false; + return; + } + // Pass to parent for the things we don't care about. super.onKeypress(keypress); } @@ -143,11 +153,14 @@ public class TCheckBox extends TWidget { @Override public void draw() { CellAttributes checkboxColor; + CellAttributes mnemonicColor; if (isAbsoluteActive()) { checkboxColor = getTheme().getColor("tcheckbox.active"); + mnemonicColor = getTheme().getColor("tcheckbox.mnemonic.highlighted"); } else { checkboxColor = getTheme().getColor("tcheckbox.inactive"); + mnemonicColor = getTheme().getColor("tcheckbox.mnemonic"); } if (useWindowBackground) { CellAttributes background = getWindow().getBackground(); @@ -161,7 +174,11 @@ public class TCheckBox extends TWidget { putCharXY(1, 0, ' ', checkboxColor); } putCharXY(2, 0, ']', checkboxColor); - putStringXY(4, 0, label, checkboxColor); + putStringXY(4, 0, mnemonic.getRawLabel(), checkboxColor); + if (mnemonic.getShortcutIdx() >= 0) { + putCharXY(4 + mnemonic.getShortcutIdx(), 0, + mnemonic.getShortcut(), mnemonicColor); + } } // ------------------------------------------------------------------------ @@ -186,4 +203,13 @@ public class TCheckBox extends TWidget { this.checked = checked; } + /** + * Get the mnemonic string for this checkbox. + * + * @return mnemonic string + */ + public MnemonicString getMnemonic() { + return mnemonic; + } + } diff --git a/src/jexer/TLabel.java b/src/jexer/TLabel.java index 69e1efd2..f33a8d75 100644 --- a/src/jexer/TLabel.java +++ b/src/jexer/TLabel.java @@ -29,9 +29,11 @@ package jexer; import jexer.bits.CellAttributes; +import jexer.bits.MnemonicString; /** - * TLabel implements a simple label. + * TLabel implements a simple label, with an optional mnemonic hotkey action + * associated with it. */ public class TLabel extends TWidget { @@ -40,9 +42,14 @@ public class TLabel extends TWidget { // ------------------------------------------------------------------------ /** - * Label text. + * The shortcut and label. */ - private String label = ""; + private MnemonicString mnemonic; + + /** + * The action to perform when the mnemonic shortcut is pressed. + */ + private TAction action; /** * Label color. @@ -72,6 +79,21 @@ public class TLabel extends TWidget { this(parent, text, x, y, "tlabel"); } + /** + * Public constructor, using the default "tlabel" for colorKey. + * + * @param parent parent widget + * @param text label on the screen + * @param x column relative to parent + * @param y row relative to parent + * @param action to call when shortcut is pressed + */ + public TLabel(final TWidget parent, final String text, final int x, + final int y, final TAction action) { + + this(parent, text, x, y, "tlabel", action); + } + /** * Public constructor. * @@ -87,6 +109,22 @@ public class TLabel extends TWidget { this(parent, text, x, y, colorKey, true); } + /** + * Public constructor. + * + * @param parent parent widget + * @param text label on the screen + * @param x column relative to parent + * @param y row relative to parent + * @param colorKey ColorTheme key color to use for foreground text + * @param action to call when shortcut is pressed + */ + public TLabel(final TWidget parent, final String text, final int x, + final int y, final String colorKey, final TAction action) { + + this(parent, text, x, y, colorKey, true, action); + } + /** * Public constructor. * @@ -100,12 +138,31 @@ public class TLabel extends TWidget { public TLabel(final TWidget parent, final String text, final int x, final int y, final String colorKey, final boolean useWindowBackground) { + this(parent, text, x, y, colorKey, useWindowBackground, null); + } + + /** + * Public constructor. + * + * @param parent parent widget + * @param text label on the screen + * @param x column relative to parent + * @param y row relative to parent + * @param colorKey ColorTheme key color to use for foreground text + * @param useWindowBackground if true, use the window's background color + * @param action to call when shortcut is pressed + */ + public TLabel(final TWidget parent, final String text, final int x, + final int y, final String colorKey, final boolean useWindowBackground, + final TAction action) { + // Set parent and window super(parent, false, x, y, text.length(), 1); - this.label = text; + mnemonic = new MnemonicString(text); this.colorKey = colorKey; this.useWindowBackground = useWindowBackground; + this.action = action; } // ------------------------------------------------------------------------ @@ -119,12 +176,19 @@ public class TLabel extends TWidget { public void draw() { // Setup my color CellAttributes color = new CellAttributes(); + CellAttributes mnemonicColor = new CellAttributes(); color.setTo(getTheme().getColor(colorKey)); + mnemonicColor.setTo(getTheme().getColor("tlabel.mnemonic")); if (useWindowBackground) { CellAttributes background = getWindow().getBackground(); color.setBackColor(background.getBackColor()); + mnemonicColor.setBackColor(background.getBackColor()); + } + putStringXY(0, 0, mnemonic.getRawLabel(), color); + if (mnemonic.getShortcutIdx() >= 0) { + putCharXY(mnemonic.getShortcutIdx(), 0, + mnemonic.getShortcut(), mnemonicColor); } - putStringXY(0, 0, label, color); } // ------------------------------------------------------------------------ @@ -132,12 +196,21 @@ public class TLabel extends TWidget { // ------------------------------------------------------------------------ /** - * Get label text. + * Get label raw text. * * @return label text */ public String getLabel() { - return label; + return mnemonic.getRawLabel(); + } + + /** + * Get the mnemonic string for this label. + * + * @return mnemonic string + */ + public MnemonicString getMnemonic() { + return mnemonic; } /** @@ -146,7 +219,16 @@ public class TLabel extends TWidget { * @param label new label text */ public void setLabel(final String label) { - this.label = label; + mnemonic = new MnemonicString(label); + } + + /** + * Act as though the mnemonic shortcut was pressed. + */ + public void dispatch() { + if (action != null) { + action.DO(); + } } } diff --git a/src/jexer/TRadioButton.java b/src/jexer/TRadioButton.java index b4170ba8..e3d98a98 100644 --- a/src/jexer/TRadioButton.java +++ b/src/jexer/TRadioButton.java @@ -30,12 +30,17 @@ package jexer; import jexer.bits.CellAttributes; import jexer.bits.GraphicsChars; +import jexer.bits.MnemonicString; import jexer.event.TKeypressEvent; import jexer.event.TMouseEvent; import static jexer.TKeypress.*; /** * TRadioButton implements a selectable radio button. + * + * If the user clicks or presses space on this button, it is selected. + * + * If the user presses escape on this button, it is unselected. */ public class TRadioButton extends TWidget { @@ -49,9 +54,9 @@ public class TRadioButton extends TWidget { private boolean selected = false; /** - * Label for this radio button. + * The shortcut and radio button label. */ - private String label; + private MnemonicString mnemonic; /** * ID for this radio button. Buttons start counting at 1 in the @@ -78,7 +83,7 @@ public class TRadioButton extends TWidget { // Set parent and window super(parent, x, y, label.length() + 4, 1); - this.label = label; + mnemonic = new MnemonicString(label); this.id = id; setCursorVisible(true); @@ -114,10 +119,8 @@ public class TRadioButton extends TWidget { public void onMouseDown(final TMouseEvent mouse) { if ((mouseOnRadioButton(mouse)) && (mouse.isMouse1())) { // Switch state - selected = !selected; - if (selected) { - ((TRadioGroup) getParent()).setSelected(this); - } + selected = true; + ((TRadioGroup) getParent()).setSelected(this); } } @@ -130,9 +133,16 @@ public class TRadioButton extends TWidget { public void onKeypress(final TKeypressEvent keypress) { if (keypress.equals(kbSpace)) { - selected = !selected; - if (selected) { - ((TRadioGroup) getParent()).setSelected(this); + selected = true; + ((TRadioGroup) getParent()).setSelected(this); + return; + } + + if (keypress.equals(kbEsc)) { + TRadioGroup parent = (TRadioGroup) getParent(); + if (parent.requiresSelection == false) { + selected = false; + parent.setSelected(0); } return; } @@ -151,11 +161,14 @@ public class TRadioButton extends TWidget { @Override public void draw() { CellAttributes radioButtonColor; + CellAttributes mnemonicColor; if (isAbsoluteActive()) { radioButtonColor = getTheme().getColor("tradiobutton.active"); + mnemonicColor = getTheme().getColor("tradiobutton.mnemonic.highlighted"); } else { radioButtonColor = getTheme().getColor("tradiobutton.inactive"); + mnemonicColor = getTheme().getColor("tradiobutton.mnemonic"); } putCharXY(0, 0, '(', radioButtonColor); @@ -165,7 +178,11 @@ public class TRadioButton extends TWidget { putCharXY(1, 0, ' ', radioButtonColor); } putCharXY(2, 0, ')', radioButtonColor); - putStringXY(4, 0, label, radioButtonColor); + putStringXY(4, 0, mnemonic.getRawLabel(), radioButtonColor); + if (mnemonic.getShortcutIdx() >= 0) { + putCharXY(4 + mnemonic.getShortcutIdx(), 0, + mnemonic.getShortcut(), mnemonicColor); + } } // ------------------------------------------------------------------------ @@ -203,4 +220,13 @@ public class TRadioButton extends TWidget { return id; } + /** + * Get the mnemonic string for this button. + * + * @return mnemonic string + */ + public MnemonicString getMnemonic() { + return mnemonic; + } + } diff --git a/src/jexer/TRadioGroup.java b/src/jexer/TRadioGroup.java index d57d8647..0f84e719 100644 --- a/src/jexer/TRadioGroup.java +++ b/src/jexer/TRadioGroup.java @@ -49,6 +49,12 @@ public class TRadioGroup extends TWidget { */ private TRadioButton selectedButton = null; + /** + * If true, one of the children MUST be selected. Note package private + * access. + */ + boolean requiresSelection = true; + // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ @@ -117,12 +123,35 @@ public class TRadioGroup extends TWidget { */ void setSelected(final TRadioButton button) { assert (button.isSelected()); - if (selectedButton != null) { + if ((selectedButton != null) && (selectedButton != button)) { selectedButton.setSelected(false); } selectedButton = button; } + /** + * Set the new selected radio button. 1-based. + * + * @param id ID of the selected button, or 0 to unselect + */ + public void setSelected(final int id) { + if ((id < 0) || (id > getChildren().size())) { + return; + } + + if (id == 0) { + for (TWidget widget: getChildren()) { + ((TRadioButton) widget).setSelected(false); + } + selectedButton = null; + return; + } + assert ((id > 0) && (id <= getChildren().size())); + TRadioButton button = (TRadioButton) (getChildren().get(id - 1)); + button.setSelected(true); + selectedButton = button; + } + /** * Convenience function to add a radio button to this group. * @@ -136,8 +165,13 @@ public class TRadioGroup extends TWidget { setWidth(label.length() + 7); } setHeight(getChildren().size() + 3); - return new TRadioButton(this, buttonX, buttonY, label, + TRadioButton button = new TRadioButton(this, buttonX, buttonY, label, getChildren().size() + 1); + + // Default to the first item on the list. + activate(getChildren().get(0)); + + return button; } } diff --git a/src/jexer/TTerminalWindow.java b/src/jexer/TTerminalWindow.java index ec4fd07e..b55e7b05 100644 --- a/src/jexer/TTerminalWindow.java +++ b/src/jexer/TTerminalWindow.java @@ -101,7 +101,7 @@ public class TTerminalWindow extends TScrollableWindow public TTerminalWindow(final TApplication application, final int x, final int y, final String commandLine) { - this(application, x, y, RESIZABLE, commandLine.split("\\s"), + this(application, x, y, RESIZABLE, commandLine.split("\\s+"), System.getProperty("jexer.TTerminal.closeOnExit", "false").equals("true")); } @@ -118,7 +118,7 @@ public class TTerminalWindow extends TScrollableWindow public TTerminalWindow(final TApplication application, final int x, final int y, final String commandLine, final boolean closeOnExit) { - this(application, x, y, RESIZABLE, commandLine.split("\\s"), + this(application, x, y, RESIZABLE, commandLine.split("\\s+"), closeOnExit); } @@ -247,16 +247,16 @@ public class TTerminalWindow extends TScrollableWindow equals("true")) ) { ptypipe = true; - spawnShell(cmdShellPtypipe.split("\\s")); + spawnShell(cmdShellPtypipe.split("\\s+")); } else if (System.getProperty("os.name").startsWith("Windows")) { - spawnShell(cmdShellWindows.split("\\s")); + spawnShell(cmdShellWindows.split("\\s+")); } else if (System.getProperty("os.name").startsWith("Mac")) { - spawnShell(cmdShellBSD.split("\\s")); + spawnShell(cmdShellBSD.split("\\s+")); } else if (System.getProperty("os.name").startsWith("Linux")) { - spawnShell(cmdShellGNU.split("\\s")); + spawnShell(cmdShellGNU.split("\\s+")); } else { // When all else fails, assume GNU. - spawnShell(cmdShellGNU.split("\\s")); + spawnShell(cmdShellGNU.split("\\s+")); } } diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index aa4cef89..f7a83a19 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -331,7 +331,7 @@ public abstract class TWidget implements Comparable { } // If I have any buttons on me AND this is an Alt-key that matches - // its mnemonic, send it an Enter keystroke + // its mnemonic, send it an Enter keystroke. for (TWidget widget: children) { if (widget instanceof TButton) { TButton button = (TButton) widget; @@ -349,6 +349,81 @@ public abstract class TWidget implements Comparable { } } + // If I have any labels on me AND this is an Alt-key that matches + // its mnemonic, call its action. + for (TWidget widget: children) { + if (widget instanceof TLabel) { + TLabel label = (TLabel) widget; + if (!keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() + && (Character.toLowerCase(label.getMnemonic().getShortcut()) + == Character.toLowerCase(keypress.getKey().getChar())) + ) { + + label.dispatch(); + return; + } + } + } + + // If I have any radiobuttons on me AND this is an Alt-key that + // matches its mnemonic, select it and send a Space to it. + for (TWidget widget: children) { + if (widget instanceof TRadioButton) { + TRadioButton button = (TRadioButton) widget; + if (button.isEnabled() + && !keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() + && (Character.toLowerCase(button.getMnemonic().getShortcut()) + == Character.toLowerCase(keypress.getKey().getChar())) + ) { + activate(widget); + widget.onKeypress(new TKeypressEvent(kbSpace)); + return; + } + } + if (widget instanceof TRadioGroup) { + for (TWidget child: widget.getChildren()) { + if (child instanceof TRadioButton) { + TRadioButton button = (TRadioButton) child; + if (button.isEnabled() + && !keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() + && (Character.toLowerCase(button.getMnemonic().getShortcut()) + == Character.toLowerCase(keypress.getKey().getChar())) + ) { + activate(widget); + widget.activate(child); + child.onKeypress(new TKeypressEvent(kbSpace)); + return; + } + } + } + } + } + + // If I have any checkboxes on me AND this is an Alt-key that matches + // its mnemonic, select it and set it to checked. + for (TWidget widget: children) { + if (widget instanceof TCheckBox) { + TCheckBox checkBox = (TCheckBox) widget; + if (checkBox.isEnabled() + && !keypress.getKey().isFnKey() + && keypress.getKey().isAlt() + && !keypress.getKey().isCtrl() + && (Character.toLowerCase(checkBox.getMnemonic().getShortcut()) + == Character.toLowerCase(keypress.getKey().getChar())) + ) { + activate(checkBox); + checkBox.setChecked(true); + return; + } + } + } + // Dispatch the keypress to an active widget for (TWidget widget: children) { if (widget.active) { @@ -1085,6 +1160,16 @@ public abstract class TWidget implements Comparable { } } + /** + * Reset the tab order of children to match their position in the list. + * Available so that subclasses can re-order their widgets if needed. + */ + protected void resetTabOrder() { + for (int i = 0; i < children.size(); i++) { + children.get(i).tabOrder = i; + } + } + /** * Switch the active child. * @@ -1129,9 +1214,6 @@ public abstract class TWidget implements Comparable { return; } - if (activeChild == null) { - return; - } TWidget child = null; for (TWidget widget: children) { if ((widget.enabled) @@ -1144,7 +1226,9 @@ public abstract class TWidget implements Comparable { } } if ((child != null) && (child != activeChild)) { - activeChild.active = false; + if (activeChild != null) { + activeChild.active = false; + } assert (child.enabled); child.active = true; activeChild = child; @@ -1160,7 +1244,7 @@ public abstract class TWidget implements Comparable { public final void switchWidget(final boolean forward) { // No children: do nothing. - if ((children.size() == 0) || (activeChild == null)) { + if (children.size() == 0) { return; } @@ -1178,7 +1262,10 @@ public abstract class TWidget implements Comparable { // Two or more children: go forward or backward to the next enabled // child. - int tabOrder = activeChild.tabOrder; + int tabOrder = 0; + if (activeChild != null) { + tabOrder = activeChild.tabOrder; + } do { if (forward) { tabOrder++; @@ -1203,7 +1290,12 @@ public abstract class TWidget implements Comparable { tabOrder = 0; } - if (activeChild.tabOrder == tabOrder) { + if (activeChild == null) { + if (tabOrder == 0) { + // We wrapped around + break; + } + } else if (activeChild.tabOrder == tabOrder) { // We wrapped around break; } @@ -1211,11 +1303,15 @@ public abstract class TWidget implements Comparable { && !(children.get(tabOrder) instanceof THScroller) && !(children.get(tabOrder) instanceof TVScroller)); - assert (children.get(tabOrder).enabled); + if (activeChild != null) { + assert (children.get(tabOrder).enabled); - activeChild.active = false; - children.get(tabOrder).active = true; - activeChild = children.get(tabOrder); + activeChild.active = false; + } + if (children.get(tabOrder).enabled == true) { + children.get(tabOrder).active = true; + activeChild = children.get(tabOrder); + } } /** @@ -1453,6 +1549,21 @@ public abstract class TWidget implements Comparable { return addLabel(text, x, y, "tlabel"); } + /** + * Convenience function to add a label to this container/window. + * + * @param text label + * @param x column relative to parent + * @param y row relative to parent + * @param action to call when shortcut is pressed + * @return the new label + */ + public final TLabel addLabel(final String text, final int x, final int y, + final TAction action) { + + return addLabel(text, x, y, "tlabel", action); + } + /** * Convenience function to add a label to this container/window. * @@ -1469,6 +1580,23 @@ public abstract class TWidget implements Comparable { return new TLabel(this, text, x, y, colorKey); } + /** + * Convenience function to add a label to this container/window. + * + * @param text label + * @param x column relative to parent + * @param y row relative to parent + * @param colorKey ColorTheme key color to use for foreground text. + * Default is "tlabel" + * @param action to call when shortcut is pressed + * @return the new label + */ + public final TLabel addLabel(final String text, final int x, final int y, + final String colorKey, final TAction action) { + + return new TLabel(this, text, x, y, colorKey, action); + } + /** * Convenience function to add a label to this container/window. * @@ -1486,6 +1614,26 @@ public abstract class TWidget implements Comparable { return new TLabel(this, text, x, y, colorKey, useWindowBackground); } + /** + * Convenience function to add a label to this container/window. + * + * @param text label + * @param x column relative to parent + * @param y row relative to parent + * @param colorKey ColorTheme key color to use for foreground text. + * Default is "tlabel" + * @param useWindowBackground if true, use the window's background color + * @param action to call when shortcut is pressed + * @return the new label + */ + public final TLabel addLabel(final String text, final int x, final int y, + final String colorKey, final boolean useWindowBackground, + final TAction action) { + + return new TLabel(this, text, x, y, colorKey, useWindowBackground, + action); + } + /** * Convenience function to add a button to this container/window. * diff --git a/src/jexer/backend/TWindowBackend.java b/src/jexer/backend/TWindowBackend.java index 0a042336..10f95c66 100644 --- a/src/jexer/backend/TWindowBackend.java +++ b/src/jexer/backend/TWindowBackend.java @@ -73,16 +73,6 @@ public class TWindowBackend extends TWindow implements Backend { */ private Screen otherScreen; - /** - * The mouse X position as seen on the other screen. - */ - private int otherMouseX = -1; - - /** - * The mouse Y position as seen on the other screen. - */ - private int otherMouseY = -1; - /** * The session information. */ @@ -114,6 +104,7 @@ public class TWindowBackend extends TWindow implements Backend { otherScreen = new LogicalScreen(); otherScreen.setDimensions(width - 2, height - 2); drawLock = otherScreen; + setHiddenMouse(true); } /** @@ -139,6 +130,7 @@ public class TWindowBackend extends TWindow implements Backend { otherScreen = new LogicalScreen(); otherScreen.setDimensions(width - 2, height - 2); drawLock = otherScreen; + setHiddenMouse(true); } /** @@ -165,6 +157,7 @@ public class TWindowBackend extends TWindow implements Backend { otherScreen = new LogicalScreen(); otherScreen.setDimensions(width - 2, height - 2); drawLock = otherScreen; + setHiddenMouse(true); } /** @@ -193,6 +186,7 @@ public class TWindowBackend extends TWindow implements Backend { otherScreen = new LogicalScreen(); otherScreen.setDimensions(width - 2, height - 2); drawLock = otherScreen; + setHiddenMouse(true); } // ------------------------------------------------------------------------ @@ -275,17 +269,12 @@ public class TWindowBackend extends TWindow implements Backend { event.setY(mouse.getY() - 1); event.setAbsoluteX(event.getX()); event.setAbsoluteY(event.getY()); - otherMouseX = event.getX() + getX() + 1; - otherMouseY = event.getY() + getY() + 1; synchronized (eventQueue) { eventQueue.add(event); } synchronized (listener) { listener.notifyAll(); } - } else { - otherMouseX = -1; - otherMouseY = -1; } super.onMouseMotion(mouse); } @@ -329,17 +318,6 @@ public class TWindowBackend extends TWindow implements Backend { } } - // If the mouse pointer is over the other window, draw its - // pointer again here. (Their TApplication drew it, then our - // TApplication drew it again (undo-ing it), so now we draw it a - // third time so that it is visible.) - if ((otherMouseX != -1) && (otherMouseY != -1)) { - CellAttributes attr = getAttrXY(otherMouseX, otherMouseY); - attr.setForeColor(attr.getForeColor().invert()); - attr.setBackColor(attr.getBackColor().invert()); - putAttrXY(otherMouseX, otherMouseY, attr, false); - } - // If their cursor is visible, draw that here too. if (otherScreen.isCursorVisible()) { setCursorX(otherScreen.getCursorX() + 1); diff --git a/src/jexer/bits/ColorTheme.java b/src/jexer/bits/ColorTheme.java index 83f09f4e..9ac4986b 100644 --- a/src/jexer/bits/ColorTheme.java +++ b/src/jexer/bits/ColorTheme.java @@ -362,6 +362,11 @@ public class ColorTheme { color.setBackColor(Color.BLUE); color.setBold(true); colors.put("tlabel", color); + color = new CellAttributes(); + color.setForeColor(Color.YELLOW); + color.setBackColor(Color.BLUE); + color.setBold(true); + colors.put("tlabel.mnemonic", color); // TText text color = new CellAttributes(); @@ -393,6 +398,16 @@ public class ColorTheme { color.setBackColor(Color.BLACK); color.setBold(true); colors.put("tcheckbox.active", color); + color = new CellAttributes(); + color.setForeColor(Color.YELLOW); + color.setBackColor(Color.BLUE); + color.setBold(true); + colors.put("tcheckbox.mnemonic", color); + color = new CellAttributes(); + color.setForeColor(Color.RED); + color.setBackColor(Color.BLACK); + color.setBold(true); + colors.put("tcheckbox.mnemonic.highlighted", color); // TComboBox color = new CellAttributes(); @@ -456,6 +471,16 @@ public class ColorTheme { color.setBackColor(Color.BLACK); color.setBold(true); colors.put("tradiobutton.active", color); + color = new CellAttributes(); + color.setForeColor(Color.YELLOW); + color.setBackColor(Color.BLUE); + color.setBold(true); + colors.put("tradiobutton.mnemonic", color); + color = new CellAttributes(); + color.setForeColor(Color.RED); + color.setBackColor(Color.BLACK); + color.setBold(true); + colors.put("tradiobutton.mnemonic.highlighted", color); // TRadioGroup color = new CellAttributes(); -- 2.27.0