1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
5 import jexer
.TApplication
;
6 import jexer
.TApplication
.BackendType
;
7 import be
.nikiroo
.fanfix
.Instance
;
10 * This {@link Reader}is based upon the TUI widget library 'jexer'
11 * (https://github.com/klamonte/jexer/) and offer, as its name suggest, a Text
14 * It is expected to be on par with the GUI version.
18 class TuiReader
extends BasicReader
{
20 * Will detect the backend to use.
22 * Swing is the default backend on Windows and MacOS while evreything else
23 * will use XTERM unless explicitly overridden by <tt>jexer.Swing</tt> =
24 * <tt>true</tt> or <tt>false</tt>.
26 * @return the backend to use
28 private static BackendType
guessBackendType() {
29 // TODO: allow a config option to force one or the other?
30 TApplication
.BackendType backendType
= TApplication
.BackendType
.XTERM
;
31 if (System
.getProperty("os.name").startsWith("Windows")) {
32 backendType
= TApplication
.BackendType
.SWING
;
35 if (System
.getProperty("os.name").startsWith("Mac")) {
36 backendType
= TApplication
.BackendType
.SWING
;
39 if (System
.getProperty("jexer.Swing") != null) {
40 if (System
.getProperty("jexer.Swing", "false").equals("true")) {
41 backendType
= TApplication
.BackendType
.SWING
;
43 backendType
= TApplication
.BackendType
.XTERM
;
51 public void read() throws IOException
{
53 TuiReaderApplication app
= new TuiReaderApplication(this,
55 new Thread(app
).start();
56 } catch (Exception e
) {
62 public void browse(String source
) {
64 TuiReaderApplication app
= new TuiReaderApplication(this, source
,
66 new Thread(app
).start();
67 } catch (Exception e
) {