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