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


Java RTextArea.replaceSelection方法代码示例

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


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

示例1: doDefaultInsert

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
private final void doDefaultInsert(RTextArea textArea) {
	// FIXME:  We need a way to get the "trigger string" (i.e.,
	// the text that was just typed); however, the text area's
	// template manager might be null (if templates are disabled).
	// Also, the manager's trigger string doesn't yet match up with
	// that defined in RSyntaxTextAreaEditorKit.java (which is
	// hardcoded as a space)...
	//String str = manager.getInsertTriggerString();
	//int mod = manager.getInsertTrigger().getModifiers();
	//if (str!=null && str.length()>0 &&
	//	((mod&ActionEvent.ALT_MASK)==(mod&ActionEvent.CTRL_MASK))) {
	//	char ch = str.charAt(0);
	//	if (ch>=0x20 && ch!=0x7F)
	//		textArea.replaceSelection(str);
	//}
	textArea.replaceSelection(" ");
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:18,代码来源:RSyntaxTextAreaEditorKit.java

示例2: doDefaultInsert

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
private final void doDefaultInsert(RTextArea textArea) {
    // FIXME: We need a way to get the "trigger string" (i.e.,
    // the text that was just typed); however, the text area's
    // template manager might be null (if templates are disabled).
    // Also, the manager's trigger string doesn't yet match up with
    // that defined in RSyntaxTextAreaEditorKit.java (which is
    // hardcoded as a space)...
    // String str = manager.getInsertTriggerString();
    // int mod = manager.getInsertTrigger().getModifiers();
    // if (str!=null && str.length()>0 &&
    // ((mod&ActionEvent.ALT_MASK)==(mod&ActionEvent.CTRL_MASK))) {
    // char ch = str.charAt(0);
    // if (ch>=0x20 && ch!=0x7F)
    // textArea.replaceSelection(str);
    // }
    textArea.replaceSelection(" ");
}
 
开发者ID:intuit,项目名称:Tank,代码行数:18,代码来源:RSyntaxTextAreaEditorKit.java

示例3: actionPerformedImpl

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
@Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {

	if (!textArea.isEditable() || !textArea.isEnabled()) {
		UIManager.getLookAndFeel().provideErrorFeedback(textArea);
		return;
	}

	Document document = textArea.getDocument();
	Element map = document.getDefaultRootElement();
	Caret c = textArea.getCaret();
	int dot = c.getDot();
	int mark = c.getMark();
	int dotLine = map.getElementIndex(dot);
	int markLine = map.getElementIndex(mark);

	// If there is a multi-line selection, indent all lines in
	// the selection.
	if (dotLine!=markLine) {
		int first = Math.min(dotLine, markLine);
		int last = Math.max(dotLine, markLine);
		Element elem; int start;

		// Since we're using Document.insertString(), we must mimic the
		// soft tab behavior provided by RTextArea.replaceSelection().
		String replacement = "\t";
		if (textArea.getTabsEmulated()) {
			StringBuilder sb = new StringBuilder();
			int temp = textArea.getTabSize();
			for (int i=0; i<temp; i++) {
				sb.append(' ');
			}
			replacement = sb.toString();
		}

		textArea.beginAtomicEdit();
		try {
			for (int i=first; i<last; i++) {
				elem = map.getElement(i);
				start = elem.getStartOffset();
				document.insertString(start, replacement, null);
			}
			// Don't do the last line if the caret is at its
			// beginning.  We must call getDot() again and not just
			// use 'dot' as the caret's position may have changed
			// due to the insertion of the tabs above.
			elem = map.getElement(last);
			start = elem.getStartOffset();
			if (Math.max(c.getDot(), c.getMark())!=start) {
				document.insertString(start, replacement, null);
			}
		} catch (BadLocationException ble) { // Never happens.
			ble.printStackTrace();
			UIManager.getLookAndFeel().
							provideErrorFeedback(textArea);
		} finally {
			textArea.endAtomicEdit();
		}
	}
	else {
		textArea.replaceSelection("\t");
	}

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

示例4: actionPerformedImpl

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {

            if (!textArea.isEditable() || !textArea.isEnabled()) {
                UIManager.getLookAndFeel().provideErrorFeedback(textArea);
                return;
            }

            Document document = textArea.getDocument();
            Element map = document.getDefaultRootElement();
            Caret c = textArea.getCaret();
            int dot = c.getDot();
            int mark = c.getMark();
            int dotLine = map.getElementIndex(dot);
            int markLine = map.getElementIndex(mark);

            // If there is a multiline selection, indent all lines in
            // the selection.
            if (dotLine != markLine) {
                int first = Math.min(dotLine, markLine);
                int last = Math.max(dotLine, markLine);
                Element elem;
                int start;
                try {
                    for (int i = first; i < last; i++) {
                        elem = map.getElement(i);
                        start = elem.getStartOffset();
                        document.insertString(start, "\t", null);
                    }
                    // Don't do the last line if the caret is at its
                    // beginning. We must call getDot() again and not just
                    // use 'dot' as the caret's position may have changed
                    // due to the insertion of the tabs above.
                    elem = map.getElement(last);
                    start = elem.getStartOffset();
                    if (Math.max(c.getDot(), c.getMark()) != start) {
                        document.insertString(start, "\t", null);
                    }
                } catch (BadLocationException ble) { // Never happens.
                    ble.printStackTrace();
                    UIManager.getLookAndFeel().
                            provideErrorFeedback(textArea);
                }
            }
            else {
                textArea.replaceSelection("\t");
            }

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

示例5: actionPerformedImpl

import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {

			if (!textArea.isEditable() || !textArea.isEnabled()) {
				UIManager.getLookAndFeel().provideErrorFeedback(textArea);
				return;
			}

			Document document = textArea.getDocument();
			Element map = document.getDefaultRootElement();
			Caret c = textArea.getCaret();
			int dot = c.getDot();
			int mark = c.getMark();
			int dotLine = map.getElementIndex(dot);
			int markLine = map.getElementIndex(mark);

			// If there is a multi-line selection, indent all lines in
			// the selection.
			if (dotLine!=markLine) {
				int first = Math.min(dotLine, markLine);
				int last = Math.max(dotLine, markLine);
				Element elem; int start;

				// Since we're using Document.insertString(), we must mimic the
				// soft tab behavior provided by RTextArea.replaceSelection().
				String replacement = "\t";
				if (textArea.getTabsEmulated()) {
					StringBuffer sb = new StringBuffer();
					int temp = textArea.getTabSize();
					for (int i=0; i<temp; i++) {
						sb.append(' ');
					}
					replacement = sb.toString();
				}

				textArea.beginAtomicEdit();
				try {
					for (int i=first; i<last; i++) {
						elem = map.getElement(i);
						start = elem.getStartOffset();
						document.insertString(start, replacement, null);
					}
					// Don't do the last line if the caret is at its
					// beginning.  We must call getDot() again and not just
					// use 'dot' as the caret's position may have changed
					// due to the insertion of the tabs above.
					elem = map.getElement(last);
					start = elem.getStartOffset();
					if (Math.max(c.getDot(), c.getMark())!=start) {
						document.insertString(start, replacement, null);
					}
				} catch (BadLocationException ble) { // Never happens.
					ble.printStackTrace();
					UIManager.getLookAndFeel().
									provideErrorFeedback(textArea);
				} finally {
					textArea.endAtomicEdit();
				}
			}
			else {
				textArea.replaceSelection("\t");
			}

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


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