Esempio n. 1
0
  @Override
  public void keyTyped(final KeyEvent e) {
    if (!hist.active()
        || control(e)
        || DELNEXT.is(e)
        || DELPREV.is(e)
        || ESCAPE.is(e)
        || CUT2.is(e)) return;

    final int caret = editor.pos();

    // remember if marked text is to be deleted
    final StringBuilder sb = new StringBuilder(1).append(e.getKeyChar());
    final boolean indent = TAB.is(e) && editor.indent(sb, e.isShiftDown());

    // delete marked text
    final boolean selected = editor.selected() && !indent;
    if (selected) editor.delete();

    final int move = ENTER.is(e) ? editor.enter(sb) : editor.add(sb, selected);

    // refresh history and adjust cursor position
    hist.store(editor.text(), caret, editor.pos());
    if (move != 0) editor.pos(Math.min(editor.size(), caret + move));

    // adjust text height
    scrollCode.invokeLater(true);
    e.consume();
  }
Esempio n. 2
0
  @Override
  public void keyPressed(final KeyEvent e) {
    if (gui.updating) return;
    if (ESCAPE.is(e)) gui.fullscreen(false);

    if (gui.context.data() == null) return;
    if (SPACE.is(e)) {
      gui.notify.mark(sc(e) ? 2 : e.isShiftDown() ? 1 : 0, null);
    } else if (ENTER.is(e)) {
      GUIMenuCmd.C_FILTER.execute(gui);
    } else if (GOBACK2.is(e)) {
      GUIMenuCmd.C_GOBACK.execute(gui);
    }
  }