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
;
10 import be
.nikiroo
.fanfix
.supported
.SupportType
;
13 * This {@link Reader}is based upon the TUI widget library 'jexer'
14 * (https://github.com/klamonte/jexer/) and offer, as its name suggest, a Text
17 * It is expected to be on par with the GUI version.
21 class TuiReader
extends BasicReader
{
23 * Will detect the backend to use.
25 * Swing is the default backend on Windows and MacOS while evreything else
26 * will use XTERM unless explicitly overridden by <tt>jexer.Swing</tt> =
27 * <tt>true</tt> or <tt>false</tt>.
29 * @return the backend to use
31 private static BackendType
guessBackendType() {
32 // TODO: allow a config option to force one or the other?
33 TApplication
.BackendType backendType
= TApplication
.BackendType
.XTERM
;
34 if (System
.getProperty("os.name").startsWith("Windows")) {
35 backendType
= TApplication
.BackendType
.SWING
;
38 if (System
.getProperty("os.name").startsWith("Mac")) {
39 backendType
= TApplication
.BackendType
.SWING
;
42 if (System
.getProperty("jexer.Swing") != null) {
43 if (System
.getProperty("jexer.Swing", "false").equals("true")) {
44 backendType
= TApplication
.BackendType
.SWING
;
46 backendType
= TApplication
.BackendType
.XTERM
;
54 public void read(boolean sync
) throws IOException
{
56 TuiReaderApplication app
= new TuiReaderApplication(this,
58 new Thread(app
).start();
59 } catch (Exception e
) {
60 Instance
.getTraceHandler().error(e
);
65 public void browse(String source
) {
67 TuiReaderApplication app
= new TuiReaderApplication(this, source
,
69 new Thread(app
).start();
70 } catch (Exception e
) {
71 Instance
.getTraceHandler().error(e
);
76 public void search(SupportType searchOn
, String keywords
, int page
, int item
) {
78 throw new java
.lang
.IllegalStateException("Not implemented yet.");
82 public void searchTag(SupportType searchOn
, int page
, int item
, String
... tags
) {
84 throw new java
.lang
.IllegalStateException("Not implemented yet.");