hideStatusBar and hideMenuBar
authorKevin Lamonte <kevin.lamonte@gmail.com>
Sun, 18 Aug 2019 02:54:43 +0000 (21:54 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Sun, 18 Aug 2019 02:54:43 +0000 (21:54 -0500)
src/jexer/TApplication.java
src/jexer/TDesktop.java
src/jexer/TEditorWindow.java
src/jexer/TImageWindow.java
src/jexer/TWindow.java

index 0f50457a9b66f77ee38f05fff4ffa51da318317f..9c9c5714c67cbad7eb7a093fe049644f88250b13 100644 (file)
@@ -270,7 +270,7 @@ public class TApplication implements Runnable {
      * constant.  Someday it would be nice to have a multi-line menu or
      * toolbars.
      */
-    private static final int desktopTop = 1;
+    private int desktopTop = 1;
 
     /**
      * Y coordinate of the bottom edge of the desktop.
@@ -305,6 +305,16 @@ public class TApplication implements Runnable {
      */
     private boolean typingHidMouse = false;
 
+    /**
+     * If true, hide the status bar.
+     */
+    private boolean hideStatusBar = false;
+
+    /**
+     * If true, hide the menu bar.
+     */
+    private boolean hideMenuBar = false;
+
     /**
      * The list of commands to run before the next I/O check.
      */
@@ -705,8 +715,32 @@ public class TApplication implements Runnable {
      * Finish construction once the backend is set.
      */
     private void TApplicationImpl() {
+        // 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;
+        }
+
+        // Hide status bar option
+        if (System.getProperty("jexer.hideStatusBar",
+                "false").equals("true")) {
+            hideStatusBar = true;
+        }
+
+        // Hide menu bar option
+        if (System.getProperty("jexer.hideMenuBar", "false").equals("true")) {
+            hideMenuBar = true;
+        }
+
         theme           = new ColorTheme();
-        desktopBottom   = getScreen().getHeight() - 1;
+        desktopTop      = (hideMenuBar ? 0 : 1);
+        desktopBottom   = getScreen().getHeight() - 1 + (hideStatusBar ? 1 : 0);
         fillEventQueue  = new LinkedList<TInputEvent>();
         drainEventQueue = new LinkedList<TInputEvent>();
         windows         = new LinkedList<TWindow>();
@@ -739,18 +773,6 @@ 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;
-        }
-
     }
 
     // ------------------------------------------------------------------------
@@ -895,7 +917,7 @@ public class TApplication implements Runnable {
             return true;
         }
 
-        if (command.equals(cmMenu)) {
+        if (command.equals(cmMenu) && (hideMenuBar == false)) {
             if (!modalWindowActive() && (activeMenu == null)) {
                 if (menus.size() > 0) {
                     menus.get(0).setActive(true);
@@ -980,6 +1002,7 @@ public class TApplication implements Runnable {
             && !keypress.getKey().isCtrl()
             && (activeMenu == null)
             && !modalWindowActive()
+            && (hideMenuBar == false)
         ) {
 
             assert (subMenus.size() == 0);
@@ -1068,6 +1091,9 @@ public class TApplication implements Runnable {
                         screenResizeTime = System.currentTimeMillis();
                     }
                     desktopBottom = getScreen().getHeight() - 1;
+                    if (hideStatusBar) {
+                        desktopBottom++;
+                    }
                     mouseX = 0;
                     mouseY = 0;
                     oldMouseX = 0;
@@ -1075,7 +1101,7 @@ public class TApplication implements Runnable {
                 }
                 if (desktop != null) {
                     desktop.setDimensions(0, 0, resize.getWidth(),
-                        resize.getHeight() - 1);
+                        resize.getHeight() - (hideStatusBar ? 0 : 1));
                     desktop.onResize(resize);
                 }
 
@@ -1872,63 +1898,71 @@ public class TApplication implements Runnable {
             }
         }
 
-        // Draw the blank menubar line - reset the screen clipping first so
-        // it won't trim it out.
-        getScreen().resetClipping();
-        getScreen().hLineXY(0, 0, getScreen().getWidth(), ' ',
-            theme.getColor("tmenu"));
-        // Now draw the menus.
-        int x = 1;
-        for (TMenu menu: menus) {
-            CellAttributes menuColor;
-            CellAttributes menuMnemonicColor;
-            if (menu.isActive()) {
-                menuIsActive = true;
-                menuColor = theme.getColor("tmenu.highlighted");
-                menuMnemonicColor = theme.getColor("tmenu.mnemonic.highlighted");
-                topLevel = menu;
-            } else {
-                menuColor = theme.getColor("tmenu");
-                menuMnemonicColor = theme.getColor("tmenu.mnemonic");
-            }
-            // Draw the menu title
-            getScreen().hLineXY(x, 0, StringUtils.width(menu.getTitle()) + 2, ' ',
-                menuColor);
-            getScreen().putStringXY(x + 1, 0, menu.getTitle(), menuColor);
-            // Draw the highlight character
-            getScreen().putCharXY(x + 1 + menu.getMnemonic().getScreenShortcutIdx(),
-                0, menu.getMnemonic().getShortcut(), menuMnemonicColor);
-
-            if (menu.isActive()) {
-                ((TWindow) menu).drawChildren();
-                // Reset the screen clipping so we can draw the next title.
-                getScreen().resetClipping();
-            }
-            x += StringUtils.width(menu.getTitle()) + 2;
-        }
+        if (hideMenuBar == false) {
 
-        for (TMenu menu: subMenus) {
-            // Reset the screen clipping so we can draw the next sub-menu.
+            // Draw the blank menubar line - reset the screen clipping first
+            // so it won't trim it out.
             getScreen().resetClipping();
-            ((TWindow) menu).drawChildren();
+            getScreen().hLineXY(0, 0, getScreen().getWidth(), ' ',
+                theme.getColor("tmenu"));
+            // Now draw the menus.
+            int x = 1;
+            for (TMenu menu: menus) {
+                CellAttributes menuColor;
+                CellAttributes menuMnemonicColor;
+                if (menu.isActive()) {
+                    menuIsActive = true;
+                    menuColor = theme.getColor("tmenu.highlighted");
+                    menuMnemonicColor = theme.getColor("tmenu.mnemonic.highlighted");
+                    topLevel = menu;
+                } else {
+                    menuColor = theme.getColor("tmenu");
+                    menuMnemonicColor = theme.getColor("tmenu.mnemonic");
+                }
+                // Draw the menu title
+                getScreen().hLineXY(x, 0,
+                    StringUtils.width(menu.getTitle()) + 2, ' ', menuColor);
+                getScreen().putStringXY(x + 1, 0, menu.getTitle(), menuColor);
+                // Draw the highlight character
+                getScreen().putCharXY(x + 1 +
+                    menu.getMnemonic().getScreenShortcutIdx(),
+                    0, menu.getMnemonic().getShortcut(), menuMnemonicColor);
+
+                if (menu.isActive()) {
+                    ((TWindow) menu).drawChildren();
+                    // Reset the screen clipping so we can draw the next
+                    // title.
+                    getScreen().resetClipping();
+                }
+                x += StringUtils.width(menu.getTitle()) + 2;
+            }
+
+            for (TMenu menu: subMenus) {
+                // Reset the screen clipping so we can draw the next
+                // sub-menu.
+                getScreen().resetClipping();
+                ((TWindow) menu).drawChildren();
+            }
         }
         getScreen().resetClipping();
 
-        // Draw the status bar of the top-level window
-        TStatusBar statusBar = null;
-        if (topLevel != null) {
-            statusBar = topLevel.getStatusBar();
-        }
-        if (statusBar != null) {
-            getScreen().resetClipping();
-            statusBar.setWidth(getScreen().getWidth());
-            statusBar.setY(getScreen().getHeight() - topLevel.getY());
-            statusBar.draw();
-        } else {
-            CellAttributes barColor = new CellAttributes();
-            barColor.setTo(getTheme().getColor("tstatusbar.text"));
-            getScreen().hLineXY(0, desktopBottom, getScreen().getWidth(), ' ',
-                barColor);
+        if (hideStatusBar == false) {
+            // Draw the status bar of the top-level window
+            TStatusBar statusBar = null;
+            if (topLevel != null) {
+                statusBar = topLevel.getStatusBar();
+            }
+            if (statusBar != null) {
+                getScreen().resetClipping();
+                statusBar.setWidth(getScreen().getWidth());
+                statusBar.setY(getScreen().getHeight() - topLevel.getY());
+                statusBar.draw();
+            } else {
+                CellAttributes barColor = new CellAttributes();
+                barColor.setTo(getTheme().getColor("tstatusbar.text"));
+                getScreen().hLineXY(0, desktopBottom, getScreen().getWidth(),
+                    ' ', barColor);
+            }
         }
 
         // Draw the mouse pointer
@@ -2432,6 +2466,7 @@ public class TApplication implements Runnable {
             if (((window.flags & TWindow.CENTERED) == 0)
                 && ((window.flags & TWindow.ABSOLUTEXY) == 0)
                 && (smartWindowPlacement == true)
+                && (!(window instanceof TDesktop))
             ) {
 
                 doSmartPlacement(window);
@@ -2770,6 +2805,7 @@ public class TApplication implements Runnable {
             && (!modalWindowActive())
             && (!overrideMenuWindowActive())
             && (mouse.getAbsoluteY() == 0)
+            && (hideMenuBar == false)
         ) {
 
             for (TMenu menu: subMenus) {
@@ -2797,6 +2833,7 @@ public class TApplication implements Runnable {
             && (mouse.isMouse1())
             && (activeMenu != null)
             && (mouse.getAbsoluteY() == 0)
+            && (hideMenuBar == false)
         ) {
 
             TMenu oldMenu = activeMenu;
@@ -2965,6 +3002,7 @@ public class TApplication implements Runnable {
      */
     public final void switchMenu(final boolean forward) {
         assert (activeMenu != null);
+        assert (hideMenuBar == false);
 
         for (TMenu menu: subMenus) {
             menu.setActive(false);
index 20e6fd04c405e9edc918cdca4821264976929a4d..fd56a7fb55abbe8d3d71b0c5e6f6310aa2dd04e3 100644 (file)
@@ -61,9 +61,8 @@ public class TDesktop extends TWindow {
      * @param parent parent application
      */
     public TDesktop(final TApplication parent) {
-
         super(parent, "", 0, 0, parent.getScreen().getWidth(),
-            parent.getScreen().getHeight() - 1);
+            parent.getDesktopBottom() - parent.getDesktopTop());
 
         setActive(false);
     }
index 85bb91a273169da8f4fdd0e4749c521c4f6b5968..b5c4cf19116dd54b38cc59b296bda50d98309945 100644 (file)
@@ -97,7 +97,7 @@ public class TEditorWindow extends TScrollableWindow {
     public TEditorWindow(final TApplication parent, final String title) {
 
         super(parent, title, 0, 0, parent.getScreen().getWidth(),
-            parent.getScreen().getHeight() - 2, RESIZABLE);
+            parent.getDesktopBottom() - parent.getDesktopTop(), RESIZABLE);
 
         editField = addEditor("", 0, 0, getWidth() - 2, getHeight() - 2);
         setupAfterEditor();
@@ -114,7 +114,7 @@ public class TEditorWindow extends TScrollableWindow {
         final String contents) {
 
         super(parent, title, 0, 0, parent.getScreen().getWidth(),
-            parent.getScreen().getHeight() - 2, RESIZABLE);
+            parent.getDesktopBottom() - parent.getDesktopTop(), RESIZABLE);
 
         filename = title;
         editField = addEditor(contents, 0, 0, getWidth() - 2, getHeight() - 2);
@@ -132,7 +132,7 @@ public class TEditorWindow extends TScrollableWindow {
         final File file) throws IOException {
 
         super(parent, file.getName(), 0, 0, parent.getScreen().getWidth(),
-            parent.getScreen().getHeight() - 2, RESIZABLE);
+            parent.getDesktopBottom() - parent.getDesktopTop(), RESIZABLE);
 
         filename = file.getName();
         String contents = readFileData(file);
index 057f6ac18f9cd707fcad9b2d2ed4d340d0bb64f3..15db1da3dd4f61fa3e387c314bc4291e38a8ec47 100644 (file)
@@ -82,7 +82,7 @@ public class TImageWindow extends TScrollableWindow {
         final File file) throws IOException {
 
         this(parent, file, 0, 0, parent.getScreen().getWidth(),
-            parent.getScreen().getHeight() - 2);
+            parent.getDesktopBottom() - parent.getDesktopTop());
     }
 
     /**
index 2855209eda870bb5a5bc44c9d2670585f7400d89..20f88d6da388500154b25fa0e91e7e76611871b7 100644 (file)
@@ -1124,9 +1124,9 @@ public class TWindow extends TWidget {
         restoreWindowX = getX();
         restoreWindowY = getY();
         setWidth(getScreen().getWidth());
-        setHeight(application.getDesktopBottom() - 1);
+        setHeight(application.getDesktopBottom() - application.getDesktopTop());
         setX(0);
-        setY(1);
+        setY(application.getDesktopTop());
         maximized = true;
 
         onResize(new TResizeEvent(TResizeEvent.Type.WIDGET, getWidth(),