当前位置: 首页>>代码示例>>Java>>正文


Java Utilities.getRowIndent方法代码示例

本文整理汇总了Java中org.netbeans.editor.Utilities.getRowIndent方法的典型用法代码示例。如果您正苦于以下问题:Java Utilities.getRowIndent方法的具体用法?Java Utilities.getRowIndent怎么用?Java Utilities.getRowIndent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.editor.Utilities的用法示例。


在下文中一共展示了Utilities.getRowIndent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInitialIndentFromPreviousLine

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
protected int getInitialIndentFromPreviousLine(final BaseDocument doc, final int line) throws BadLocationException {

        // get initial indent from the previous line
        int initialIndent = 0;

        if (line > 0) {
            int lineStart = Utilities.getRowStartFromLineOffset(doc, line);
            int previousNonWhiteLineEnd = Utilities.getFirstNonWhiteBwd(doc, lineStart);

            if (previousNonWhiteLineEnd > 0) {
                initialIndent = Utilities.getRowIndent(doc, previousNonWhiteLineEnd);
            }
        }

        return initialIndent;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TagBasedLexerFormatter.java

示例2: getIndentForTagParameter

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
protected int getIndentForTagParameter(BaseDocument doc, TokenItem tag) throws BadLocationException{
    int tagStartLine = Utilities.getLineOffset(doc, tag.getOffset());
    TokenItem currentToken = tag.getNext();
    
    /*
     * Find the offset of the first attribute if it is specified on the same line as the opening of the tag
     * e.g. <tag   |attr=
     * 
     */
    while (currentToken != null && isWSTag(currentToken) && tagStartLine == Utilities.getLineOffset(doc, currentToken.getOffset())){
        currentToken = currentToken.getNext();
    }
    
    if (tag != null && !isWSTag(currentToken) && tagStartLine == Utilities.getLineOffset(doc, currentToken.getOffset())){
        return currentToken.getOffset() - Utilities.getRowIndent(doc, currentToken.getOffset()) - Utilities.getRowStart(doc, currentToken.getOffset());
    }
    
    return getShiftWidth(); // default;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TagBasedFormatter.java

示例3: getInitialIndentFromPreviousLine

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
protected int getInitialIndentFromPreviousLine(final BaseDocument doc, final int line) throws BadLocationException {
    
    // get initial indent from the previous line
    int initialIndent = 0;
    
    if (line > 0){
        int lineStart = Utilities.getRowStartFromLineOffset(doc, line);
        int previousNonWhiteLineEnd = Utilities.getFirstNonWhiteBwd(doc, lineStart);
        
        if (previousNonWhiteLineEnd > 0){
            initialIndent = Utilities.getRowIndent(doc, previousNonWhiteLineEnd);
        }
    }
    
    return initialIndent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TagBasedFormatter.java

示例4: getIndentForTagParameter

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
protected int getIndentForTagParameter(BaseDocument doc, JoinedTokenSequence tokenSequence, int tagOffset) throws BadLocationException {
    int originalOffset = tokenSequence.offset();
    int tagStartLine = Utilities.getLineOffset(doc, tagOffset);
    tokenSequence.move(tagOffset);
    Token<?> token;
    int tokenOffset;
    boolean thereWasWS = false;
    int shift = doc.getShiftWidth(); // default;

    /*
     * Find the offset of the first attribute if it is specified on the same line as the opening of the tag
     * e.g. <tag   |attr=
     *
     */
    while (tokenSequence.moveNext()) {
        token = tokenSequence.token();
        tokenOffset = tokenSequence.offset();
        boolean isWSToken = isWSToken(token);
        
        if (thereWasWS && (!isWSToken || tagStartLine != Utilities.getLineOffset(doc, tokenOffset))) {
            if (!isWSToken && tagStartLine == Utilities.getLineOffset(doc, tokenOffset)) {
                
                shift = tokenOffset - Utilities.getRowIndent(doc, tokenOffset)
                        - Utilities.getRowStart(doc, tokenOffset);
            }
            break;
        } else if (isWSToken){
            thereWasWS = true;
        }
    }

    tokenSequence.move(originalOffset);
    tokenSequence.moveNext();

    return shift;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:TagBasedLexerFormatter.java

示例5: getInitialIndentFromNextLine

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
private int getInitialIndentFromNextLine(final BaseDocument doc, final int line) throws BadLocationException {
    
    // get initial indent from the next line
    int initialIndent = 0;
    
    int lineStart = Utilities.getRowStartFromLineOffset(doc, line);
    int lineEnd = Utilities.getRowEnd(doc, lineStart);
    int nextNonWhiteLineStart = Utilities.getFirstNonWhiteFwd(doc, lineEnd);
    
    if (nextNonWhiteLineStart > 0){
        initialIndent = Utilities.getRowIndent(doc, nextNonWhiteLineStart, true);
    }
    
    return initialIndent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:TagBasedFormatter.java

示例6: indentNewLine

import org.netbeans.editor.Utilities; //导入方法依赖的package包/类
/** Inserts new line at given position and indents the new line with
    * spaces.
    *
    * @param doc the document to work on
    * @param offset the offset of a character on the line
    * @return new offset to place cursor to
    */
    public int indentNewLine (Document doc, int offset) {
//        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("\n+ XMLFormatter::indentNewLine: doc = " + doc); // NOI18N
//        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset = " + offset); // NOI18N

        if (doc instanceof BaseDocument) {
            BaseDocument bdoc = (BaseDocument)doc;

            bdoc.atomicLock();
            try {
                bdoc.insertString (offset, "\n", null); // NOI18N
                offset++;

                int fullLine = Utilities.getFirstNonWhiteBwd (bdoc, offset - 1);
                int indent = Utilities.getRowIndent (bdoc, fullLine);
                
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: fullLine = " + fullLine); // NOI18N
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: indent   = " + indent); // NOI18N
//
//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset   = " + offset); // NOI18N
//                    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: sb       = '" + sb.toString() + "'"); // NOI18N

                String indentation = getIndentString(bdoc, indent);
                bdoc.insertString (offset, indentation, null);
                offset += indentation.length();

//                if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("+             ::indentNewLine: offset = " + offset); // NOI18N
            } catch (BadLocationException e) {
                if (Boolean.getBoolean ("netbeans.debug.exceptions")) { // NOI18N
                    e.printStackTrace();
                }
            } finally {
                bdoc.atomicUnlock();
            }

            return offset;
        }

        return super.indentNewLine (doc, offset);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:DTDFormatter.java


注:本文中的org.netbeans.editor.Utilities.getRowIndent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。