Package org.syntax.jedit.tokenmarker

Examples of org.syntax.jedit.tokenmarker.TokenMarker


   * @param offset
   *           The offset, from the start of the line
   */
  public int _offsetToX( int line, int offset )
  {
    TokenMarker tokenMarker = getTokenMarker();

    /* Use painter's cached info for speed */
    FontMetrics fm = painter.getFontMetrics();

    getLineText( line, lineSegment );

    int segmentOffset = lineSegment.offset;
    int x = 0; // -horizontalOffset;

    /* If syntax coloring is disabled, do simple translation */
    if( tokenMarker == null )
    {
      lineSegment.count = offset;
      return x + Utilities.getTabbedTextWidth( lineSegment, fm, x, painter, 0 );
    }
    /*
     * If syntax coloring is enabled, we have to do this because tokens can
     * vary in width
     */
    else
    {
      Token tokens;
      if( painter.currentLineIndex == line && painter.currentLineTokens != null )
        tokens = painter.currentLineTokens;
      else
      {
        painter.currentLineIndex = line;
        tokens = painter.currentLineTokens = tokenMarker.markTokens( lineSegment, line );
      }

      // Toolkit toolkit = painter.getToolkit();
      Font defaultFont = painter.getFont();
      SyntaxStyle[] styles = painter.getStyles();
View Full Code Here


   * @param x
   *           The x co-ordinate
   */
  public int xToOffset( int line, int x )
  {
    TokenMarker tokenMarker = getTokenMarker();

    /* Use painter's cached info for speed */
    FontMetrics fm = painter.getFontMetrics();

    getLineText( line, lineSegment );

    char[] segmentArray = lineSegment.array;
    int segmentOffset = lineSegment.offset;
    int segmentCount = lineSegment.count;

    int width = 0; // -horizontalOffset;

    if( tokenMarker == null )
    {
      for( int i = 0; i < segmentCount; i++ )
      {
        char c = segmentArray[i + segmentOffset];
        int charWidth;
        if( c == '\t' )
          charWidth = ( int )painter.nextTabStop( width, i ) - width;
        else
          charWidth = fm.charWidth( c );

        if( painter.isBlockCaretEnabled() )
        {
          if( x - charWidth <= width )
            return i;
        }
        else
        {
          if( x - charWidth / 2 <= width )
            return i;
        }

        width += charWidth;
      }

      return segmentCount;
    }
    else
    {
      Token tokens;
      if( painter.currentLineIndex == line && painter.currentLineTokens != null )
        tokens = painter.currentLineTokens;
      else
      {
        painter.currentLineIndex = line;
        tokens = painter.currentLineTokens = tokenMarker.markTokens( lineSegment, line );
      }

      int offset = 0;
      // Toolkit toolkit = painter.getToolkit();
      Font defaultFont = painter.getFont();
View Full Code Here

    // too many lines will always be painted.
    int lastInvalid = firstLine + ( clipRect.y + clipRect.height - 1 ) / height;

    try
    {
      TokenMarker tokenMarker = textArea.getDocument().getTokenMarker();
      int x = 0; // -textArea.getHorizontalOffset();

      for( int line = firstInvalid; line <= lastInvalid; line++ )
      {
        paintLine( gfx, tokenMarker, line, x );
      }

      if( tokenMarker != null && tokenMarker.isNextLineRequested() )
      {
        int h = clipRect.y + clipRect.height;
        repaint( 0, h, getWidth(), getHeight() - h );
      }
    }
View Full Code Here

        // of the font height, we subtract 1 from it, otherwise one
        // too many lines will always be painted.
        int lastInvalid = firstLine + (clipRect.y + clipRect.height - 1) / height;

        try {
            TokenMarker tokenMarker = textArea.getDocument().getTokenMarker();
            int x = 0; // -textArea.getHorizontalOffset();

            for (int line = firstInvalid; line <= lastInvalid; line++) {
                paintLine(gfx, tokenMarker, line, x);
            }

            if (tokenMarker != null && tokenMarker.isNextLineRequested()) {
                int h = clipRect.y + clipRect.height;
                repaint(0, h, getWidth(), getHeight() - h);
            }
        } catch (Exception e) {
            System.err.println("Error repainting line" + " range {" + firstInvalid + "," + lastInvalid + "}:");
View Full Code Here

     *
     * @param line   The line
     * @param offset The offset, from the start of the line
     */
    public int _offsetToX(int line, int offset) {
        TokenMarker tokenMarker = getTokenMarker();

    /* Use painter's cached info for speed */
        FontMetrics fm = painter.getFontMetrics();

        getLineText(line, lineSegment);

        int segmentOffset = lineSegment.offset;
        int x = 0; // -horizontalOffset;

    /* If syntax coloring is disabled, do simple translation */
        if (tokenMarker == null) {
            lineSegment.count = offset;
            return x + Utilities.getTabbedTextWidth(lineSegment, fm, x, painter, 0);
        }
    /*
     * If syntax coloring is enabled, we have to do this because tokens can
     * vary in width
     */
        else {
            Token tokens;
            if (painter.currentLineIndex == line && painter.currentLineTokens != null) {
                tokens = painter.currentLineTokens;
            } else {
                painter.currentLineIndex = line;
                tokens = painter.currentLineTokens = tokenMarker.markTokens(lineSegment, line);
            }

            // Toolkit toolkit = painter.getToolkit();
            Font defaultFont = painter.getFont();
            SyntaxStyle[] styles = painter.getStyles();
View Full Code Here

     *
     * @param line The line
     * @param x    The x co-ordinate
     */
    public int xToOffset(int line, int x) {
        TokenMarker tokenMarker = getTokenMarker();

    /* Use painter's cached info for speed */
        FontMetrics fm = painter.getFontMetrics();

        getLineText(line, lineSegment);

        char[] segmentArray = lineSegment.array;
        int segmentOffset = lineSegment.offset;
        int segmentCount = lineSegment.count;

        int width = 0; // -horizontalOffset;

        if (tokenMarker == null) {
            for (int i = 0; i < segmentCount; i++) {
                char c = segmentArray[i + segmentOffset];
                int charWidth;
                if (c == '\t') {
                    charWidth = (int) painter.nextTabStop(width, i) - width;
                } else {
                    charWidth = fm.charWidth(c);
                }

                if (painter.isBlockCaretEnabled()) {
                    if (x - charWidth <= width) {
                        return i;
                    }
                } else {
                    if (x - charWidth / 2 <= width) {
                        return i;
                    }
                }

                width += charWidth;
            }

            return segmentCount;
        } else {
            Token tokens;
            if (painter.currentLineIndex == line && painter.currentLineTokens != null) {
                tokens = painter.currentLineTokens;
            } else {
                painter.currentLineIndex = line;
                tokens = painter.currentLineTokens = tokenMarker.markTokens(lineSegment, line);
            }

            int offset = 0;
            // Toolkit toolkit = painter.getToolkit();
            Font defaultFont = painter.getFont();
View Full Code Here

TOP

Related Classes of org.syntax.jedit.tokenmarker.TokenMarker

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.