本文整理了Java中javax.swing.text.Segment.next()
方法的一些代码示例,展示了Segment.next()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Segment.next()
方法的具体详情如下:
包路径:javax.swing.text.Segment
类名称:Segment
方法名:next
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.next();
} while (doc.isIdentifierChar(languageIndex, ch) &&
ch != CharacterIterator.DONE);
ch = seg.next();
} while (Character.isWhitespace(ch));
代码示例来源:origin: bobbylight/RSyntaxTextArea
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.next();
} while (doc.isIdentifierChar(languageIndex, ch) &&
ch != CharacterIterator.DONE);
ch = seg.next();
} while (ch!=Segment.DONE &&
!(doc.isIdentifierChar(languageIndex, ch) ||
ch = seg.next();
代码示例来源:origin: com.google.code.findbugs/findbugs
/**
* Increments the iterator's index by one and returns the character at the
* new index.
*
* @return the character at the new position, or DONE if the new position is
* off the end
*/
@Override
public char next() {
++docPos;
if (docPos < segmentEnd || segmentEnd >= doc.getLength()) {
return text.next();
}
try {
doc.getText(segmentEnd, doc.getLength() - segmentEnd, text);
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
segmentEnd += text.count;
return text.current();
}
代码示例来源:origin: net.sf.jazzy/jazzy
/** This helper method will return the end of the next word in the buffer.
*
*/
private static int getNextWordEnd(Segment text, int startPos) {
for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
if (!Character.isLetterOrDigit(ch)) {
if (ch == '-' || ch == '\'') { // handle ' and - inside words
char ch2 = text.next();
text.previous();
if (ch2 != Segment.DONE && Character.isLetterOrDigit(ch2))
continue;
}
return text.getIndex();
}
}
return text.getEndIndex();
}
代码示例来源:origin: net.sf.jazzy/jazzy
/** This helper method will return the start character of the next
* word in the buffer from the start position
*/
private static int getNextWordStart(Segment text, int startPos) {
if (startPos <= text.getEndIndex())
for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
if (Character.isLetterOrDigit(ch)) {
return text.getIndex();
}
}
return -1;
}
代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea
ch = seg.next();
} while (Character.isLetterOrDigit(ch));
ch = seg.next();
} while (ch!=Segment.DONE &&
!(Character.isLetterOrDigit(ch) ||
ch = seg.next();
代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea
ch = seg.next();
} while (Character.isLetterOrDigit(ch));
ch = seg.next();
} while (Character.isWhitespace(ch));
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.next();
} while (doc.isIdentifierChar(languageIndex, ch) &&
ch != CharacterIterator.DONE);
ch = seg.next();
} while (Character.isWhitespace(ch));
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
for (text.first(); next != Segment.DONE; next = text.next()) {
代码示例来源:origin: net.sf.jazzy/jazzy
/**
* Sets the current word position at the start of the word containing
* the char at position pos. This way a call to nextWord() will return
* this word.
*
* @param pos position in the word we want to set as current.
*/
public void posStartFullWordFrom(int pos){
currentWordPos=text.getBeginIndex();
if(pos>text.getEndIndex())
pos=text.getEndIndex();
for (char ch = text.setIndex(pos); ch != Segment.DONE; ch = text.previous()) {
if (!Character.isLetterOrDigit(ch)) {
if (ch == '-' || ch == '\'') { // handle ' and - inside words
char ch2 = text.previous();
text.next();
if (ch2 != Segment.DONE && Character.isLetterOrDigit(ch2))
continue;
}
currentWordPos=text.getIndex()+1;
break;
}
}
//System.out.println("CurPos:"+currentWordPos);
if(currentWordPos==0)
first=true;
moreTokens=true;
currentWordEnd = getNextWordEnd(text, currentWordPos);
nextWordPos = getNextWordStart(text, currentWordEnd + 1);
}
代码示例来源:origin: de.sciss/syntaxpane
static int getSmartHomeOffset(JTextComponent target, SyntaxDocument sDoc,
int dot) throws BadLocationException {
Element el = sDoc.getParagraphElement(dot);
Segment seg = new Segment();
sDoc.getText(el.getStartOffset(),
el.getEndOffset() - el.getStartOffset() - 1, seg);
int homeOffset = 0;
int dotLineOffset = dot - el.getStartOffset();
boolean inText = false;
// see the location of first non-space offset
for (int i = 0; i < dotLineOffset; i++) {
if (!Character.isWhitespace(seg.charAt(i))) {
inText = true;
break;
}
}
// if we are at first char in line, or we are past the non space
// chars in the line, then we move to non-space char
// otherwise, we move to first char of line
if (dotLineOffset == 0 || inText) {
for (char ch = seg.first();
ch != CharacterIterator.DONE && Character.isWhitespace(ch);
ch = seg.next()) {
homeOffset++;
}
}
return el.getStartOffset() + homeOffset;
}
}
代码示例来源:origin: de.sciss/jsyntaxpane
static int getSmartHomeOffset(JTextComponent target, SyntaxDocument sDoc,
int dot) throws BadLocationException {
Element el = sDoc.getParagraphElement(dot);
Segment seg = new Segment();
sDoc.getText(el.getStartOffset(),
el.getEndOffset() - el.getStartOffset() - 1, seg);
int homeOffset = 0;
int dotLineOffset = dot - el.getStartOffset();
boolean inText = false;
// see the location of first non-space offset
for (int i = 0; i < dotLineOffset; i++) {
if (!Character.isWhitespace(seg.charAt(i))) {
inText = true;
break;
}
}
// if we are at first char in line, or we are past the non space
// chars in the line, then we move to non-space char
// otherwise, we move to first char of line
if (dotLineOffset == 0 || inText) {
for (char ch = seg.first();
ch != CharacterIterator.DONE && Character.isWhitespace(ch);
ch = seg.next()) {
homeOffset++;
}
}
return el.getStartOffset() + homeOffset;
}
}
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.next();
} while (doc.isIdentifierChar(languageIndex, ch) &&
ch != CharacterIterator.DONE);
ch = seg.next();
} while (ch!=Segment.DONE &&
!(doc.isIdentifierChar(languageIndex, ch) ||
ch = seg.next();
内容来源于网络,如有侵权,请联系作者删除!