Java Code Examples for org.jline.utils.InfoCmp

The following examples show how to use org.jline.utils.InfoCmp. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: samza   Source File: QueryResultLogView.java    License: Apache License 2.0 6 votes vote down vote up
private void drawStatusBar(int rowsInBuffer) {
  terminal.puts(InfoCmp.Capability.save_cursor);
  terminal.puts(InfoCmp.Capability.cursor_address, height - 1, 0);
  AttributedStyle statusBarStyle = AttributedStyle.DEFAULT.background(AttributedStyle.WHITE)
          .foreground(AttributedStyle.BLACK);
  AttributedStringBuilder attrBuilder = new AttributedStringBuilder()
          .style(statusBarStyle.bold().italic())
          .append("Q")
          .style(statusBarStyle)
          .append(": Quit     ")
          .style(statusBarStyle.bold().italic())
          .append("SPACE")
          .style(statusBarStyle)
          .append(": Pause/Resume     ")
          .append(String.valueOf(rowsInBuffer) + " rows in buffer     ");
  if (paused) {
    attrBuilder.style(statusBarStyle.bold().foreground(AttributedStyle.RED).blink())
            .append("PAUSED");
  }
  String statusBarText = attrBuilder.toAnsi();
  terminal.writer().print(statusBarText);
  terminal.flush();
  terminal.puts(InfoCmp.Capability.restore_cursor);
}
 
Example 2
Source Project: Flink-CEPplus   Source File: CliClient.java    License: Apache License 2.0 5 votes vote down vote up
public void clearTerminal() {
	if (isPlainTerminal()) {
		for (int i = 0; i < 200; i++) { // large number of empty lines
			terminal.writer().println();
		}
	} else {
		terminal.puts(InfoCmp.Capability.clear_screen);
	}
}
 
Example 3
Source Project: flink   Source File: CliClient.java    License: Apache License 2.0 5 votes vote down vote up
public void clearTerminal() {
	if (isPlainTerminal()) {
		for (int i = 0; i < 200; i++) { // large number of empty lines
			terminal.writer().println();
		}
	} else {
		terminal.puts(InfoCmp.Capability.clear_screen);
	}
}
 
Example 4
Source Project: samza   Source File: QueryResultLogView.java    License: Apache License 2.0 5 votes vote down vote up
private void restoreTerminal(TerminalStatus status) {
  // Signal handlers
  terminal.handle(Terminal.Signal.INT, status.handlerInt);
  terminal.handle(Terminal.Signal.QUIT, status.handlerQuit);
  terminal.handle(Terminal.Signal.TSTP, status.handlerTstp);
  terminal.handle(Terminal.Signal.CONT, status.handlerCont);
  terminal.handle(Terminal.Signal.WINCH, status.handlerWinch);

  // Attributes
  terminal.setAttributes(status.attributes);

  // Capability
  terminal.puts(InfoCmp.Capability.exit_ca_mode);
  terminal.puts(InfoCmp.Capability.cursor_visible);
}
 
Example 5
Source Project: flink   Source File: CliClient.java    License: Apache License 2.0 5 votes vote down vote up
public void clearTerminal() {
	if (isPlainTerminal()) {
		for (int i = 0; i < 200; i++) { // large number of empty lines
			terminal.writer().println();
		}
	} else {
		terminal.puts(InfoCmp.Capability.clear_screen);
	}
}
 
Example 6
@Override
public void puts(InfoCmp.Capability capability) {
  terminal.puts(capability);
}
 
Example 7
@Override
public void execute(String commandStrippedLine) throws IOException {
  puts(InfoCmp.Capability.clear_screen);
  flush();
}
 
Example 8
@Override
protected void puts(InfoCmp.Capability capability) {
  // Ignore
}
 
Example 9
Source Project: Launcher   Source File: JLineCommandHandler.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void bell() {
    terminal.puts(InfoCmp.Capability.bell);
    //reader.beep();
}
 
Example 10
Source Project: Launcher   Source File: JLineCommandHandler.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public void clear() {
    terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example 11
@Override
public boolean puts(InfoCmp.Capability capability, Object... objects) {
    return delegate().puts(capability, objects);
}
 
Example 12
@Override
public boolean getBooleanCapability(InfoCmp.Capability capability) {
    return delegate().getBooleanCapability(capability);
}
 
Example 13
@Override
public Integer getNumericCapability(InfoCmp.Capability capability) {
    return delegate().getNumericCapability(capability);
}
 
Example 14
@Override
public String getStringCapability(InfoCmp.Capability capability) {
    return delegate().getStringCapability(capability);
}
 
Example 15
Source Project: samza   Source File: CliCommandHandler.java    License: Apache License 2.0 4 votes vote down vote up
private void clearScreen() {
  terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example 16
Source Project: samza   Source File: QueryResultLogView.java    License: Apache License 2.0 4 votes vote down vote up
private void clearStatusBar() {
  terminal.puts(InfoCmp.Capability.save_cursor);
  terminal.puts(InfoCmp.Capability.cursor_address, height - 1, 0);
  terminal.puts(InfoCmp.Capability.delete_line, height - 1, 0);
  terminal.puts(InfoCmp.Capability.restore_cursor);
}
 
Example 17
Source Project: samza   Source File: QueryResultLogView.java    License: Apache License 2.0 4 votes vote down vote up
private TerminalStatus setupTerminal() {
  TerminalStatus prevStatus = new TerminalStatus();

  // Signal handlers
  prevStatus.handlerInt = terminal.handle(Terminal.Signal.INT, this::handleSignal);
  prevStatus.handlerQuit = terminal.handle(Terminal.Signal.QUIT, this::handleSignal);
  prevStatus.handlerTstp = terminal.handle(Terminal.Signal.TSTP, this::handleSignal);
  prevStatus.handlerCont = terminal.handle(Terminal.Signal.CONT, this::handleSignal);
  prevStatus.handlerWinch = terminal.handle(Terminal.Signal.WINCH, this::handleSignal);

  // Attributes
  prevStatus.attributes = terminal.getAttributes();
  Attributes newAttributes = new Attributes(prevStatus.attributes);
  // (003, ETX, Ctrl-C, or also 0177, DEL, rubout) Interrupt char‐
  // acter (INTR).  Send a SIGINT signal.  Recognized when ISIG is
  // set, and then not passed as input.
  newAttributes.setControlChar(Attributes.ControlChar.VINTR, 0);
  // (034, FS, Ctrl-\) Quit character (QUIT).  Send SIGQUIT signal.
  // Recognized when ISIG is set, and then not passed as input.
  // newAttributes.setControlChar(Attributes.ControlChar.VQUIT, 0);
  newAttributes.setControlChar(Attributes.ControlChar.VMIN, 1);
  newAttributes.setControlChar(Attributes.ControlChar.VTIME, 0);
  // Enables signals and SIGTTOU signal to the process group of a background
  // process which tries to write to our terminal
  newAttributes.setLocalFlags(
          EnumSet.of(Attributes.LocalFlag.ISIG, Attributes.LocalFlag.TOSTOP), true);
  // No canonical mode, no echo, and no implementation-defined input processing
  newAttributes.setLocalFlags(EnumSet.of(
          Attributes.LocalFlag.ICANON, Attributes.LocalFlag.ECHO,
          Attributes.LocalFlag.IEXTEN), false);
  // Input flags
  newAttributes.setInputFlags(EnumSet.of(
          Attributes.InputFlag.ICRNL, Attributes.InputFlag.INLCR, Attributes.InputFlag.IXON), false);
  terminal.setAttributes(newAttributes);

  // Capabilities
  // tput smcup; use alternate screen
  terminal.puts(InfoCmp.Capability.enter_ca_mode);
  terminal.puts(InfoCmp.Capability.cursor_invisible);
  terminal.puts(InfoCmp.Capability.cursor_home);

  terminal.flush();

  return prevStatus;
}
 
Example 18
Source Project: samza   Source File: CliShell.java    License: Apache License 2.0 4 votes vote down vote up
private void clearScreen() {
  terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example 19
Source Project: Recaf   Source File: JLineEditor.java    License: MIT License 3 votes vote down vote up
/**
 * Open an editor with the given title / file to load from. Blocks until the editor is closed.
 *
 * @param title
 * 		Editor title.
 * @param file
 * 		File containing content to read/write to.
 *
 * @throws IOException
 * 		Thrown if the file cannot be opened.
 */
private void openEditor(String title, File file) throws IOException {
	Nano nano = new Nano(terminal, file);
	nano.title = title;
	nano.open(file.getAbsolutePath());
	nano.run();
	terminal.puts(InfoCmp.Capability.clear_screen);
	terminal.flush();
}
 
Example 20
protected abstract void puts(InfoCmp.Capability capability);