Package org.fife.ui.rsyntaxtextarea.folding

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


      y += r.height;

      // Update topLine (we're actually using it for our "current line"
      // variable now).
      if (fm!=null) {
        Fold fold = fm.getFoldForLine(topLine);
        if (fold!=null && fold.isCollapsed()) {
          topLine += fold.getCollapsedLineCount();
        }
      }
      topLine++;
      if (topLine>=lineCount)
        break;
View Full Code Here


    @Override
    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;
          }

          StringBuilder sb = new StringBuilder("<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

        }
        else {
          g.drawLine(w2,y, w2,y+curLineH);
        }
      }
      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+curLineH);
          paintingOutlineLine = true;
        }
        if (fold.isCollapsed()) {
          collapsedFoldIcon.paintIcon(this, g, x, y);
          y += LineNumberList.getChildViewBounds(v, line,
                visibleEditorRect).height;
          line += fold.getLineCount() + 1;
        }
        else {
          expandedFoldIcon.paintIcon(this, g, x, y);
          y += curLineH;
          line++;
View Full Code Here

      int line = rowAtPoint(p);

      RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
      FoldManager fm = rsta.getFoldManager();

      Fold fold = fm.getFoldForLine(line);
      if (fold!=null) {
        fold.toggleCollapsedState();
        getGutter().repaint();
        textArea.repaint();
      }

    }
View Full Code Here

      }
    }

    @Override
    public void mouseMoved(MouseEvent e) {
      Fold newSelectedFold = findOpenFoldClosestTo(e.getPoint());
      if (newSelectedFold!=foldWithOutlineShowing &&
          newSelectedFold!=null && !newSelectedFold.isOnSingleLine()) {
        foldWithOutlineShowing = newSelectedFold;
        repaint();
      }
    }
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

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.