Package org.fife.ui.rsyntaxtextarea.folding

Examples of org.fife.ui.rsyntaxtextarea.folding.FoldManager$Listener


      host = (RSyntaxTextArea)getContainer();
      if (host.isCodeFoldingEnabled()) {
        // TODO: Cache y-offsets again to speed this up
        //System.out.println("y-axis baby");
        int lineCount = host.getLineCount();
        FoldManager fm = host.getFoldManager();
        for (int i=0; i<lineCount; i++) {
          if (fm.isLineHidden(i)) {
            span -= getSpan(View.Y_AXIS, i);
          }
        }
      }
    }
View Full Code Here


  protected View getViewAtPoint(int x, int y, Rectangle alloc) {

    int lineCount = getViewCount();
    int curY = alloc.y + getOffset(Y_AXIS, 0); // Always at least 1 line
    host = (RSyntaxTextArea)getContainer();
    FoldManager fm = host.getFoldManager();

    for (int line=1; line<lineCount; line++) {
      int span = getSpan(Y_AXIS, line-1);
      if (y<curY+span) {
        childAllocation2(line-1, curY, alloc);
        return getView(line-1);
      }
      curY += span;
      Fold fold = fm.getFoldForLine(line-1);
      if (fold!=null && fold.isCollapsed()) {
        line += fold.getCollapsedLineCount();
      }
    }
View Full Code Here

    Graphics2D g2d = (Graphics2D)g;
    host = (RSyntaxTextArea)getContainer();
    int ascent = host.getMaxAscent();
    int fontHeight = host.getLineHeight();
    FoldManager fm = host.getFoldManager();
    TokenPainter painter = host.getTokenPainter();
    Element root = getElement();

    // Whether token styles should always be painted, even in selections
    int selStart = host.getSelectionStart();
    int selEnd = host.getSelectionEnd();
    boolean useSelectedTextColor = host.getUseSelectedTextColor();

    int n = getViewCount()// Number of lines.
    int x = alloc.x + getLeftInset();
    tempRect.y = alloc.y + getTopInset();
    Rectangle clip = g.getClipBounds();
    for (int i = 0; i < n; i++) {

      tempRect.x = x + getOffset(X_AXIS, i);
      //tempRect.y = y + getOffset(Y_AXIS, i);
      tempRect.width = getSpan(X_AXIS, i);
      tempRect.height = getSpan(Y_AXIS, i);
      //System.err.println("For line " + i + ": tempRect==" + tempRect);

      if (tempRect.intersects(clip)) {
        Element lineElement = root.getElement(i);
        int startOffset = lineElement.getStartOffset();
        int endOffset = lineElement.getEndOffset()-1; // Why always "-1"?
        View view = getView(i);
        if (!useSelectedTextColor || selStart==selEnd ||
            (startOffset>=selEnd || endOffset<selStart)) {
          drawView(painter, g2d, alloc, view, fontHeight,
              tempRect.y+ascent);
        }
        else {
          //System.out.println("Drawing line with selection: " + i);
          drawViewWithSelection(painter, g2d, alloc, view, fontHeight,
              tempRect.y+ascent, selStart, selEnd);
        }
      }

      tempRect.y += tempRect.height;

      Fold possibleFold = fm.getFoldForLine(i);
      if (possibleFold!=null && possibleFold.isCollapsed()) {
        i += possibleFold.getCollapsedLineCount();
        // Visible indicator of collapsed lines
        Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
        if (c!=null) {
View Full Code Here

      // to speed this back up!
      Rectangle r = (Rectangle)modelToView(offs, alloc, Bias.Forward);
      if (r!=null) {
        if (host.isCodeFoldingEnabled()) {
          int line = host.getLineOfOffset(offs);
          FoldManager fm = host.getFoldManager();
          if (fm.isLineHidden(line)) {
            return -1;
          }
        }
        return r.y;
      }
View Full Code Here

    @Override
    public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
      RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
      if (rsta.isCodeFoldingEnabled()) {
        FoldManager fm = rsta.getFoldManager();
        for (int i=0; i<fm.getFoldCount(); i++) {
          expand(fm.getFold(i));
        }
        possiblyRepaintGutter(rsta);
      }
      else {
        UIManager.getLookAndFeel().provideErrorFeedback(rsta);
View Full Code Here

    }

    protected Fold getClosestFold(RSyntaxTextArea textArea) {
      int offs = textArea.getCaretPosition();
      int line = textArea.getCaretLineNumber();
      FoldManager fm = textArea.getFoldManager();
      Fold fold = fm.getFoldForLine(line);
      if (fold==null) {
        fold = fm.getDeepestOpenFoldContaining(offs);
      }
      return fold;
    }
View Full Code Here

      int line = root.getElementIndex(offs);
      int end = root.getElement(line).getEndOffset() - 1;
      if (offs==end) {// If we're already at the end of the line...
        RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
        if (rsta.isCodeFoldingEnabled()) { // Start of next visible line
          FoldManager fm = rsta.getFoldManager();
          int lineCount = root.getElementCount();
          while (++line<lineCount && fm.isLineHidden(line));
          if (line<lineCount) { // Found a lower visible line
            offs = root.getElement(line).getStartOffset();
          }
          // No lower visible line - we're already at last visible offset
          return offs;
View Full Code Here

   */
  public Token getTokenListForPhysicalLineAbove(int offset) {
    RSyntaxDocument document = (RSyntaxDocument)getDocument();
    Element map = document.getDefaultRootElement();
int line = map.getElementIndex(offset);
FoldManager fm = host.getFoldManager();
if (fm==null) {
  line--;
  if (line>=0) {
    return document.getTokenListForLine(line);
  }
}
else {
  line = fm.getVisibleLineAbove(line);
  if (line>=0) {
    return document.getTokenListForLine(line);
  }
}
//    int line = map.getElementIndex(offset) - 1;
View Full Code Here

  if (line<lineCount-1) {
    return document.getTokenListForLine(line+1);
  }
}
else {
  FoldManager fm = host.getFoldManager();
  line = fm.getVisibleLineBelow(line);
  if (line>=0 && line<lineCount) {
    return document.getTokenListForLine(line);
  }
}
//    int line = map.getElementIndex(offset);
View Full Code Here

      // NOTE:  lineHeight is not initially set here, leading to the
      // current line not being highlighted when a document is first
      // opened.  So, we set it here just in case.
      lineHeight = host!=null ? host.getLineHeight() : lineHeight;
if (host.isCodeFoldingEnabled()) {
  FoldManager fm = host.getFoldManager();
  int hiddenCount = fm.getHiddenLineCountAbove(line);
  line -= hiddenCount;
}
      r = new Rectangle(alloc.x, alloc.y + line*lineHeight,
                  alloc.width, lineHeight);
    }
View Full Code Here

TOP

Related Classes of org.fife.ui.rsyntaxtextarea.folding.FoldManager$Listener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.