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 Project: samza   Author: apache   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   Author: ljygz   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   Author: flink-tpc-ds   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   Author: apache   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   Author: apache   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
Source Project: ksql-fork-with-deep-learning-function   Author: kaiwaehner   File: JLineTerminal.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void puts(InfoCmp.Capability capability) {
  terminal.puts(capability);
}
 
Example #7
Source Project: ksql-fork-with-deep-learning-function   Author: kaiwaehner   File: Console.java    License: 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 #8
Source Project: ksql-fork-with-deep-learning-function   Author: kaiwaehner   File: TestTerminal.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void puts(InfoCmp.Capability capability) {
  // Ignore
}
 
Example #9
Source Project: Launcher   Author: GravitLauncher   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   Author: GravitLauncher   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
Source Project: ssh-shell-spring-boot   Author: fonimus   File: SshShellTerminalDelegate.java    License: 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 #12
Source Project: ssh-shell-spring-boot   Author: fonimus   File: SshShellTerminalDelegate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean getBooleanCapability(InfoCmp.Capability capability) {
    return delegate().getBooleanCapability(capability);
}
 
Example #13
Source Project: ssh-shell-spring-boot   Author: fonimus   File: SshShellTerminalDelegate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Integer getNumericCapability(InfoCmp.Capability capability) {
    return delegate().getNumericCapability(capability);
}
 
Example #14
Source Project: ssh-shell-spring-boot   Author: fonimus   File: SshShellTerminalDelegate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String getStringCapability(InfoCmp.Capability capability) {
    return delegate().getStringCapability(capability);
}
 
Example #15
Source Project: samza   Author: apache   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   Author: apache   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   Author: apache   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   Author: apache   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   Author: Col-E   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
Source Project: ksql-fork-with-deep-learning-function   Author: kaiwaehner   File: Console.java    License: Apache License 2.0 votes vote down vote up
protected abstract void puts(InfoCmp.Capability capability);