Examples of Fold


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

    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

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

    TokenPainter painter = host.getTokenPainter();
    int line = linesAbove;
    //int count = 0;
    while (y<clip.y+clip.height+ascent && 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);
      if (!useSelectedTextColor || selStart==selEnd ||
          (startOffset>=selEnd || endOffset<selStart)) {
        drawLine(painter, token, g2d, x,y);
      }
      else {
        //System.out.println("Drawing line with selection: " + line);
        drawLineWithSelection(painter,token,g2d, x,y, selStart, selEnd);
      }

      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,
              host.getWidth(),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

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

        String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
        int width = metrics.stringWidth(number);
        g.drawString(number, rhs-width,y);
        y += cellHeight;
        if (fm!=null) {
          Fold fold = fm.getFoldForLine(line-1);
          // Skip to next line to paint, taking extra care for lines with
          // block ends and begins together, e.g. "} else {"
          while (fold!=null && fold.isCollapsed()) {
            int hiddenLineCount = fold.getLineCount();
            if (hiddenLineCount==0) {
              // Fold parser identified a 0-line fold region... This
              // is really a bug, but we'll handle it gracefully.
              break;
            }
            line += hiddenLineCount;
            fold = fm.getFoldForLine(line-1);
          }
        }
        line++;
      }
    }
    else { // rtl
      int line = topLine + 1;
      while (y<visibleRect.y+visibleRect.height && line<textArea.getLineCount()) {
        String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
        g.drawString(number, RHS_BORDER_WIDTH, y);
        y += cellHeight;
        if (fm!=null) {
          Fold fold = fm.getFoldForLine(line-1);
          // Skip to next line to paint, taking extra care for lines with
          // block ends and begins together, e.g. "} else {"
          while (fold!=null && fold.isCollapsed()) {
            line += fold.getLineCount();
            fold = fm.getFoldForLine(line);
          }
        }
        line++;
      }
View Full Code Here

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

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

    @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

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

  }


  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

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

          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

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

        }
        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

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

        }
        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

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

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