public int getWidth() { return TerminalFactory.get().getWidth(); }
public int getTerminalWidth() { if (terminal != null) { return terminal.getWidth(); } Map<String, String> env = System.getenv(); String columnsFromEnv = env.get("COLUMNS"); if (columnsFromEnv != null) { return Integer.parseInt(columnsFromEnv); } return DEFAULT_WIDTH; }
private static void printUsage() { HelpFormatter hf = new HelpFormatter(); try { int width = hf.getWidth(); int jlineWidth = TerminalFactory.get().getWidth(); width = Math.min(160, Math.max(jlineWidth, width)); hf.setWidth(width); } catch (Throwable t) { // Ignore } hf.printHelp("llapstatus", OPTIONS); }
private void printUsage() { HelpFormatter hf = new HelpFormatter(); try { int width = hf.getWidth(); int jlineWidth = TerminalFactory.get().getWidth(); width = Math.min(160, Math.max(jlineWidth, width)); // Ignore potentially incorrect values hf.setWidth(width); } catch (Throwable t) { // Ignore } hf.printHelp("llap", options); } }
private static void printUsage() { HelpFormatter hf = new HelpFormatter(); try { int width = hf.getWidth(); int jlineWidth = TerminalFactory.get().getWidth(); width = Math.min(160, Math.max(jlineWidth, width)); hf.setWidth(width); } catch (Throwable t) { // Ignore } hf.printHelp("metatool", OPTIONS); }
/** * Prints the info about a command to the given print writer. * * @param command command to print info * @param pw where to print the info */ public static void printCommandInfo(Command command, PrintWriter pw) { String description = String.format("%s: %s", command.getCommandName(), command.getDescription()); int width = 80; try { width = TerminalFactory.get().getWidth(); } catch (Exception e) { // In case the terminal factory failed to decide terminal type, use default width } HELP_FORMATTER.printWrapped(pw, width, description); HELP_FORMATTER.printUsage(pw, width, command.getUsage()); if (command.getOptions().getOptions().size() > 0) { HELP_FORMATTER.printOptions(pw, width, command.getOptions(), HELP_FORMATTER.getLeftPadding(), HELP_FORMATTER.getDescPadding()); } }
public int getWidth() { return terminal.getWidth(); }
int nextTabStop(int pos) { int tabWidth = TAB_WIDTH; int width = getTerminal().getWidth(); int mod = (pos + tabWidth - 1) % tabWidth; int npos = pos + tabWidth - mod; return npos < width ? npos - pos : width - pos; }
private void printConfFooter(List<String> output) { int col3 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - COL2 - 6)); output.add(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%-" + col3 + "s", Shell.repeat("-", COL1), Shell.repeat("-", COL2), Shell.repeat("-", col3))); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws ShellCommandException, IOException { int numColumns = shellState.getReader().getTerminal().getWidth(); if (cl.hasOption(noWrapOpt.getOpt())) { numColumns = Integer.MAX_VALUE;
private final void printConstraintViolationException(ConstraintViolationException cve) { printException(cve, ""); int COL1 = 50, COL2 = 14; int col3 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - COL2 - 6)); logError(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%" + col3 + "s%n", repeat("-", COL1), repeat("-", COL2), repeat("-", col3))); logError(String.format("%-" + COL1 + "s | %" + COL2 + "s | %-" + col3 + "s%n", "Constraint class", "Violation code", "Violation Description")); logError(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%" + col3 + "s%n", repeat("-", COL1), repeat("-", COL2), repeat("-", col3))); for (TConstraintViolationSummary cvs : cve.violationSummaries) logError(String.format("%-" + COL1 + "s | %" + COL2 + "d | %-" + col3 + "s%n", cvs.constrainClass, cvs.violationCode, cvs.violationDescription)); logError(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%" + col3 + "s%n", repeat("-", COL1), repeat("-", COL2), repeat("-", col3))); }
int width = getTerminal().getWidth(); int height = getTerminal().getHeight();
ProgressThread(ProgressState progress, ProgressBarStyle style, long updateInterval, PrintStream consoleStream) { this.progress = progress; this.style = style; this.updateInterval = updateInterval; this.consoleStream = consoleStream; this.killed = false; this.terminal = TerminalFactory.get(); if (terminal.getWidth() >= 10) // Workaround for issue #23 under IntelliJ consoleWidth = terminal.getWidth(); }
ProgressThread(ProgressState progress, ProgressBarStyle style, long updateInterval, PrintStream consoleStream) { this.progress = progress; this.style = style; this.updateInterval = updateInterval; this.consoleStream = consoleStream; this.killed = false; this.terminal = TerminalFactory.get(); if (terminal.getWidth() >= 10) // Workaround for issue #23 under IntelliJ consoleWidth = terminal.getWidth(); }
/** * Returns the {@Terminal} width. * @param session * @return */ public static int getTermWidth(CommandSession session) { Terminal term = (Terminal) session.get(".jline.terminal"); return term != null ? term.getWidth() : 80; } }
private void moveCursorFromTo(int i0, int i1) throws IOException { if (i0 == i1) return; int width = getTerminal().getWidth(); int l0 = i0 / width; int c0 = i0 % width;
public static void printUsage() { HelpFormatter hf = new HelpFormatter(); try { int width = hf.getWidth(); int jlineWidth = TerminalFactory.get().getWidth(); width = Math.min(160, Math.max(jlineWidth, width)); // Ignore potentially incorrect values hf.setWidth(width); } catch (Throwable t) { // Ignore } LlapStatusOptionsProcessor optionsProcessor = new LlapStatusOptionsProcessor(); hf.printHelp(LLAPSTATUS_CONSTANT, optionsProcessor.options); }
public static String[] getRawAnsiSettings() throws IOException { ConsoleReader reader = new ConsoleReader(); return new String[] { "Width: " + reader.getTerminal().getWidth(), "Height: " + reader.getTerminal().getHeight(), "Ansi: " + reader.getTerminal().isAnsiSupported(), "Echo: " + reader.getTerminal().isEchoEnabled(), "Supported: " + reader.getTerminal().isSupported() }; }