public int getWidth() { return TerminalFactory.get().getWidth(); }
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); }
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("llapstatus", 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 static synchronized Terminal get() { return get(null); }
public Terminal getTerminal() { if (term == null) { term = TerminalFactory.get(); } return term; } //
public ConsoleReader(final @Nullable String appName, final InputStream in, final OutputStream out, final @Nullable Terminal term, final @Nullable String encoding) throws IOException { this.appName = appName != null ? appName : "JLine"; this.encoding = encoding != null ? encoding : Configuration.getEncoding(); Terminal terminal = term != null ? term : TerminalFactory.get(); this.terminal = terminal instanceof Terminal2 ? (Terminal2) terminal : new DefaultTerminal2(terminal); String outEncoding = terminal.getOutputEncoding() != null? terminal.getOutputEncoding() : this.encoding; this.out = new OutputStreamWriter(terminal.wrapOutIfNeeded(out), outEncoding); setInput( in ); this.inputrcUrl = getInputRc(); consoleKeys = new ConsoleKeys(this.appName, inputrcUrl); if (terminal instanceof UnixTerminal && TerminalLineSettings.DEFAULT_TTY.equals(((UnixTerminal) terminal).getSettings().getTtyDevice()) && Configuration.getBoolean("jline.sigcont", false)) { setupSigCont(); } }
@Override public Integer get() { try { return TerminalFactory.get().getWidth(); } catch (Exception e) { return DEFAULT_LINE_WIDTH; } } };
@Override public Integer get() { try { return TerminalFactory.get().getWidth(); } catch (Exception e) { return DEFAULT_LINE_WIDTH; } } };
/** * Returns a wrapped {@link Terminal}. * * @return * @throws Exception */ public static Terminal get() throws Exception { return get(TerminalFactory.get(), false); }
public int getWidth() { return TerminalFactory.get().getWidth(); }
/** * NOTE: Use this method only if isUnixTerminal is true. * Gets the width of the terminal * @return - width of terminal */ public int getTerminalWidth() { return TerminalFactory.get().getWidth(); }
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); } }
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(); }
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); }
@Inject public JLine2Console(History history) throws Exception { super(); TerminalFactory.configure(Type.AUTO); terminal = TerminalFactory.get(); terminal.init(); consoleReader = new ConsoleReader(System.in, System.out, terminal); consoleReader.setHistory(history); consoleReader.setHistoryEnabled(true); }
public void startREPL(IConstructor repl, IEvaluatorContext ctx) { try { lang = new TheREPL(vf, repl, ctx); // TODO: this used to get a repl from the IEvaluatorContext but that was wrong. Need to fix later. ISourceLocation history = repl.has("history") ? (ISourceLocation) repl.get("history") : null; new BaseREPL(lang, null, System.in, System.out, true, true, history , TerminalFactory.get(), null).run(); } catch (IOException | URISyntaxException e) { e.printStackTrace(ctx.getStdErr()); } }
@Override public void printProgress(PrintWriter sout, QueryStatus status) { int terminalWidth = TerminalFactory.get().getWidth(); int progressWidth = (min(terminalWidth, 100) - 75) + 17; // progress bar is 17-42 characters wide int progress = (int)(status.getProgress() * 100.0f); String responseTime = getResponseTimeReadable((float)((status.getFinishTime() - status.getSubmitTime()) / 1000.0)); String progressBar = formatProgressBar(progressWidth, progress); reprintProgressLine(sout, progressBar, progress, responseTime, status); }