X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=0f50457a9b66f77ee38f05fff4ffa51da318317f;hb=80b1b7b5fb2d8caed97ea9a98b8a844beb00927d;hp=ec93629b0b17f9584336ff855f0d1010660121be;hpb=bfa37f3b2ef87d39c15fad7d565c00cbabd92acf;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index ec93629..0f50457 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -289,6 +289,22 @@ public class TApplication implements Runnable { */ private boolean focusFollowsMouse = false; + /** + * If true, display a text-based mouse cursor. + */ + private boolean textMouse = true; + + /** + * If true, hide the mouse after typing a keystroke. + */ + private boolean hideMouseWhenTyping = false; + + /** + * If true, the mouse should not be displayed because a keystroke was + * typed. + */ + private boolean typingHidMouse = false; + /** * The list of commands to run before the next I/O check. */ @@ -722,6 +738,19 @@ public class TApplication implements Runnable { ); } } + + // Text block mouse option + if (System.getProperty("jexer.textMouse", "true").equals("false")) { + textMouse = false; + } + + // Hide mouse when typing option + if (System.getProperty("jexer.hideMouseWhenTyping", + "false").equals("true")) { + + hideMouseWhenTyping = true; + } + } // ------------------------------------------------------------------------ @@ -1086,8 +1115,16 @@ public class TApplication implements Runnable { // Special application-wide events ----------------------------------- + if (event instanceof TKeypressEvent) { + if (hideMouseWhenTyping) { + typingHidMouse = true; + } + } + // Peek at the mouse position if (event instanceof TMouseEvent) { + typingHidMouse = false; + TMouseEvent mouse = (TMouseEvent) event; if ((mouseX != mouse.getX()) || (mouseY != mouse.getY())) { oldMouseX = mouseX; @@ -1273,6 +1310,8 @@ public class TApplication implements Runnable { // Peek at the mouse position if (event instanceof TMouseEvent) { + typingHidMouse = false; + TMouseEvent mouse = (TMouseEvent) event; if ((mouseX != mouse.getX()) || (mouseY != mouse.getY())) { oldMouseX = mouseX; @@ -1695,17 +1734,16 @@ public class TApplication implements Runnable { Cell cell = getScreen().getCharXY(x, y); if (cell.isImage()) { cell.invertImage(); + } + if (cell.getForeColorRGB() < 0) { + cell.setForeColor(cell.getForeColor().invert()); } else { - if (cell.getForeColorRGB() < 0) { - cell.setForeColor(cell.getForeColor().invert()); - } else { - cell.setForeColorRGB(cell.getForeColorRGB() ^ 0x00ffffff); - } - if (cell.getBackColorRGB() < 0) { - cell.setBackColor(cell.getBackColor().invert()); - } else { - cell.setBackColorRGB(cell.getBackColorRGB() ^ 0x00ffffff); - } + cell.setForeColorRGB(cell.getForeColorRGB() ^ 0x00ffffff); + } + if (cell.getBackColorRGB() < 0) { + cell.setBackColor(cell.getBackColor().invert()); + } else { + cell.setBackColorRGB(cell.getBackColorRGB() ^ 0x00ffffff); } getScreen().putCharXY(x, y, cell); if ((onlyThisCell == true) || (cell.getWidth() == Cell.Width.SINGLE)) { @@ -1790,8 +1828,10 @@ public class TApplication implements Runnable { } } - // Draw mouse at the new position. - invertCell(mouseX, mouseY); + if ((textMouse == true) && (typingHidMouse == false)) { + // Draw mouse at the new position. + invertCell(mouseX, mouseY); + } oldDrawnMouseX = mouseX; oldDrawnMouseY = mouseY; @@ -1856,7 +1896,7 @@ public class TApplication implements Runnable { menuColor); getScreen().putStringXY(x + 1, 0, menu.getTitle(), menuColor); // Draw the highlight character - getScreen().putCharXY(x + 1 + menu.getMnemonic().getShortcutIdx(), + getScreen().putCharXY(x + 1 + menu.getMnemonic().getScreenShortcutIdx(), 0, menu.getMnemonic().getShortcut(), menuMnemonicColor); if (menu.isActive()) { @@ -1917,7 +1957,9 @@ public class TApplication implements Runnable { getScreen().unsetImageRow(mouseY); } } - invertCell(mouseX, mouseY); + if ((textMouse == true) && (typingHidMouse == false)) { + invertCell(mouseX, mouseY); + } oldDrawnMouseX = mouseX; oldDrawnMouseY = mouseY;