本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}