本文整理汇总了Java中org.fife.ui.rtextarea.RTextArea.getLineEndOffset方法的典型用法代码示例。如果您正苦于以下问题:Java RTextArea.getLineEndOffset方法的具体用法?Java RTextArea.getLineEndOffset怎么用?Java RTextArea.getLineEndOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fife.ui.rtextarea.RTextArea
的用法示例。
在下文中一共展示了RTextArea.getLineEndOffset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWordStart
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
@Override
protected int getWordStart(RTextArea textArea, int offs)
throws BadLocationException {
if (offs==0) {
return offs;
}
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
int line = textArea.getLineOfOffset(offs);
int start = textArea.getLineStartOffset(line);
if (offs==start) {
return start;
}
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--;
}
doc.getText(start, end-start, seg);
// Determine the "type" of char at offs - lower case, upper case,
// whitespace or other. We take special care here as we're starting
// in the middle of the Segment to check whether we're already at
// the "beginning" of a word.
int firstIndex = seg.getBeginIndex() + (offs-start) - 1;
seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs==end ? 0 : seg.array[seg.getIndex() + 1];
// The "word" is a group of letters and/or digits
int languageIndex = 0; // TODO
if (doc.isIdentifierChar(languageIndex, ch)) {
if (offs!=end && !doc.isIdentifierChar(languageIndex, nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (doc.isIdentifierChar(languageIndex, ch));
}
// The "word" is whitespace
else if (Character.isWhitespace(ch)) {
if (offs!=end && !Character.isWhitespace(nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" a single "something else" char (operator,
// etc.).
offs -= firstIndex - seg.getIndex() + 1;//seg.getEndIndex() - seg.getIndex();
if (ch!=Segment.DONE && nextCh!='\n') {
offs++;
}
return offs;
}
示例2: getPreviousWordStart
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
@Override
protected int getPreviousWordStart(RTextArea textArea, int offs)
throws BadLocationException {
if (offs==0) {
return offs;
}
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
int line = textArea.getLineOfOffset(offs);
int start = textArea.getLineStartOffset(line);
if (offs==start) {
return start-1; // Just delete the newline
}
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--;
}
doc.getText(start, end-start, seg);
// Determine the "type" of char at offs - lower case, upper case,
// whitespace or other. We take special care here as we're starting
// in the middle of the Segment to check whether we're already at
// the "beginning" of a word.
int firstIndex = seg.getBeginIndex() + (offs-start) - 1;
seg.setIndex(firstIndex);
char ch = seg.current();
// Always strip off whitespace first
if (Character.isWhitespace(ch)) {
do {
ch = seg.previous();
} while (Character.isWhitespace(ch));
}
// The "word" is a group of letters and/or digits
int languageIndex = 0; // TODO
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.previous();
} while (doc.isIdentifierChar(languageIndex, ch));
}
// The "word" is a series of symbols.
else {
while (!Character.isWhitespace(ch) &&
!doc.isIdentifierChar(languageIndex, ch)
&& ch!=Segment.DONE) {
ch = seg.previous();
}
}
if (ch==Segment.DONE) {
return start; // Removed last "token" of the line
}
offs -= firstIndex - seg.getIndex();
return offs;
}
示例3: getWordEnd
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
@Override
protected int getWordEnd(RTextArea textArea, int offs)
throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
if (offs==doc.getLength()) {
return offs;
}
int line = textArea.getLineOfOffset(offs);
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--; // Hide newline
}
if (offs==end) {
return end;
}
doc.getText(offs, end-offs, seg);
// Determine the "type" of char at offs - letter/digit,
// whitespace or other
char ch = seg.first();
// The "word" is a group of letters and/or digits
int languageIndex = 0; // TODO
if (doc.isIdentifierChar(languageIndex, ch)) {
do {
ch = seg.next();
} while (doc.isIdentifierChar(languageIndex, ch));
}
// The "word" is whitespace.
else if (Character.isWhitespace(ch)) {
do {
ch = seg.next();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" is a single character of some other type
// (operator, etc.).
offs += seg.getIndex() - seg.getBeginIndex();
return offs;
}
示例4: getWordStart
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
protected int getWordStart(RTextArea textArea, int offs)
throws BadLocationException {
if (offs == 0) {
return offs;
}
RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
int line = textArea.getLineOfOffset(offs);
int start = textArea.getLineStartOffset(line);
if (offs == start) {
return start;
}
int end = textArea.getLineEndOffset(line);
if (line != textArea.getLineCount() - 1) {
end--;
}
doc.getText(start, end - start, seg);
// Determine the "type" of char at offs - lower case, upper case,
// whitespace or other. We take special care here as we're starting
// in the middle of the Segment to check whether we're already at
// the "beginning" of a word.
int firstIndex = seg.getBeginIndex() + (offs - start) - 1;
seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs == end ? 0 : seg.array[seg.getIndex() + 1];
// The "word" is a group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
if (offs != end && !Character.isLetterOrDigit(nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (Character.isLetterOrDigit(ch));
}
// The "word" is whitespace
else if (Character.isWhitespace(ch)) {
if (offs != end && !Character.isWhitespace(nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" a single "something else" char (operator,
// etc.).
offs -= firstIndex - seg.getIndex() + 1;// seg.getEndIndex() - seg.getIndex();
if (ch != Segment.DONE && nextCh != '\n') {
offs++;
}
return offs;
}
示例5: getWordEnd
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
protected int getWordEnd(RTextArea textArea, int offs)
throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
if (offs == doc.getLength()) {
return offs;
}
int line = textArea.getLineOfOffset(offs);
int end = textArea.getLineEndOffset(line);
if (line != textArea.getLineCount() - 1) {
end--; // Hide newline
}
if (offs == end) {
return end;
}
doc.getText(offs, end - offs, seg);
// Determine the "type" of char at offs - letter/digit,
// whitespace or other
char ch = seg.first();
// The "word" is a group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
do {
ch = seg.next();
} while (Character.isLetterOrDigit(ch));
}
// The "word" is whitespace.
else if (Character.isWhitespace(ch)) {
do {
ch = seg.next();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" is a single character of some other type
// (operator, etc.).
offs += seg.getIndex() - seg.getBeginIndex();
return offs;
}
示例6: getNextWord
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
/**
* Overridden to do better with skipping "words" in code.
*/
protected int getNextWord(RTextArea textArea, int offs)
throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
if (offs == doc.getLength()) {
return offs;
}
int line = textArea.getLineOfOffset(offs);
int end = textArea.getLineEndOffset(line);
if (offs == end) {
return offs + 1; // Start of next line.
}
doc.getText(offs, end - offs, seg);
// Determine the "type" of char at offs - letter/digit,
// whitespace or other
char ch = seg.first();
// Skip the group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
do {
ch = seg.next();
} while (Character.isLetterOrDigit(ch));
}
// Skip groups of "anything else" (operators, etc.).
else if (!Character.isWhitespace(ch)) {
do {
ch = seg.next();
} while (ch != Segment.DONE &&
!(Character.isLetterOrDigit(ch) ||
Character.isWhitespace(ch)));
}
// Skip any trailing whitespace
while (Character.isWhitespace(ch)) {
ch = seg.next();
}
offs += seg.getIndex() - seg.getBeginIndex();
return offs;
}
示例7: getWordStart
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
protected int getWordStart(RTextArea textArea, int offs)
throws BadLocationException {
if (offs==0) {
return offs;
}
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
int line = textArea.getLineOfOffset(offs);
int start = textArea.getLineStartOffset(line);
if (offs==start) {
return start;
}
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--;
}
doc.getText(start, end-start, seg);
// Determine the "type" of char at offs - lower case, upper case,
// whitespace or other. We take special care here as we're starting
// in the middle of the Segment to check whether we're already at
// the "beginning" of a word.
int firstIndex = seg.getBeginIndex() + (offs-start) - 1;
seg.setIndex(firstIndex);
char ch = seg.current();
char nextCh = offs==end ? 0 : seg.array[seg.getIndex() + 1];
// The "word" is a group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
if (offs!=end && !Character.isLetterOrDigit(nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (Character.isLetterOrDigit(ch));
}
// The "word" is whitespace
else if (Character.isWhitespace(ch)) {
if (offs!=end && !Character.isWhitespace(nextCh)) {
return offs;
}
do {
ch = seg.previous();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" a single "something else" char (operator,
// etc.).
offs -= firstIndex - seg.getIndex() + 1;//seg.getEndIndex() - seg.getIndex();
if (ch!=Segment.DONE && nextCh!='\n') {
offs++;
}
return offs;
}
示例8: getPreviousWordStart
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
protected int getPreviousWordStart(RTextArea textArea, int offs)
throws BadLocationException {
if (offs==0) {
return offs;
}
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
int line = textArea.getLineOfOffset(offs);
int start = textArea.getLineStartOffset(line);
if (offs==start) {
return start-1; // Just delete the newline
}
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--;
}
doc.getText(start, end-start, seg);
// Determine the "type" of char at offs - lower case, upper case,
// whitespace or other. We take special care here as we're starting
// in the middle of the Segment to check whether we're already at
// the "beginning" of a word.
int firstIndex = seg.getBeginIndex() + (offs-start) - 1;
seg.setIndex(firstIndex);
char ch = seg.current();
// Always strip off whitespace first
if (Character.isWhitespace(ch)) {
do {
ch = seg.previous();
} while (Character.isWhitespace(ch));
}
// The "word" is a group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
do {
ch = seg.previous();
} while (Character.isLetterOrDigit(ch));
}
// The "word" is a series of symbols.
else {
while (!Character.isWhitespace(ch) &&
!Character.isLetterOrDigit(ch)
&& ch!=Segment.DONE) {
ch = seg.previous();
}
}
if (ch==Segment.DONE) {
return start; // Removed last "token" of the line
}
offs -= firstIndex - seg.getIndex();
return offs;
}
示例9: getWordEnd
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
protected int getWordEnd(RTextArea textArea, int offs)
throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
if (offs==doc.getLength()) {
return offs;
}
int line = textArea.getLineOfOffset(offs);
int end = textArea.getLineEndOffset(line);
if (line!=textArea.getLineCount()-1) {
end--; // Hide newline
}
if (offs==end) {
return end;
}
doc.getText(offs, end-offs, seg);
// Determine the "type" of char at offs - letter/digit,
// whitespace or other
char ch = seg.first();
// The "word" is a group of letters and/or digits
if (Character.isLetterOrDigit(ch)) {
do {
ch = seg.next();
} while (Character.isLetterOrDigit(ch));
}
// The "word" is whitespace.
else if (Character.isWhitespace(ch)) {
do {
ch = seg.next();
} while (Character.isWhitespace(ch));
}
// Otherwise, the "word" is a single character of some other type
// (operator, etc.).
offs += seg.getIndex() - seg.getBeginIndex();
return offs;
}