1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 00:08:51 -05:00

Support for setting the Lanternal TextUI theme via -Dnet.filebot.cli.theme

This commit is contained in:
Reinhard Pointner 2019-02-25 10:11:30 +07:00
parent 2cf7982ed5
commit 08ba94d2f3

View File

@ -30,6 +30,7 @@ import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Panels;
import com.googlecode.lanterna.gui2.Separator;
import com.googlecode.lanterna.gui2.TextGUI;
import com.googlecode.lanterna.gui2.Window.Hint;
import com.googlecode.lanterna.gui2.dialogs.ListSelectDialogBuilder;
import com.googlecode.lanterna.screen.Screen;
@ -40,11 +41,13 @@ import com.googlecode.lanterna.terminal.swing.TerminalEmulatorAutoCloseTrigger;
import net.filebot.RenameAction;
import net.filebot.similarity.Match;
import net.filebot.util.SystemProperty;
import net.filebot.web.SearchResult;
public class CmdlineOperationsTextUI extends CmdlineOperations {
public static final String DEFAULT_THEME = "businessmachine";
// use green matrix-style theme by default
private final Theme theme = SystemProperty.of("net.filebot.cli.theme", Theme::forName, Theme.BusinessMachine).get();
private Terminal terminal;
private Screen screen;
@ -55,8 +58,7 @@ public class CmdlineOperationsTextUI extends CmdlineOperations {
screen = new TerminalScreen(terminal);
ui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.DEFAULT));
// use green matrix-style theme
ui.setTheme(LanternaThemes.getRegisteredTheme(DEFAULT_THEME));
theme.setTheme(ui);
}
public synchronized <T> T onScreen(Supplier<T> dialog) throws Exception {
@ -186,4 +188,22 @@ public class CmdlineOperationsTextUI extends CmdlineOperations {
}
public enum Theme {
Default, BigSnake, Blaster, BusinessMachine, Conqueror, Defrost;
public void setTheme(TextGUI ui) {
ui.setTheme(LanternaThemes.getRegisteredTheme(name().toLowerCase()));
}
public static Theme forName(String name) {
for (Theme t : values()) {
if (t.name().equalsIgnoreCase(name)) {
return t;
}
}
throw new IllegalArgumentException(String.format("%s not in %s", name, asList(values())));
}
}
}