Package org.fife.ui.rsyntaxtextarea.folding

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


        return folds;
    }

    private void getFolds(List<Fold> folds, RSyntaxTextArea area, Node node, Fold parent) {
        try {
            Fold passItOn = parent;
            int line = node.getPosition().getLine();
            if (line == -1)
                return; // nilnode...
            int offs = area.getLineStartOffset(line);

            // update parents end position...
            if (parent != null) {
                int pend = parent.getEndOffset();
                if (pend == Integer.MAX_VALUE || offs >= pend)
                    parent.setEndOffset(offs);
            }

            // Create new if needed...
            if (isFoldable(node)) {
                if (parent == null) {
                    passItOn = new Fold(FoldType.CODE, area, offs);
                    folds.add(passItOn);
                } else
                    passItOn = parent.createChild(FoldType.CODE, offs);
            }
View Full Code Here


    // 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();
      }
    }

    childAllocation2(line, y, alloc);
    return alloc;
View Full Code Here

      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();
      }
    }

    // Not found - return last line's view.
    childAllocation2(lineCount - 1, curY, alloc);
View Full Code Here

      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) {
          g.setColor(c);
          g.drawLine(x,tempRect.y-1, alloc.width,tempRect.y-1);
View Full Code Here

    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;
      line++;
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

    }

    public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
      RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
      if (rsta.isCodeFoldingEnabled()) {
        Fold fold = getClosestFold(rsta);
        if (fold!=null) {
          fold.toggleCollapsedState();
        }
        possiblyRepaintGutter(textArea);
      }
      else {
        UIManager.getLookAndFeel().provideErrorFeedback(rsta);
View Full Code Here

  }


  private Fold findOpenFoldClosestTo(Point p) {

    Fold fold = null;

    RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
    if (rsta.isCodeFoldingEnabled()) { // Should always be true
      int offs = rsta.viewToModel(p); // TODO: Optimize me
      if (offs>-1) {
View Full Code Here

          line = rsta.getLineOfOffset(pos);
        } catch (BadLocationException ble) {
          ble.printStackTrace(); // Never happens
          return null;
        }
        Fold fold = fm.getFoldForLine(line);
        if (fold!=null && fold.isCollapsed()) {

          int endLine = fold.getEndLine();
          if (fold.getLineCount()>25) { // Not too big
            endLine = fold.getStartLine() + 25;
          }

          StringBuffer sb = new StringBuffer("<html><nobr>");
          while (line<=endLine && line<rsta.getLineCount()) { // Sanity
            Token t = rsta.getTokenListForLine(line);
View Full Code Here

        }
        else {
          g.drawLine(w2,y, w2,y+cellHeight);
        }
      }
      Fold fold = fm.getFoldForLine(line);
      if (fold!=null) {
        if (fold==foldWithOutlineShowing && !fold.isCollapsed()) {
          g.setColor(getForeground());
          int w2 = width/2;
          g.drawLine(w2,y+cellHeight/2, w2,y+cellHeight);
          paintingOutlineLine = true;
        }
        if (fold.isCollapsed()) {
          collapsedFoldIcon.paintIcon(this, g, x, y);
          // 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());
        }
        else {
          expandedFoldIcon.paintIcon(this, g, x, y);
        }
      }
View Full Code Here

TOP

Related Classes of org.fife.ui.rsyntaxtextarea.folding.Fold

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.