Examples of FoldManager


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

    // we can position to.
    else {

      Element map = doc.getDefaultRootElement();
      int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
FoldManager fm = host.getFoldManager();
//System.out.print("--- " + lineIndex);
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
//System.out.println(" => " + lineIndex);
      if (lineIndex >= map.getElementCount()) {
        return host.getLastVisibleOffset();
      }
View Full Code Here

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

    if (metrics != null) {
      // 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;
      FoldManager fm = host.getFoldManager();
      if (!fm.isLineHidden(line)) {
        line -= fm.getHiddenLineCountAbove(line);
        return alloc.y + line*lineHeight;
      }
    }

    return -1;
View Full Code Here

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

    int topLine = (visibleRect.y-textAreaInsets.top)/cellHeight;
    int actualTopY = topLine*cellHeight + textAreaInsets.top;
    int y = actualTopY + ascent;

    // Get the actual first line to paint, taking into account folding.
    FoldManager fm = null;
    if (textArea instanceof RSyntaxTextArea) {
      fm = ((RSyntaxTextArea)textArea).getFoldManager();
      topLine += fm.getHiddenLineCountAbove(topLine, true);
    }
    final int RHS_BORDER_WIDTH = getRhsBorderWidth();

/*
    // Highlight the current line's line number, if desired.
    if (textArea.getHighlightCurrentLine() && currentLine>=topLine &&
        currentLine<=bottomLine) {
      g.setColor(textArea.getCurrentLineHighlightColor());
      g.fillRect(0,actualTopY+(currentLine-topLine)*cellHeight,
            cellWidth,cellHeight);
    }
*/

    // Paint line numbers
    g.setColor(getForeground());
    boolean ltr = getComponentOrientation().isLeftToRight();
    if (ltr) {
      FontMetrics metrics = g.getFontMetrics();
      int rhs = getWidth() - RHS_BORDER_WIDTH;
      int line = topLine + 1;
      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;
        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.FoldManager

    Element root = doc.getDefaultRootElement();
    int lineCount = root.getElementCount();
    int topPosition = textArea.viewToModel(
                new Point(visibleRect.x,visibleRect.y));
    int topLine = root.getElementIndex(topPosition);
    FoldManager fm = null;
    if (textArea instanceof RSyntaxTextArea) {
      fm = ((RSyntaxTextArea)textArea).getFoldManager();
    }

    // Compute the y at which to begin painting text, taking into account
    // that 1 logical line => at least 1 physical line, so it may be that
    // y<0.  The computed y-value is the y-value of the top of the first
    // (possibly) partially-visible view.
    Rectangle visibleEditorRect = ui.getVisibleEditorRect();
    Rectangle r = LineNumberList.getChildViewBounds(v, topLine,
                        visibleEditorRect);
    int y = r.y;
    final int RHS_BORDER_WIDTH = getRhsBorderWidth();
    int rhs;
    boolean ltr = getComponentOrientation().isLeftToRight();
    if (ltr) {
      rhs = width - RHS_BORDER_WIDTH;
    }
    else { // rtl
      rhs = RHS_BORDER_WIDTH;
    }
    int visibleBottom = visibleRect.y + visibleRect.height;
    FontMetrics metrics = g.getFontMetrics();

    // Keep painting lines until our y-coordinate is past the visible
    // end of the text area.
    g.setColor(getForeground());

    while (y < visibleBottom) {

      r = LineNumberList.getChildViewBounds(v, topLine, visibleEditorRect);

      /*
      // Highlight the current line's line number, if desired.
      if (currentLineHighlighted && topLine==currentLine) {
        g.setColor(textArea.getCurrentLineHighlightColor());
        g.fillRect(0,y, width,(r.y+r.height)-y);
        g.setColor(getForeground());
      }
      */

      // Paint the line number.
      int index = (topLine+1) + getLineNumberingStartIndex() - 1;
      String number = Integer.toString(index);
      if (ltr) {
        int strWidth = metrics.stringWidth(number);
        g.drawString(number, rhs-strWidth,y+ascent);
      }
      else {
        int x = RHS_BORDER_WIDTH;
        g.drawString(number, x, y+ascent);
      }

      // The next possible y-coordinate is just after the last line
      // painted.
      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++;
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

      int line = root.getElementIndex(offs);
      int start = root.getElement(line).getStartOffset();
      if (offs==start) {// If we're already at the start of the line...
        RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
        if (rsta.isCodeFoldingEnabled()) { // End of next visible line
          FoldManager fm = rsta.getFoldManager();
          while (--line>=0 && fm.isLineHidden(line));
          if (line>=0) { // Found an earlier visible line
            offs = root.getElement(line).getEndOffset() - 1;
          }
          // No earlier visible line - we must be at offs==0...
          return offs;
View Full Code Here

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

    if (rsta.isCodeFoldingEnabled()) { // Should always be true
      int offs = rsta.viewToModel(p); // TODO: Optimize me
      if (offs>-1) {
        try {
          int line = rsta.getLineOfOffset(offs);
          FoldManager fm = rsta.getFoldManager();
          fold = fm.getFoldForLine(line);
          if (fold==null) {
            fold = fm.getDeepestOpenFoldContaining(offs);
          }
        } catch (BadLocationException ble) {
          ble.printStackTrace(); // Never happens
        }
      }
View Full Code Here

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

    String text = null;

    RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
    if (rsta.isCodeFoldingEnabled()) {
      FoldManager fm = rsta.getFoldManager();
      int pos = rsta.viewToModel(new Point(0, e.getY()));
      if (pos>=0) { // Not -1
        int line = 0;
        try {
          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;
View Full Code Here

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

    int y = topLine*cellHeight +
      (cellHeight-collapsedFoldIcon.getIconHeight())/2;
    y += textAreaInsets.top;

    // Get the first and last lines to paint.
    FoldManager fm = rsta.getFoldManager();
    topLine += fm.getHiddenLineCountAbove(topLine, true);

    int width = getWidth();
    int x = width - 10;
    int line = topLine;
    boolean paintingOutlineLine = foldWithOutlineShowing!=null &&
        foldWithOutlineShowing.containsLine(line);

    while (y<visibleRect.y+visibleRect.height) {
      if (paintingOutlineLine) {
        g.setColor(getForeground());
        int w2 = width/2;
        if (line==foldWithOutlineShowing.getEndLine()) {
          int y2 = y+cellHeight/2;
          g.drawLine(w2,y, w2,y2);
          g.drawLine(w2,y2, width-2,y2);
          paintingOutlineLine = false;
        }
        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.FoldManager

    Element root = doc.getDefaultRootElement();
    int topPosition = textArea.viewToModel(
                new Point(visibleRect.x,visibleRect.y));
    int topLine = root.getElementIndex(topPosition);
    int cellHeight = textArea.getLineHeight();
    FoldManager fm = ((RSyntaxTextArea)textArea).getFoldManager();

    // Compute the y at which to begin painting text, taking into account
    // that 1 logical line => at least 1 physical line, so it may be that
    // y<0.  The computed y-value is the y-value of the top of the first
    // (possibly) partially-visible view.
    Rectangle visibleEditorRect = ui.getVisibleEditorRect();
    Rectangle r = LineNumberList.getChildViewBounds(v, topLine,
                        visibleEditorRect);
    int y = r.y;
    y += (cellHeight-collapsedFoldIcon.getIconHeight())/2;

    int visibleBottom = visibleRect.y + visibleRect.height;
    int x = width - 10;
    int line = topLine;
    boolean paintingOutlineLine = foldWithOutlineShowing!=null &&
        foldWithOutlineShowing.containsLine(line);
    int lineCount = root.getElementCount();

    while (y<visibleBottom && line<lineCount) {

      int curLineH = LineNumberList.getChildViewBounds(v, line,
          visibleEditorRect).height;

      if (paintingOutlineLine) {
        g.setColor(getForeground());
        int w2 = width/2;
        if (line==foldWithOutlineShowing.getEndLine()) {
          int y2 = y + curLineH - cellHeight/2;
          g.drawLine(w2,y, w2,y2);
          g.drawLine(w2,y2, width-2,y2);
          paintingOutlineLine = false;
        }
        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);
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.