Commit | Line | Data |
---|---|---|
7d4115a5 KL |
1 | Jexer - Java Text User Interface library |
2 | ======================================== | |
3 | ||
4b257bd8 KL |
4 | This library implements a text-based windowing system reminiscient of |
5 | Borland's [Turbo Vision](http://en.wikipedia.org/wiki/Turbo_Vision) | |
6 | system. (For those wishing to use the actual C++ Turbo Vision | |
7 | library, see [Sergio Sigala's C++ version based on the public domain | |
8 | sources released by Borland.](http://tvision.sourceforge.net/) ) | |
30bd4abd | 9 | |
4b257bd8 | 10 | Jexer currently supports three backends: |
1ac2ccb1 | 11 | |
30bd4abd KL |
12 | * System.in/out to a command-line ECMA-48 / ANSI X3.64 type terminal |
13 | (tested on Linux + xterm). I/O is handled through terminal escape | |
14 | sequences generated by the library itself: ncurses is not required | |
b5f2a6db KL |
15 | or linked to. xterm mouse tracking using UTF8 and SGR coordinates |
16 | are supported. For the demo application, this is the default | |
17 | backend on non-Windows platforms. | |
1ac2ccb1 | 18 | |
55b4f29b KL |
19 | * The same command-line ECMA-48 / ANSI X3.64 type terminal as above, |
20 | but to any general InputStream/OutputStream. See the file | |
21 | jexer.demos.Demo2 for an example of running the demo over a TCP | |
22 | socket. | |
23 | ||
a4406f4e KL |
24 | * Java Swing UI. This backend can be selected by setting |
25 | jexer.Swing=true. The default window size for Swing is 132x40, | |
26 | which is set in jexer.session.SwingSession. For the demo | |
27 | application, this is the default backend on Windows platforms. | |
1ac2ccb1 | 28 | |
a4406f4e KL |
29 | Additional backends can be created by subclassing |
30 | jexer.backend.Backend and passing it into the TApplication | |
31 | constructor. | |
1ac2ccb1 KL |
32 | |
33 | ||
7d4115a5 KL |
34 | |
35 | License | |
36 | ------- | |
37 | ||
e16dda65 KL |
38 | This project is licensed under the MIT License. See the file LICENSE |
39 | for the full license text. | |
7d4115a5 KL |
40 | |
41 | ||
30bd4abd KL |
42 | |
43 | Acknowledgements | |
44 | ---------------- | |
45 | ||
46 | Jexer makes use of the Terminus TrueType font [made available | |
47 | here](http://files.ax86.net/terminus-ttf/) . | |
48 | ||
49 | ||
50 | ||
7d4115a5 KL |
51 | Usage |
52 | ----- | |
53 | ||
4b257bd8 | 54 | Simply subclass TApplication and then run it in a new thread: |
7d4115a5 KL |
55 | |
56 | ```Java | |
57 | import jexer.*; | |
58 | ||
4b257bd8 | 59 | class MyApplication extends TApplication { |
7d4115a5 | 60 | |
4b257bd8 | 61 | public MyApplication() throws Exception { |
a4406f4e | 62 | super(BackendType.SWING); // Could also use BackendType.XTERM |
7d4115a5 | 63 | |
fca67db0 KL |
64 | // Create standard menus for File and Window |
65 | addFileMenu(); | |
66 | addWindowMenu(); | |
4b257bd8 KL |
67 | |
68 | // Add a custom window, see below for its code. | |
69 | addWindow(new MyWindow(this)); | |
7d4115a5 KL |
70 | } |
71 | ||
72 | public static void main(String [] args) { | |
4b257bd8 KL |
73 | try { |
74 | MyApplication app = new MyApplication(); | |
75 | (new Thread(app)).start(); | |
76 | } catch (Throwable t) { | |
77 | t.printStackTrace(); | |
78 | } | |
7d4115a5 KL |
79 | } |
80 | } | |
81 | ``` | |
82 | ||
4b257bd8 KL |
83 | Similarly, subclass TWindow and add some widgets: |
84 | ||
85 | ```Java | |
86 | class MyWindow extends TWindow { | |
87 | ||
88 | public MyWindow(TApplication application) { | |
89 | // See TWindow's API for several constructors. This one uses the | |
90 | // application, title, width, and height. Note that the window width | |
91 | // and height include the borders. The widgets inside the window | |
92 | // will see (0, 0) as the top-left corner inside the borders, | |
93 | // i.e. what the window would see as (1, 1). | |
94 | super(application, "My Window", 30, 20); | |
95 | ||
96 | // See TWidget's API for convenience methods to add various kinds of | |
97 | // widgets. Note that ANY widget can be a container for other | |
98 | // widgets: TRadioGroup for example has TRadioButtons as child | |
99 | // widgets. | |
100 | ||
101 | // We will add a basic label, text entry field, and button. | |
102 | addLabel("This is a label", 5, 3); | |
103 | addField(5, 5, 20, false, "enter text here"); | |
104 | // For the button, we will pop up a message box if the user presses | |
105 | // it. | |
106 | addButton("Press &Me!", 5, 8, new TAction() { | |
107 | public void DO() { | |
108 | MyWindow.this.messageBox("Box Title", "You pressed me, yay!"); | |
109 | } | |
110 | } ); | |
111 | } | |
112 | } | |
113 | ``` | |
114 | ||
115 | Put these into a file, compile it with jexer.jar in the classpath, run | |
116 | it and you'll see an application like this: | |
117 | ||
118 | ![The Example Code Above](/screenshots/readme_application.png?raw=true "The application in the text of README.md") | |
119 | ||
120 | See the files in jexer.demos for many more detailed examples showing | |
121 | all of the existing UI controls. The demo can be run in three | |
122 | different ways: | |
123 | ||
124 | * 'java -jar jexer.jar' . This will use System.in/out with | |
125 | xterm-like sequences on non-Windows platforms. On Windows it will | |
126 | use a Swing JFrame. | |
127 | ||
128 | * 'java -Djexer.Swing=true -jar jexer.jar' . This will always use | |
129 | Swing on any platform. | |
130 | ||
131 | * 'java -cp jexer.jar jexer.demos.Demo2 PORT' (where PORT is a | |
132 | number to run the TCP daemon on). This will use the telnet | |
133 | protocol to establish an 8-bit clean channel and be aware of | |
134 | screen size changes. | |
135 | ||
136 | ||
137 | ||
138 | More Screenshots | |
139 | ---------------- | |
140 | ||
141 | ![Several Windows Open Including A Terminal](/screenshots/screenshot1.png?raw=true "Several Windows Open Including A Terminal") | |
142 | ||
143 | ![Yo Dawg...](/screenshots/yodawg.png?raw=true "Yo Dawg, I heard you like text windowing systems, so I ran a text windowing system inside your text windowing system so you can have a terminal in your terminal.") | |
144 | ||
145 | ||
146 | ||
147 | System Properties | |
148 | ----------------- | |
149 | ||
150 | The following properties control features of Jexer: | |
151 | ||
152 | jexer.Swing | |
153 | ----------- | |
154 | ||
155 | Used only by jexer.demos.Demo1. If true, use the Swing interface | |
156 | for the demo application. Default: true on Windows platforms | |
157 | (os.name starts with "Windows"), false on non-Windows platforms. | |
158 | ||
159 | jexer.Swing.cursorStyle | |
160 | ----------------------- | |
161 | ||
162 | Used by jexer.io.SwingScreen. Selects the cursor style to draw. | |
163 | Valid values are: underline, block, outline. Default: underline. | |
30bd4abd KL |
164 | |
165 | ||
7d4115a5 | 166 | |
92554d64 KL |
167 | Known Issues / Arbitrary Decisions |
168 | ---------------------------------- | |
169 | ||
170 | Some arbitrary design decisions had to be made when either the | |
171 | obviously expected behavior did not happen or when a specification was | |
172 | ambiguous. This section describes such issues. | |
173 | ||
bb35d919 | 174 | - TTerminalWindow will hang on input from the remote if the |
69345248 KL |
175 | TApplication is exited before the TTerminalWindow's process has |
176 | closed on its own. This is due to a Java limitation/interaction | |
177 | between blocking reads (which is necessary to get UTF8 translation | |
178 | correct) and file streams. | |
92554d64 | 179 | |
bd8d51fa KL |
180 | - See jexer.tterminal.ECMA48 for more specifics of terminal |
181 | emulation limitations. | |
182 | ||
a4406f4e KL |
183 | - TTerminalWindow uses cmd.exe on Windows. Output will not be seen |
184 | until enter is pressed, due to cmd.exe's use of line-oriented | |
185 | input (see the ENABLE_LINE_INPUT flag for GetConsoleMode() and | |
186 | SetConsoleMode()). | |
92554d64 | 187 | |
b5f2a6db KL |
188 | - TTerminalWindow launches 'script -fqe /dev/null' on non-Windows |
189 | platforms. This is a workaround for the C library behavior of | |
190 | checking for a tty: script launches $SHELL in a pseudo-tty. This | |
191 | works on Linux but might not on other Posix-y platforms. | |
192 | ||
e3dfbd23 KL |
193 | - Java's InputStreamReader as used by the ECMA48 backend requires a |
194 | valid UTF-8 stream. The default X10 encoding for mouse | |
195 | coordinates outside (160,94) can corrupt that stream, at best | |
196 | putting garbage keyboard events in the input queue but at worst | |
197 | causing the backend reader thread to throw an Exception and exit | |
198 | and make the entire UI unusable. Mouse support therefore requires | |
199 | a terminal that can deliver either UTF-8 coordinates (1005 mode) | |
200 | or SGR coordinates (1006 mode). Most modern terminals can do | |
201 | this. | |
b5f2a6db KL |
202 | |
203 | - jexer.session.TTYSession calls 'stty size' once every second to | |
204 | check the current window size, performing the same function as | |
205 | ioctl(TIOCGWINSZ) but without requiring a native library. | |
206 | ||
207 | - jexer.io.ECMA48Terminal calls 'stty' to perform the equivalent of | |
55b4f29b KL |
208 | cfmakeraw() when using System.in/out. System.out is also |
209 | (blindly!) put in 'stty sane cooked' mode when exiting. | |
210 | ||
b5f2a6db KL |
211 | |
212 | ||
7d4115a5 KL |
213 | Roadmap |
214 | ------- | |
215 | ||
30d336cc | 216 | Many tasks remain before calling this version 1.0: |
7d4115a5 | 217 | |
4b257bd8 | 218 | 0.0.4 |
7d4115a5 | 219 | |
cf9af8df | 220 | - TStatusBar |
cc99cba8 | 221 | - TEditor |
a4406f4e KL |
222 | - TWindow |
223 | - "Smart placement" for new windows | |
cc99cba8 | 224 | |
a4406f4e | 225 | 0.0.5: BUG HUNT |
cc99cba8 | 226 | |
e3dfbd23 | 227 | - Swing performance. Even with double buffering it isn't great. |
9edb442b | 228 | |
a4406f4e | 229 | 0.1.0: BETA RELEASE |
9edb442b | 230 | |
a4406f4e KL |
231 | - TSpinner |
232 | - TComboBox | |
a4406f4e | 233 | - TCalendar |
7d4115a5 KL |
234 | |
235 | Wishlist features (2.0): | |
236 | ||
237 | - TTerminal | |
238 | - Handle resize events (pass to child process) | |
7d4115a5 | 239 | - Screen |
4b257bd8 | 240 | - Allow complex characters in putCharXY() and detect them in putStringXY(). |
7d4115a5 KL |
241 | - Drag and drop |
242 | - TEditor | |
243 | - TField | |
244 | - TText | |
245 | - TTerminal | |
246 | - TComboBox |