Esempio n. 1
0
  /** Returns the oldest build in the record. */
  @Exported
  @QuickSilver
  public RunT getFirstBuild() {
    SortedMap<Integer, ? extends RunT> runs = _getRuns();

    if (runs.isEmpty()) return null;
    return runs.get(runs.lastKey());
  }
Esempio n. 2
0
 // initialize encodings
 static {
   final SortedMap<String, Charset> cs = Charset.availableCharsets();
   ENCODINGS = cs.keySet().toArray(new String[cs.size()]);
 }
  /**
   * Create a new reader.
   *
   * @param in the input
   * @param out the output
   * @param bindings the key bindings to use
   * @param term the terminal to use
   */
  public ConsoleReader(InputStream in, Writer out, InputStream bindings, Terminal term)
      throws IOException {
    this.terminal = term;
    setInput(in);
    this.out = out;

    if (bindings == null) {
      try {
        String bindingFile =
            System.getProperty(
                "jline.keybindings",
                new File(System.getProperty("user.home", ".jlinebindings.properties"))
                    .getAbsolutePath());

        if (new File(bindingFile).isFile()) {
          bindings = new FileInputStream(new File(bindingFile));
        }
      } catch (Exception e) {
        // swallow exceptions with option debugging
        if (debugger != null) {
          e.printStackTrace(debugger);
        }
      }
    }

    if (bindings == null) {
      bindings = terminal.getDefaultBindings();
    }

    this.keybindings = new short[Character.MAX_VALUE * 2];

    Arrays.fill(this.keybindings, UNKNOWN);

    /**
     * Loads the key bindings. Bindings file is in the format:
     *
     * <p>keycode: operation name
     */
    if (bindings != null) {
      Properties p = new Properties();
      p.load(bindings);
      bindings.close();

      for (Iterator i = p.keySet().iterator(); i.hasNext(); ) {
        String val = (String) i.next();

        try {
          Short code = new Short(val);
          String op = (String) p.getProperty(val);

          Short opval = (Short) KEYMAP_NAMES.get(op);

          if (opval != null) {
            keybindings[code.shortValue()] = opval.shortValue();
          }
        } catch (NumberFormatException nfe) {
          consumeException(nfe);
        }
      }

      // hardwired arrow key bindings
      // keybindings[VK_UP] = PREV_HISTORY;
      // keybindings[VK_DOWN] = NEXT_HISTORY;
      // keybindings[VK_LEFT] = PREV_CHAR;
      // keybindings[VK_RIGHT] = NEXT_CHAR;
    }
  }
Esempio n. 4
0
 /**
  * Gets the latest build #m that satisfies <tt>m&lt;=n</tt>.
  *
  * <p>This is useful when you'd like to fetch a build but the exact build might be already gone
  * (deleted, rotated, etc.)
  */
 public final RunT getNearestOldBuild(int n) {
   SortedMap<Integer, ? extends RunT> m = _getRuns().tailMap(n);
   if (m.isEmpty()) return null;
   return m.get(m.firstKey());
 }
Esempio n. 5
0
 /**
  * Gets the youngest build #m that satisfies <tt>n&lt;=m</tt>.
  *
  * <p>This is useful when you'd like to fetch a build but the exact build might be already gone
  * (deleted, rotated, etc.)
  */
 public final RunT getNearestBuild(int n) {
   SortedMap<Integer, ? extends RunT> m = _getRuns().headMap(n - 1); // the map should
   // include n, so n-1
   if (m.isEmpty()) return null;
   return m.get(m.lastKey());
 }