minor cleanup
[fanfix.git] / src / jexer / demos / Demo8.java
CommitLineData
5ffeabcc
KL
1/*
2 * Jexer - Java Text User Interface
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (C) 2019 Kevin Lamonte
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 *
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
27 * @version 1
28 */
29package jexer.demos;
30
31import java.util.ResourceBundle;
32
33import jexer.TApplication;
34import jexer.TPanel;
35import jexer.TSplitPane;
c7a75ad3 36import jexer.TTerminalWidget;
5ffeabcc
KL
37import jexer.TText;
38import jexer.TWindow;
39import jexer.layout.BoxLayoutManager;
40import jexer.menu.TMenu;
41
42/**
43 * This class shows off TSplitPane.
44 */
45public class Demo8 {
46
47 /**
48 * Translated strings.
49 */
50 private static final ResourceBundle i18n = ResourceBundle.getBundle(Demo8.class.getName());
51
52 // ------------------------------------------------------------------------
53 // Constants --------------------------------------------------------------
54 // ------------------------------------------------------------------------
55
56 private static String TEXT =
57"This is an example of a reflowable text field. Some example text follows.\n" +
58"\n" +
59"Notice that some menu items should be disabled when this window has focus.\n" +
60"\n" +
61"This library implements a text-based windowing system loosely " +
62"reminiscent of Borland's [Turbo " +
63"Vision](http://en.wikipedia.org/wiki/Turbo_Vision) library. For those " +
64"wishing to use the actual C++ Turbo Vision library, see [Sergio " +
65"Sigala's updated version](http://tvision.sourceforge.net/) that runs " +
66"on many more platforms.\n" +
67"\n" +
68"This library is licensed MIT. See the file LICENSE for the full license " +
69"for the details.\n";
70
469c2b3c
KL
71 /**
72 * Menu item: split vertically.
73 */
74 private static final int MENU_SPLIT_VERTICAL = 2000;
75
76 /**
77 * Menu item: split horizontally.
78 */
79 private static final int MENU_SPLIT_HORIZONTAL = 2001;
80
5ffeabcc
KL
81 // ------------------------------------------------------------------------
82 // Demo8 ------------------------------------------------------------------
83 // ------------------------------------------------------------------------
84
85 /**
86 * Main entry point.
87 *
88 * @param args Command line arguments
89 */
90 public static void main(final String [] args) throws Exception {
91 // This demo will build everything "from the outside".
92
93 // Swing is the default backend on Windows unless explicitly
94 // overridden by jexer.Swing.
95 TApplication.BackendType backendType = TApplication.BackendType.XTERM;
96 if (System.getProperty("os.name").startsWith("Windows")) {
97 backendType = TApplication.BackendType.SWING;
98 }
99 if (System.getProperty("os.name").startsWith("Mac")) {
100 backendType = TApplication.BackendType.SWING;
101 }
102 if (System.getProperty("jexer.Swing") != null) {
103 if (System.getProperty("jexer.Swing", "false").equals("true")) {
104 backendType = TApplication.BackendType.SWING;
105 } else {
106 backendType = TApplication.BackendType.XTERM;
107 }
108 }
109
110 // For this demo, let's disable the status bar.
111 System.setProperty("jexer.hideStatusBar", "true");
112
113 TApplication app = new TApplication(backendType);
114 app.addToolMenu();
115 app.addFileMenu();
116 TWindow window = new TWindow(app, i18n.getString("windowTitle"),
117 60, 22);
118
119 TMenu paneMenu = app.addMenu(i18n.getString("paneMenu"));
469c2b3c
KL
120 paneMenu.addItem(MENU_SPLIT_VERTICAL,
121 i18n.getString("paneSplitVertical"));
122 paneMenu.addItem(MENU_SPLIT_HORIZONTAL,
123 i18n.getString("paneSplitHorizontal"));
5ffeabcc
KL
124
125 TSplitPane pane = window.addSplitPane(0, 0, window.getWidth() - 2,
126 window.getHeight() - 2, true);
127
c7a75ad3
KL
128 // pane.setLeft(new TText(null, TEXT, 0, 0, 10, 10));
129 // pane.setRight(new TText(null, TEXT, 0, 0, 10, 10));
130
131 // For this demo, let's require ptypipe
132 System.setProperty("jexer.TTerminal.ptypipe", "true");
133 pane.setLeft(new TTerminalWidget(null, 0, 0));
134 pane.setRight(new TTerminalWidget(null, 0, 0));
5ffeabcc
KL
135
136 app.run();
137 }
138
139}