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