wip
[fanfix.git] / src / be / nikiroo / fanfix / reader / tui / TuiReaderMainWindow.java
index a2313775a2411299d44611a88da0877ea6c6daa7..bb2c80d5cbb7290f393df79c44c949aadbb37f60 100644 (file)
@@ -2,12 +2,14 @@ package be.nikiroo.fanfix.reader.tui;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import jexer.TAction;
 import jexer.TFileOpenBox.Type;
 import jexer.TList;
 import jexer.TWindow;
+import jexer.event.TCommandEvent;
 import jexer.event.TMenuEvent;
 import be.nikiroo.fanfix.Instance;
 import be.nikiroo.fanfix.data.MetaData;
@@ -45,7 +47,22 @@ class TuiReaderMainWindow extends TWindow {
 
                listKeys = new ArrayList<MetaData>();
                listItems = new ArrayList<String>();
-               list = addList(listItems, 0, 0, getWidth(), getHeight(), new TAction() {
+
+               // TODO size + onResize
+
+               addLabel("Sort by: ", 5, 1);
+               // -1 = no default index (0 means first,...) 1=height when visible, null
+               // = action
+               addComboBox(15, 1, 12,
+                               Arrays.asList("(show all)", "Source", "Name", "Author"), 0, 1,
+                               null);
+
+               addLabel("Search: ", 5, 3);
+               addEditor("...", 15, 3, 12, 1); // TODO: cannot see where to type, ^H
+                                                                               // not working, TAB insert a TAB (cannot
+                                                                               // switch to next)
+
+               list = addList(listItems, 0, 5, getWidth(), getHeight(), new TAction() {
                        @Override
                        public void DO() {
                                MetaData meta = getSelectedMeta();
@@ -162,6 +179,16 @@ class TuiReaderMainWindow extends TWindow {
                return String.format("%5s: %s", meta.getLuid(), meta.getTitle());
        }
 
+       @Override
+       public void onCommand(TCommandEvent command) {
+               if (command.getCmd().equals(TuiReaderApplication.CMD_EXIT)) {
+                       TuiReaderApplication.close(this);
+               } else {
+                       // Handle our own event if needed here
+                       super.onCommand(command);
+               }
+       }
+
        @Override
        public void onMenu(TMenuEvent menu) {
                MetaData meta = getSelectedMeta();