1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
6 import jexer
.TApplication
;
7 import jexer
.TMessageBox
;
8 import be
.nikiroo
.fanfix
.Instance
;
9 import be
.nikiroo
.fanfix
.data
.MetaData
;
11 public class TuiReaderApplication
extends TApplication
{
12 private BasicReader reader
;
14 private static BackendType
guessBackendType() {
15 // Swing is the default backend on Windows unless explicitly
16 // overridden by jexer.Swing.
17 TApplication
.BackendType backendType
= TApplication
.BackendType
.XTERM
;
18 if (System
.getProperty("os.name").startsWith("Windows")) {
19 backendType
= TApplication
.BackendType
.SWING
;
21 if (System
.getProperty("os.name").startsWith("Mac")) {
22 backendType
= TApplication
.BackendType
.SWING
;
24 if (System
.getProperty("jexer.Swing") != null) {
25 if (System
.getProperty("jexer.Swing", "false").equals("true")) {
26 backendType
= TApplication
.BackendType
.SWING
;
28 backendType
= TApplication
.BackendType
.XTERM
;
34 public TuiReaderApplication(List
<MetaData
> stories
, BasicReader reader
)
36 this(stories
, reader
, guessBackendType());
39 public TuiReaderApplication(List
<MetaData
> stories
, BasicReader reader
,
40 TApplication
.BackendType backend
) throws Exception
{
51 getBackend().setTitle("Fanfix");
53 new TuiReaderMainWindow(this, stories
);
56 public void open(MetaData meta
) {
57 // TODO: open in editor + external option
59 if (!meta
.isImageDocument()) {
60 new TuiReaderStoryWindow(this, meta
);
62 messageBox("Error when trying to open the story",
63 "Images document not yet supported.",
69 reader
.open(meta
.getLuid());
70 } catch (IOException e
) {
71 messageBox("Error when trying to open the story", e
.getMessage(),