Fix: do not sysout/syserr in TUI mode + some fixes
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / TuiReaderApplication.java
index 93a0167fe6be9e21b63718a4c2b0d326cc403065..3d6a949528630e4733f945eb19724977788c6859 100644 (file)
@@ -7,6 +7,9 @@ import java.util.List;
 import jexer.TApplication;
 import jexer.TMessageBox;
 import jexer.TWindow;
+import be.nikiroo.fanfix.Instance;
+import be.nikiroo.fanfix.Instance.SyserrHandler;
+import be.nikiroo.fanfix.Instance.TraceHandler;
 import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.library.BasicLibrary;
@@ -46,6 +49,8 @@ class TuiReaderApplication extends TApplication implements Reader {
                new TuiReaderMainWindow(this).setMetas(stories);
        }
 
+       @SuppressWarnings("unused")
+       @Override
        public void read() throws IOException {
                MetaData meta = getMeta();
 
@@ -66,42 +71,52 @@ class TuiReaderApplication extends TApplication implements Reader {
                }
        }
 
+       @Override
        public MetaData getMeta() {
                return reader.getMeta();
        }
 
+       @Override
        public Story getStory(Progress pg) {
                return reader.getStory(pg);
        }
 
+       @Override
        public BasicLibrary getLibrary() {
                return reader.getLibrary();
        }
 
+       @Override
        public void setLibrary(BasicLibrary lib) {
                reader.setLibrary(lib);
        }
 
+       @Override
        public void setMeta(MetaData meta) throws IOException {
                reader.setMeta(meta);
        }
 
+       @Override
        public void setMeta(String luid) throws IOException {
                reader.setMeta(luid);
        }
 
+       @Override
        public void setMeta(URL source, Progress pg) throws IOException {
                reader.setMeta(source, pg);
        }
 
+       @Override
        public void browse(String source) {
                reader.browse(source);
        }
 
+       @Override
        public int getChapter() {
                return reader.getChapter();
        }
 
+       @Override
        public void setChapter(int chapter) {
                reader.setChapter(chapter);
        }
@@ -109,6 +124,22 @@ class TuiReaderApplication extends TApplication implements Reader {
        private void init(Reader reader) {
                this.reader = reader;
 
+               // Do not allow traces/debug to pollute the screen:
+               Instance.setSyserrHandler(new SyserrHandler() {
+                       @Override
+                       public void notify(Exception e, boolean showDetails) {
+                               // TODO
+                       }
+               });
+
+               Instance.setTraceHandler(new TraceHandler() {
+                       @Override
+                       public void trace(String message) {
+                               // TODO
+                       }
+               });
+               //
+
                // Add the menus
                addFileMenu();
                addEditMenu();