Examples of FoldManager


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

   */
  public Shape getChildAllocationImpl(int line, Shape a) {

    Rectangle alloc = getInsideAllocation(a);
    host = (RSyntaxTextArea)getContainer();
    FoldManager fm = host.getFoldManager();
    int y = alloc.y;

    // TODO: Make cached getOffset() calls for Y_AXIS valid even for
    // folding, to speed this up!
    for (int i=0; i<line; i++) {
      y += getSpan(Y_AXIS, i);
      Fold fold = fm.getFoldForLine(i);
      if (fold!=null && fold.isCollapsed()) {
        i += fold.getCollapsedLineCount();
      }
    }

View Full Code Here

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

      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

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

  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

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

    Graphics2D g2d = (Graphics2D)g;
    host = (RSyntaxTextArea)getContainer();
    int ascent = host.getMaxAscent();
    int fontHeight = host.getLineHeight();
    FoldManager fm = host.getFoldManager();

    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)) {
        View view = getView(i);
        drawView(g2d, alloc, view, fontHeight, tempRect.y+ascent);
      }
      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

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

      // 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

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

    lastBracketMatchPos = -1;
    setSelectionColor(getDefaultSelectionColor());
    setTabLineColor(null);
    setMarkOccurrencesColor(MarkOccurrencesSupport.DEFAULT_COLOR);

    foldManager = new FoldManager(this);

    // Set auto-indent related stuff.
    setAutoIndentEnabled(true);
    setCloseCurlyBraces(true);
    setCloseMarkupTags(true);
View Full Code Here

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

   */
  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

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

  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

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

      // 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

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

    lineHeight = host.getLineHeight();
    ascent = host.getMaxAscent();//metrics.getAscent();
    int heightAbove = clip.y - alloc.y;
    int linesAbove = Math.max(0, heightAbove / lineHeight);

    FoldManager fm = host.getFoldManager();
    linesAbove += fm.getHiddenLineCountAbove(linesAbove, true);
    Rectangle lineArea = lineToRect(a, linesAbove);
    int y = lineArea.y + ascent;
    int x = lineArea.x;
    Element map = getElement();
    int lineCount = map.getElementCount();

    RSyntaxTextAreaHighlighter h =
          (RSyntaxTextAreaHighlighter)host.getHighlighter();

    Graphics2D g2d = (Graphics2D)g;
    Token token;
    //System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1));


    int line = linesAbove;
//int count = 0;
    while (y<clip.y+clip.height+lineHeight && line<lineCount) {

      Fold fold = fm.getFoldForLine(line);
      Element lineElement = map.getElement(line);
      int startOffset = lineElement.getStartOffset();
      //int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 :
      //              lineElement.getEndOffset()-1);
      int endOffset = lineElement.getEndOffset()-1; // Why always "-1"?
      h.paintLayeredHighlights(g2d, startOffset, endOffset,
                a, host, this);
 
      // Paint a line of text.
      token = document.getTokenListForLine(line);
      drawLine(token, g2d, x,y);

      if (fold!=null && fold.isCollapsed()) {

        // Visible indicator of collapsed lines
        Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
        if (c!=null) {
          g.setColor(c);
          g.drawLine(x,y+lineHeight-ascent-1,
              alloc.width,y+lineHeight-ascent-1);
        }

        // Skip to next line to paint, taking extra care for lines with
        // block ends and begins together, e.g. "} else {"
        do {
          int hiddenLineCount = fold.getLineCount();
          if (hiddenLineCount==0) {
            // Fold parser identified a zero-line fold region.
            // This is really a bug, but we'll be graceful here
            // and avoid an infinite loop.
            break;
          }
          line += hiddenLineCount;
          fold = fm.getFoldForLine(line);
        } while (fold!=null && fold.isCollapsed());

      }

      y += lineHeight;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.