當前位置: 首頁>>代碼示例>>Java>>正文


Java RSyntaxTextArea.getText方法代碼示例

本文整理匯總了Java中org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java RSyntaxTextArea.getText方法的具體用法?Java RSyntaxTextArea.getText怎麽用?Java RSyntaxTextArea.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.fife.ui.rsyntaxtextarea.RSyntaxTextArea的用法示例。


在下文中一共展示了RSyntaxTextArea.getText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invoke

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
/**
 * Invokes this code template.  The changes are made to the given text
 * area.
 *
 * @param textArea The text area to operate on.
 * @throws BadLocationException If something bad happens.
 */
public void invoke(RSyntaxTextArea textArea) throws BadLocationException {

	Caret c = textArea.getCaret();
	int dot = c.getDot();
	int mark = c.getMark();
	int p0 = Math.min(dot, mark);
	int p1 = Math.max(dot, mark);
	RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
	Element map = doc.getDefaultRootElement();

	int lineNum = map.getElementIndex(dot);
	Element line = map.getElement(lineNum);
	int start = line.getStartOffset();
	int end = line.getEndOffset()-1; // Why always "-1"?
	String s = textArea.getText(start,end-start);
	int len = s.length();

	// endWS is the end of the leading whitespace
	// of the current line.
	int endWS = 0;
	while (endWS<len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
		endWS++;
	}
	s = s.substring(0, endWS);
	p0 -= getID().length();
	String beforeText = getBeforeTextIndented(s);
	String afterText = getAfterTextIndented(s);
	doc.replace(p0,p1-p0, beforeText+afterText, null);
	textArea.setCaretPosition(p0+beforeText.length());

}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:39,代碼來源:StaticCodeTemplate.java

示例2: invoke

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
/**
 * Invokes this code template. The changes are made to the given text area.
 * 
 * @param textArea
 *            The text area to operate on.
 * @throws BadLocationException
 *             If something bad happens.
 */
public void invoke(RSyntaxTextArea textArea) throws BadLocationException {

    Caret c = textArea.getCaret();
    int dot = c.getDot();
    int mark = c.getMark();
    int p0 = Math.min(dot, mark);
    int p1 = Math.max(dot, mark);
    RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
    Element map = doc.getDefaultRootElement();

    int lineNum = map.getElementIndex(dot);
    Element line = map.getElement(lineNum);
    int start = line.getStartOffset();
    int end = line.getEndOffset() - 1; // Why always "-1"?
    String s = textArea.getText(start, end - start);
    int len = s.length();

    // endWS is the end of the leading whitespace
    // of the current line.
    int endWS = 0;
    while (endWS < len && RSyntaxUtilities.isWhitespace(s.charAt(endWS))) {
        endWS++;
    }
    s = s.substring(0, endWS);
    p0 -= getID().length();
    String beforeText = getBeforeTextIndented(s);
    String afterText = getAfterTextIndented(s);
    doc.replace(p0, p1 - p0, beforeText + afterText, null);
    textArea.setCaretPosition(p0 + beforeText.length());

}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:40,代碼來源:StaticCodeTemplate.java

示例3: find

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
private void find(RSyntaxTextArea textArea) {

        try {
            int offset = currentLine < textArea.getLineCount() ? textArea.getLineStartOffset(currentLine) : 0;
            String searchTerm = tfSearchEditor.getText();
            String text = textArea.getText();
            int foundIndex = -1;
            int flags = (checkboxRegexp.isSelected() ? 0 : Pattern.LITERAL)
                    | (checkboxMatchCase.isSelected() ? 0 : Pattern.CASE_INSENSITIVE);
            Pattern p = Pattern.compile(searchTerm, flags);
            Matcher matcher = p.matcher(text);
            matcher.region(offset, text.length());
            if (matcher.find()) {
                foundIndex = matcher.start();
            } else if (checkboxWrap.isSelected() && offset > 0) {
                matcher.region(0, offset);
                if (matcher.find()) {
                    foundIndex = matcher.start();
                }
            }
            if (foundIndex != -1) {
                int lineOfOffset = textArea.getLineOfOffset(foundIndex);
                // textArea.setActiveLineRange(lineOfOffset, lineOfOffset);
                textArea.setCurrentLine(lineOfOffset);
                // textArea.setCaretPosition(foundIndex + searchTerm.length());
                parent.repaint();
                parent.fireStepChanged(lineOfOffset);
                currentLine = lineOfOffset + 1;
            } else {
                JOptionPane.showMessageDialog(parent, "Search String not found.");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
開發者ID:intuit,項目名稱:Tank,代碼行數:37,代碼來源:FindReplaceDialog.java

示例4: getSmali

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public Object[] getSmali() {
    for (int i = 0; i < smalis.size(); i++) {
        RSyntaxTextArea text = smalis.get(i);
        if (text != null) {
            return new Object[]{cn, text.getText()};
        }
    }
    return null;
}
 
開發者ID:Konloch,項目名稱:bytecode-viewer,代碼行數:10,代碼來源:ClassViewer.java

示例5: getKrakatau

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public Object[] getKrakatau() {
    for (int i = 0; i < krakataus.size(); i++) {
        RSyntaxTextArea text = krakataus.get(i);
        if (text != null) {
            return new Object[]{cn, text.getText()};
        }
    }
    return null;
}
 
開發者ID:Konloch,項目名稱:bytecode-viewer,代碼行數:10,代碼來源:ClassViewer.java

示例6: getJava

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public Object[] getJava() {
    for (int i = 0; i < javas.size(); i++) {
        RSyntaxTextArea text = javas.get(i);
        if (text != null) {
            return new Object[]{cn, text.getText()};
        }
    }
    return null;
}
 
開發者ID:Konloch,項目名稱:bytecode-viewer,代碼行數:10,代碼來源:ClassViewer.java


注:本文中的org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。