本文整理汇总了Java中com.googlecode.lanterna.terminal.Terminal类的典型用法代码示例。如果您正苦于以下问题:Java Terminal类的具体用法?Java Terminal怎么用?Java Terminal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Terminal类属于com.googlecode.lanterna.terminal包,在下文中一共展示了Terminal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: useScrollHint
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
private void useScrollHint() throws IOException {
if (scrollHint == null) { return; }
try {
if (scrollHint == ScrollHint.INVALID) { return; }
Terminal term = getTerminal();
if (term instanceof Scrollable) {
// just try and see if it cares:
scrollHint.applyTo( (Scrollable)term );
// if that didn't throw, then update front buffer:
scrollHint.applyTo( getFrontBuffer() );
}
}
catch (UnsupportedOperationException uoe) { /* ignore */ }
finally { scrollHint = null; }
}
示例2: createTerminal
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
private Terminal createTerminal() throws IOException {
final OutputStream outputStream = System.out;
final InputStream inputStream = System.in;
final Charset charset = Charset.forName(
System.getProperty("file.encoding"));
if (GraphicsEnvironment.isHeadless()) {
if (isOperatingSystemWindows()) {
return new WinTerminal(inputStream, outputStream, charset);
}
return new UnixTerminal(inputStream, outputStream, charset);
}
SwingTerminalFrame swingTerminalFrame = new SwingTerminalFrame(
"charva-lanterna Demo",
TerminalEmulatorDeviceConfiguration.getDefault(),
SwingTerminalFontConfiguration.getDefault(),
TerminalEmulatorColorConfiguration.getDefault(),
TerminalEmulatorAutoCloseTrigger.CloseOnExitPrivateMode);
swingTerminalFrame.setDefaultCloseOperation(
WindowConstants.EXIT_ON_CLOSE);
swingTerminalFrame.setVisible(true);
return swingTerminalFrame;
}
示例3: main
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public static void main(String[] args) {
Terminal terminal = getTerminal();
Size size = getSize(terminal);
Size sizex5 = new Size(size.getWidth()*5, size.getHeight()*5);
List<Level> levels = LevelRegistry.getLevels();
Configuration.init(sizex5, levels);
GameFacadeFactory gameFacadeFactory = new ClippedGameFacadeFactory(size);
PresenterFactory presenterFactory = new PresenterFactory(gameFacadeFactory);
TerminalViewFactory viewFactory = new TerminalViewFactory(terminal);
ViewController controller = new ViewController(viewFactory, presenterFactory);
controller.run();
terminal.exitPrivateMode();
}
示例4: start
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
@Override
public void start(Environment environment) throws IOException {
//TODO Make with prototype bean
Terminal terminal = new LanternaSshTerminal(inputStream, outputStream, Charset.forName(System
.getProperty("file.encoding")), environment);
LanternaRunner runner = new LanternaRunner();
runner.setTerminal(terminal);
runner.setSession(session);
runner.setRootMenuList(getRootMenus());
runner.setWindowManagerService(windowManagerService);
runner.setDictionaryService(dictionaryService);
runner.setUidaoService(uidaoService);
runner.setWindowActionService(windowActionService);
taskExecutor.execute(runner);
}
示例5: putStringColor
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
/**
* Put a string on the terminal with a defined color.
* @param x x position of the string
* @param y y position of the string
* @param s the string to print
* @param color the foreground color of the string
* @return x position after printing the line
*/
private int putStringColor(final int x, final int y, final String s,
final Terminal.Color color) {
if (color != null) {
this.terminal.applyForegroundColor(color);
}
final int result = putString(x, y, s);
if (color != null) {
this.terminal.applyForegroundColor(Color.DEFAULT);
}
return result;
}
示例6: doAuthentication
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
/**
* Do authentication.
*
* @param info the info
* @param usernameTextBox the username text box
* @param passwordTextBox the password text box
*/
public void doAuthentication(Label info, TextBox usernameTextBox, TextBox passwordTextBox) {
AUTHENTICATION.login(usernameTextBox.getText(), passwordTextBox.getText());
// If Authentication is successful then show the CLI Interface
if (AUTHENTICATION.isLoggedIn()) {
getInstance().removeAllComponents();
getInstance().addComponent(CliGui.getInstance().drawGui());
}
// Otherwise show an error message
else {
final String message = "Wrong Username/Password combination!! Please try again";
GUI_HELPER.displayMessage(info, message, Terminal.Color.RED, Theme.Category.SHADOW);
}
}
示例7: main
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
Terminal t = new TestTerminalFactory(args).createTerminal();
t.enterPrivateMode();
TerminalScreen s = new TerminalScreen(t);
s.startScreen();
try {
Thread.sleep(1000);
}
catch(InterruptedException e) {}
s.stopScreen();
t.exitPrivateMode();
}
示例8: createTerminal
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public Terminal createTerminal() throws IOException {
Terminal terminal = factory.createTerminal();
if(terminal instanceof SwingTerminalFrame) {
((SwingTerminalFrame)terminal).setVisible(true);
((SwingTerminalFrame)terminal).setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
return terminal;
}
示例9: getTerminal
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
private static Terminal getTerminal() {
Terminal terminal = TerminalFacade.createTerminal(System.in,
System.out, Charset.forName("UTF8"));
terminal.enterPrivateMode();
terminal.clearScreen();
terminal.setCursorVisible(false);
return terminal;
}
示例10: getSize
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
private static Size getSize(Terminal terminal) {
TerminalSize terminalSize = terminal.getTerminalSize();
int width = terminalSize.getColumns();
int height = terminalSize.getRows();
Size size = new Size(width, height);
return size;
}
示例11: TerminalMazeView
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public TerminalMazeView(MazePresenter presenter, Terminal terminal) {
_terminal = terminal;
_presenter = presenter;
CellUpdateListener updater = new TerminalMazeViewUpdater(terminal);
_presenter.setCellUpdateListener(updater);
LivesUpdateListener livesUpdater = new TerminalLivesViewUpdater(terminal);
_presenter.setLivesUpdateListener(livesUpdater);
}
示例12: TerminalLevelView
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public TerminalLevelView(LevelPresenter presenter, Terminal terminal) {
_presenter = presenter;
_terminal = terminal;
LevelSelectionListener listener = new LevelViewUpdater(this);
_presenter.setLevelSelectionListener(listener);
_oldIndex = -1;
_selectedIndex = -1;
}
示例13: main
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
public static void main(String[] args) {
Terminal terminal = getTerminal();
Size size = getSize(terminal);
List<Level> levels = LevelRegistry.getLevels();
Configuration.init(size, levels);
TerminalViewFactory viewFactory = new TerminalViewFactory(terminal);
ViewController controller = new ViewController(viewFactory);
controller.run();
terminal.exitPrivateMode();
}
示例14: setUp
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
key = Mockito.mock(Key.class);
terminal = Mockito.mock(Terminal.class);
terminalSize = Mockito.mock(TerminalSize.class);
presenter = Mockito.mock(GameOverPresenter.class);
gameOver = Mockito.spy(new TerminalGameOverView(presenter, terminal));
Mockito.when(terminalSize.getRows()).thenReturn(100);
Mockito.when(terminalSize.getColumns()).thenReturn(100);
Mockito.when(terminal.getTerminalSize()).thenReturn(terminalSize);
}
示例15: setUp
import com.googlecode.lanterna.terminal.Terminal; //导入依赖的package包/类
@Before
public void setUp(){
terminal=Mockito.mock(Terminal.class);
presenter = Mockito.mock(HighScorePresenter.class);
key=Mockito.mock(Key.class);
when(terminal.getTerminalSize()).thenReturn(new TerminalSize(1000, 1000));
when(presenter.getHighScoreInfo()).thenReturn("");
when(terminal.readInput()).thenReturn(key);
}