1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
6 import jexer
.TApplication
;
7 import jexer
.TMessageBox
;
8 import be
.nikiroo
.fanfix
.data
.MetaData
;
10 class TuiReaderApplication
extends TApplication
{
11 private BasicReader reader
;
13 private static BackendType
guessBackendType() {
14 // Swing is the default backend on Windows unless explicitly
15 // overridden by jexer.Swing.
16 TApplication
.BackendType backendType
= TApplication
.BackendType
.XTERM
;
17 if (System
.getProperty("os.name").startsWith("Windows")) {
18 backendType
= TApplication
.BackendType
.SWING
;
20 if (System
.getProperty("os.name").startsWith("Mac")) {
21 backendType
= TApplication
.BackendType
.SWING
;
23 if (System
.getProperty("jexer.Swing") != null) {
24 if (System
.getProperty("jexer.Swing", "false").equals("true")) {
25 backendType
= TApplication
.BackendType
.SWING
;
27 backendType
= TApplication
.BackendType
.XTERM
;
33 public TuiReaderApplication(List
<MetaData
> stories
, BasicReader reader
)
35 this(stories
, reader
, guessBackendType());
38 public TuiReaderApplication(List
<MetaData
> stories
, BasicReader reader
,
39 TApplication
.BackendType backend
) throws Exception
{
50 getBackend().setTitle("Fanfix");
52 new TuiReaderMainWindow(this, stories
);
55 public void open(MetaData meta
) {
56 // TODO: open in editor + external option
57 if (!meta
.isImageDocument()) {
58 new TuiReaderStoryWindow(this, reader
.getLibrary(), meta
);
61 BasicReader
.open(reader
.getLibrary(), meta
.getLuid());
62 } catch (IOException e
) {
63 messageBox("Error when trying to open the story",
64 e
.getMessage(), TMessageBox
.Type
.OK
);