private boolean fetchConfig(String name) { long currentTime = System.currentTimeMillis(); try { // tty properties are cached so we don't have to worry too much about getting term width/height if (config == null || currentTime - configLastFetched > 1000) { config = get("-a"); } } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Log.debug("Failed to query stty ", name, "\n", e); if (config == null) { return false; } } // always update the last fetched time and try to parse the output if (currentTime - configLastFetched > 1000) { configLastFetched = currentTime; } return true; }
private TerminalLineSettings(String ttyDevice, boolean unused) throws IOException, InterruptedException { checkNotNull(ttyDevice); this.sttyCommand = Configuration.getString(JLINE_STTY, DEFAULT_STTY); this.shCommand = Configuration.getString(JLINE_SH, DEFAULT_SH); this.ttyDevice = ttyDevice; this.useRedirect = SUPPORTS_REDIRECT && DEFAULT_TTY.equals(ttyDevice); this.initialConfig = get("-g").trim(); this.config = get("-a"); this.configLastFetched = System.currentTimeMillis(); Log.debug("Config: ", config); // sanity check if (config.length() == 0) { throw new IOException(MessageFormat.format("Unrecognized stty code: {0}", config)); } }
private TerminalLineSettings(String ttyDevice, boolean unused) throws IOException, InterruptedException { checkNotNull(ttyDevice); this.sttyCommand = Configuration.getString(JLINE_STTY, DEFAULT_STTY); this.shCommand = Configuration.getString(JLINE_SH, DEFAULT_SH); this.ttyDevice = ttyDevice; this.useRedirect = SUPPORTS_REDIRECT && DEFAULT_TTY.equals(ttyDevice); this.initialConfig = get("-g").trim(); this.config = get("-a"); this.configLastFetched = System.currentTimeMillis(); Log.debug("Config: ", config); // sanity check if (config.length() == 0) { throw new IOException(MessageFormat.format("Unrecognized stty code: {0}", config)); } }
private boolean fetchConfig(String name) { long currentTime = System.currentTimeMillis(); try { // tty properties are cached so we don't have to worry too much about getting term width/height if (config == null || currentTime - configLastFetched > 1000) { config = get("-a"); } } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Log.debug("Failed to query stty ", name, "\n", e); if (config == null) { return false; } } // always update the last fetched time and try to parse the output if (currentTime - configLastFetched > 1000) { configLastFetched = currentTime; } return true; }