X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Ftui%2FTuiReaderMainWindow.java;h=bb2c80d5cbb7290f393df79c44c949aadbb37f60;hb=e9d43c7c0b9e159909ed9cdce4e907056fab8d9c;hp=0fccfafaaab717fc33726be4c49aaaba41bf3210;hpb=16a81ef7656c5c692fb831927e75edde25dd77a0;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReaderMainWindow.java b/src/be/nikiroo/fanfix/reader/tui/TuiReaderMainWindow.java index 0fccfaf..bb2c80d 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReaderMainWindow.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReaderMainWindow.java @@ -2,14 +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.TCommand; import jexer.TFileOpenBox.Type; -import jexer.TKeypress; 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; @@ -39,8 +39,7 @@ class TuiReaderMainWindow extends TWindow { public TuiReaderMainWindow(TuiReaderApplication reader) { // Construct a demo window. X and Y don't matter because it will be // centred on screen. - super(reader, "Library", 0, 0, 60, 18, CENTERED | RESIZABLE - | UNCLOSABLE); + super(reader, "Library", 0, 0, 60, 18, CENTERED | RESIZABLE); this.reader = reader; @@ -48,7 +47,22 @@ class TuiReaderMainWindow extends TWindow { listKeys = new ArrayList(); listItems = new ArrayList(); - 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(); @@ -59,8 +73,7 @@ class TuiReaderMainWindow extends TWindow { }); // TODO: add the current "source/type" or filter - statusBar = newStatusBar("Library"); - statusBar.addShortcutKeypress(TKeypress.kbF10, TCommand.cmExit, "Exit"); + reader.setStatusBar(this, "Library"); // TODO: remove when not used anymore @@ -87,6 +100,12 @@ class TuiReaderMainWindow extends TWindow { // root.addChild("child 2").addChild("sub child"); } + @Override + public void onClose() { + setVisible(false); + super.onClose(); + } + /** * Change the source filter and display all stories matching this source. * @@ -160,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();