Add a new TUI system based upon Jexer (WIP)
[fanfix.git] / src / be / nikiroo / fanfix / reader / TuiReader.java
diff --git a/src/be/nikiroo/fanfix/reader/TuiReader.java b/src/be/nikiroo/fanfix/reader/TuiReader.java
new file mode 100644 (file)
index 0000000..d18436f
--- /dev/null
@@ -0,0 +1,35 @@
+package be.nikiroo.fanfix.reader;
+
+import java.io.IOException;
+import java.util.List;
+
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.data.MetaData;
+
+class TuiReader extends BasicReader {
+       @Override
+       public void read() throws IOException {
+               if (getStory() == null) {
+                       throw new IOException("No story to read");
+               }
+
+               open(getStory().getMeta().getLuid());
+       }
+
+       @Override
+       public void read(int chapter) throws IOException {
+               // TODO: show a special page?
+               read();
+       }
+
+       @Override
+       public void start(String type) {
+               List<MetaData> stories = Instance.getLibrary().getListByType(type);
+               try {
+                       TuiReaderApplication app = new TuiReaderApplication(stories, this);
+                       new Thread(app).start();
+               } catch (Exception e) {
+                       Instance.syserr(e);
+               }
+       }
+}