Package org.fife.ui.rsyntaxtextarea.folding

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


      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

        repaint();
      }
    }

    public void mouseMoved(MouseEvent e) {
      Fold newSelectedFold = findOpenFoldClosestTo(e.getPoint());
      if (newSelectedFold!=foldWithOutlineShowing &&
          newSelectedFold!=null && !newSelectedFold.isOnSingleLine()) {
        foldWithOutlineShowing = newSelectedFold;
        repaint();
      }
    }
View Full Code Here

      while (y<visibleRect.y+visibleRect.height+ascent && line<=textArea.getLineCount()) {
        String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
        int width = metrics.stringWidth(number);
        g.drawString(number, rhs-width,y);
        y += cellHeight;
        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;
        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

      // painted.
      y += r.height;

      // Update topLine (we're actually using it for our "current line"
      // variable now).
      Fold fold = fm.getFoldForLine(topLine);
      if (fold!=null && fold.isCollapsed()) {
        topLine += fold.getCollapsedLineCount();
      }
      topLine++;
      if (topLine>=lineCount)
        break;
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.setCollapsed(collapse);
        }
        possiblyRepaintGutter(textArea);
      }
      else {
        UIManager.getLookAndFeel().provideErrorFeedback(rsta);
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.setCollapsed(collapse);
        }
        possiblyRepaintGutter(textArea);
      }
      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

    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

        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

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.