org.jline.utils.InfoCmp Java Examples

The following examples show how to use org.jline.utils.InfoCmp. 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 File: QueryResultLogView.java    From samza with 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 File: CliClient.java    From flink with 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 File: CliClient.java    From flink with 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 File: QueryResultLogView.java    From samza with 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 File: CliClient.java    From Flink-CEPplus with 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
Source File: Console.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(String commandStrippedLine) throws IOException {
  puts(InfoCmp.Capability.clear_screen);
  flush();
}
 
Example #7
Source File: TestTerminal.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 4 votes vote down vote up
@Override
protected void puts(InfoCmp.Capability capability) {
  // Ignore
}
 
Example #8
Source File: JLineCommandHandler.java    From Launcher with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void bell() {
    terminal.puts(InfoCmp.Capability.bell);
    //reader.beep();
}
 
Example #9
Source File: JLineCommandHandler.java    From Launcher with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void clear() {
    terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example #10
Source File: SshShellTerminalDelegate.java    From ssh-shell-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public boolean puts(InfoCmp.Capability capability, Object... objects) {
    return delegate().puts(capability, objects);
}
 
Example #11
Source File: SshShellTerminalDelegate.java    From ssh-shell-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public boolean getBooleanCapability(InfoCmp.Capability capability) {
    return delegate().getBooleanCapability(capability);
}
 
Example #12
Source File: SshShellTerminalDelegate.java    From ssh-shell-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public Integer getNumericCapability(InfoCmp.Capability capability) {
    return delegate().getNumericCapability(capability);
}
 
Example #13
Source File: SshShellTerminalDelegate.java    From ssh-shell-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public String getStringCapability(InfoCmp.Capability capability) {
    return delegate().getStringCapability(capability);
}
 
Example #14
Source File: CliCommandHandler.java    From samza with Apache License 2.0 4 votes vote down vote up
private void clearScreen() {
  terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example #15
Source File: QueryResultLogView.java    From samza with 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 #16
Source File: QueryResultLogView.java    From samza with 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 #17
Source File: JLineTerminal.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 4 votes vote down vote up
@Override
public void puts(InfoCmp.Capability capability) {
  terminal.puts(capability);
}
 
Example #18
Source File: CliShell.java    From samza with Apache License 2.0 4 votes vote down vote up
private void clearScreen() {
  terminal.puts(InfoCmp.Capability.clear_screen);
}
 
Example #19
Source File: JLineEditor.java    From Recaf with 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
Source File: Console.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 votes vote down vote up
protected abstract void puts(InfoCmp.Capability capability);