1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
6 import jexer
.TApplication
;
7 import jexer
.TApplication
.BackendType
;
8 import be
.nikiroo
.fanfix
.Instance
;
9 import be
.nikiroo
.fanfix
.data
.MetaData
;
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
) {
64 public void browse(String source
) {
65 List
<MetaData
> metas
= getLibrary().getListBySource(source
);
67 TuiReaderApplication app
= new TuiReaderApplication(metas
, this,
69 new Thread(app
).start();
70 } catch (Exception e
) {