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


Java RTextArea.getLineStartOffset方法代码示例

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


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

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:62,代码来源:RSyntaxTextAreaEditorKit.java

示例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;

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:60,代码来源:RSyntaxTextAreaEditorKit.java

示例3: 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;

}
 
开发者ID:intuit,项目名称:Tank,代码行数:60,代码来源:RSyntaxTextAreaEditorKit.java

示例4: getPreviousWord

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
/**
 * Overridden to do better with skipping "words" in code.
 */
protected int getPreviousWord(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; // End of previous line.
    }
    doc.getText(start, offs - start, seg);

    // Determine the "type" of char at offs - lower case, upper case,
    // whitespace or other
    char ch = seg.last();

    // Skip any "leading" whitespace
    while (Character.isWhitespace(ch)) {
        ch = seg.previous();
    }

    // Skip the group of letters and/or digits
    if (Character.isLetterOrDigit(ch)) {
        do {
            ch = seg.previous();
        } while (Character.isLetterOrDigit(ch));
    }

    // Skip groups of "anything else" (operators, etc.).
    else if (!Character.isWhitespace(ch)) {
        do {
            ch = seg.previous();
        } while (ch != Segment.DONE &&
                !(Character.isLetterOrDigit(ch) ||
                Character.isWhitespace(ch)));
    }

    offs -= seg.getEndIndex() - seg.getIndex();
    if (ch != Segment.DONE) {
        offs++;
    }

    return offs;

}
 
开发者ID:intuit,项目名称:Tank,代码行数:52,代码来源:RSyntaxTextAreaEditorKit.java

示例5: 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;

}
 
开发者ID:Nanonid,项目名称:RSyntaxTextArea,代码行数:60,代码来源:RSyntaxTextAreaEditorKit.java

示例6: 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;

}
 
开发者ID:Nanonid,项目名称:RSyntaxTextArea,代码行数:58,代码来源:RSyntaxTextAreaEditorKit.java


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