Exemplo n.º 1
0
 void loadBufferSwitcher() {
   if (jEdit.getBooleanProperty("view.showBufferSwitcher")) {
     if (bufferSwitcher == null) {
       bufferSwitcher = new BufferSwitcher(this);
       add(BorderLayout.NORTH, bufferSwitcher);
       bufferSwitcher.updateBufferList();
       revalidate();
     }
   } else if (bufferSwitcher != null) {
     remove(bufferSwitcher);
     revalidate();
     bufferSwitcher = null;
   }
 }
Exemplo n.º 2
0
  @EBHandler
  public void handleBufferUpdate(BufferUpdate msg) {
    Buffer _buffer = msg.getBuffer();
    if (msg.getWhat() == BufferUpdate.CREATED) {
      if (bufferSwitcher != null) bufferSwitcher.updateBufferList();

      if (buffer.isClosed()) {

        recentBuffer = null;
      }
    } else if (msg.getWhat() == BufferUpdate.CLOSED) {
      if (bufferSwitcher != null) bufferSwitcher.updateBufferList();

      if (_buffer == buffer) {

        Buffer newBuffer = recentBuffer != null ? recentBuffer : _buffer.getPrev();

        if (newBuffer != null && !newBuffer.isClosed()) {
          setBuffer(newBuffer);
          recentBuffer = newBuffer.getPrev();
        }
      } else if (_buffer == recentBuffer) recentBuffer = null;

      Buffer closedBuffer = msg.getBuffer();
      if (closedBuffer.isUntitled()) {

        caretsForPath.remove(closedBuffer.getPath());
      }
    } else if (msg.getWhat() == BufferUpdate.LOAD_STARTED) {
      if (_buffer == buffer) {
        textArea.setCaretPosition(0);
        textArea.getPainter().repaint();
      }
    } else if (msg.getWhat() == BufferUpdate.LOADED) {
      if (_buffer == buffer) {
        textArea.repaint();
        if (bufferSwitcher != null) bufferSwitcher.updateBufferList();

        if (view.getEditPane() == this) {
          StatusBar status = view.getStatus();
          status.updateCaretStatus();
          status.updateBufferStatus();
          status.updateMiscStatus();
        }

        loadCaretInfo();
      }

    } else if (msg.getWhat() == BufferUpdate.DIRTY_CHANGED) {
      if (_buffer == buffer && bufferSwitcher != null) {
        if (buffer.isDirty()) bufferSwitcher.repaint();
        else bufferSwitcher.updateBufferList();
      }
    } else if (msg.getWhat() == BufferUpdate.MARKERS_CHANGED) {
      if (_buffer == buffer) textArea.getGutter().repaint();
    } else if (msg.getWhat() == BufferUpdate.PROPERTIES_CHANGED) {
      if (_buffer == buffer && buffer.isLoaded()) {
        textArea.propertiesChanged();
        if (view.getEditPane() == this) view.getStatus().updateBufferStatus();
      }
    } else if (msg.getWhat() == BufferUpdate.SAVED && _buffer == buffer) {
      textArea.propertiesChanged();
    }
  }