@mkdir -p bin/
@find src/be/ -name '*.java' > bin/files
-bin/lanterna: src/com/googlecode/lanterna/* src/com/googlecode/lanterna/*/* src/com/googlecode/lanterna/*/*/*
+bin/lanterna: src/resources/* src/com/googlecode/lanterna/* src/com/googlecode/lanterna/*/* src/com/googlecode/lanterna/*/*/*
@mkdir -p bin/
@find src/com/ -name '*.java' > bin/lanterna
+ cp -r src/resources/* bin/
javac -encoding UTF-8 -source 5 @bin/lanterna -d bin/ || rm bin/lanterna
@test -e bin/lanterna
}
if (values != null && values.length > 0)
- return String.format(locale, result, (Object[]) values);
+ return String.format(locale, result, values);
else
return result;
}
import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.TextColor;
-import com.googlecode.lanterna.gui2.DefaultWindowManager;
-import com.googlecode.lanterna.gui2.EmptySpace;
import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.screen.Screen;
*
*/
public class TuiLauncher {
+ static private Screen screen = null;
+
/**
* Start the TUI program.
*
TuiLauncher.start(textMode, win);
}
+ /**
+ * Return the used {@link Screen}.
+ *
+ * @return the {@link Screen}
+ */
+ static public Screen getScreen() {
+ return screen;
+ }
+
/**
* Start the TUI program.
*
});
}
- Screen screen = new TerminalScreen(terminal);
+ screen = new TerminalScreen(terminal);
screen.startScreen();
// Create gui and start gui
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen,
- new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
- gui.addWindowAndWait(win);
+ TextColor.ANSI.BLUE);
+ gui.setTheme(UiColors.getCustomTheme());
+
+ gui.addWindowAndWait(win);
screen.stopScreen();
}
}
package be.nikiroo.jvcard.tui;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.MissingResourceException;
+import java.util.Properties;
import be.nikiroo.jvcard.resources.bundles.ColorBundle;
import be.nikiroo.jvcard.resources.enums.ColorOption;
import com.googlecode.lanterna.TextColor;
+import com.googlecode.lanterna.graphics.PropertiesTheme;
+import com.googlecode.lanterna.graphics.Theme;
+import com.googlecode.lanterna.gui2.AbstractTextGUI;
import com.googlecode.lanterna.gui2.Label;
/**
}
/**
- * Create a new {@link Label} with the colours of the given {@link ColorOption}.
+ * Create a new {@link Label} with the colours of the given
+ * {@link ColorOption}.
*
* @param el
* the {@link ColorOption}
return getInstance().colorMap.get(el.name() + "_FG");
}
+ /**
+ * Return a {@link Theme} following the colours defined in
+ * display.properties.
+ *
+ * @return the {@link Theme}
+ */
+ static Theme getCustomTheme() {
+ // Create a properties-theme with our own custom values for some of it
+ Properties properties = new Properties();
+ try {
+ ClassLoader classLoader = AbstractTextGUI.class.getClassLoader();
+ InputStream resourceAsStream = classLoader
+ .getResourceAsStream("default-theme.properties");
+ if (resourceAsStream == null) {
+ resourceAsStream = new FileInputStream(
+ "src/main/resources/default-theme.properties");
+ }
+ properties.load(resourceAsStream);
+ resourceAsStream.close();
+ } catch (IOException e) {
+ }
+ properties.put("com.googlecode.lanterna.background", "black");
+ PropertiesTheme theme = new PropertiesTheme(properties);
+
+ return theme;
+ }
+
/**
* Get the (unique) instance of this class.
*
import be.nikiroo.jvcard.tui.KeyAction;
import be.nikiroo.jvcard.tui.KeyAction.DataType;
import be.nikiroo.jvcard.tui.KeyAction.Mode;
+import be.nikiroo.jvcard.tui.TuiLauncher;
+import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
+import com.googlecode.lanterna.gui2.dialogs.ActionListDialogBuilder;
import com.googlecode.lanterna.input.KeyType;
public class ContactDetailsRaw extends MainContentList {
});
// TODO: ui
actions.add(new KeyAction(Mode.ASK_USER, 'a', StringId.KEY_ACTION_ADD) {
+ @Override
+ public boolean onAction() {
+ try{
+ new ActionListDialogBuilder()
+ .setTitle("Action List Dialog")
+ .setDescription("Choose an item")
+ .addAction("First Item", new Runnable() {
+ @Override
+ public void run() {
+ // Do 1st thing...
+ }
+ })
+ .addAction("Second Item", new Runnable() {
+ @Override
+ public void run() {
+ // Do 2nd thing...
+ }
+ })
+ .addAction("Third Item", new Runnable() {
+ @Override
+ public void run() {
+ // Do 3rd thing...
+ }
+ })
+ .build()
+ .showDialog(
+ new MultiWindowTextGUI(TuiLauncher.getScreen()));
+
+ return true;
+ }catch(Exception e){
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
@Override
public Object getObject() {
return contact;