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