X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTEditorWindow.java;h=85bb91a273169da8f4fdd0e4749c521c4f6b5968;hb=e23989a4e74f7a7a08496aac956d1abe429bd6c0;hp=495131106e7b9fad3fa38a1f3ddadf159238d776;hpb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;p=fanfix.git diff --git a/src/jexer/TEditorWindow.java b/src/jexer/TEditorWindow.java index 4951311..85bb91a 100644 --- a/src/jexer/TEditorWindow.java +++ b/src/jexer/TEditorWindow.java @@ -73,6 +73,17 @@ public class TEditorWindow extends TScrollableWindow { */ private String filename = ""; + /** + * If true, hide the mouse after typing a keystroke. + */ + private boolean hideMouseWhenTyping = true; + + /** + * If true, the mouse should not be displayed because a keystroke was + * typed. + */ + private boolean typingHidMouse = false; + // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ @@ -173,6 +184,10 @@ public class TEditorWindow extends TScrollableWindow { // Use TWidget's code to pass the event to the children. super.onMouseDown(mouse); + if (hideMouseWhenTyping) { + typingHidMouse = false; + } + if (mouseOnEditor(mouse)) { // The editor might have changed, update the scollbars. setBottomValue(editField.getMaximumRowNumber()); @@ -197,6 +212,10 @@ public class TEditorWindow extends TScrollableWindow { // Use TWidget's code to pass the event to the children. super.onMouseUp(mouse); + if (hideMouseWhenTyping) { + typingHidMouse = false; + } + if (mouse.isMouse1() && mouseOnVerticalScroller(mouse)) { // Clicked on vertical scrollbar editField.setVisibleRowNumber(getVerticalValue()); @@ -215,6 +234,10 @@ public class TEditorWindow extends TScrollableWindow { // Use TWidget's code to pass the event to the children. super.onMouseMotion(mouse); + if (hideMouseWhenTyping) { + typingHidMouse = false; + } + if (mouseOnEditor(mouse) && mouse.isMouse1()) { // The editor might have changed, update the scollbars. setBottomValue(editField.getMaximumRowNumber()); @@ -239,6 +262,10 @@ public class TEditorWindow extends TScrollableWindow { */ @Override public void onKeypress(final TKeypressEvent keypress) { + if (hideMouseWhenTyping) { + typingHidMouse = true; + } + // Use TWidget's code to pass the event to the children. super.onKeypress(keypress); @@ -318,6 +345,18 @@ public class TEditorWindow extends TScrollableWindow { super.onCommand(command); } + /** + * Returns true if this window does not want the application-wide mouse + * cursor drawn over it. + * + * @return true if this window does not want the application-wide mouse + * cursor drawn over it + */ + @Override + public boolean hasHiddenMouse() { + return (super.hasHiddenMouse() || typingHidMouse); + } + // ------------------------------------------------------------------------ // TEditorWindow ---------------------------------------------------------- // ------------------------------------------------------------------------ @@ -344,6 +383,13 @@ public class TEditorWindow extends TScrollableWindow { i18n.getString("statusBarOpen")); statusBar.addShortcutKeypress(kbF10, cmMenu, i18n.getString("statusBarMenu")); + + // Hide mouse when typing option + if (System.getProperty("jexer.TEditor.hideMouseWhenTyping", + "true").equals("false")) { + + hideMouseWhenTyping = false; + } } /** @@ -386,7 +432,7 @@ public class TEditorWindow extends TScrollableWindow { * @param mouse a mouse-based event * @return whether or not the mouse is on the editor */ - private final boolean mouseOnEditor(final TMouseEvent mouse) { + private boolean mouseOnEditor(final TMouseEvent mouse) { if ((mouse.getAbsoluteX() >= getAbsoluteX() + 1) && (mouse.getAbsoluteX() < getAbsoluteX() + getWidth() - 1) && (mouse.getAbsoluteY() >= getAbsoluteY() + 1)