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


Java RSyntaxTextArea.setCaretPosition方法代碼示例

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


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

示例1: StepDialog

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public StepDialog(AgentDebuggerFrame f, String text, String type) {
    super(f, true);
    this.f = f;
    setLayout(new BorderLayout());
    ta = new RSyntaxTextArea();
    ta.setSyntaxEditingStyle(type);
    ta.setHyperlinksEnabled(false);
    ta.setText(text);
    ta.setCaretPosition(0);
    RTextScrollPane sp = new RTextScrollPane(ta);
    sp.setIconRowHeaderEnabled(true);
    add(BorderLayout.CENTER, sp);
    add(createButtonPanel(), BorderLayout.SOUTH);
    setSize(new Dimension(800, 600));
    setBounds(new Rectangle(getSize()));
    setPreferredSize(getSize());
    WindowUtil.centerOnParent(this);
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:19,代碼來源:StepDialog.java

示例2: actionPerformed

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent e) {

			RSyntaxTextArea textArea = (RSyntaxTextArea)getTextComponent(e);
			RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
			Caret c = textArea.getCaret();

			int dot = c.getDot(); // Get before "<" insertion
			boolean selection = dot!=c.getMark(); // Me too
			textArea.replaceSelection(">");

			// Don't automatically complete a tag if there was a selection
			if (!selection && getAutoAddClosingTags()) {

				Token t = doc.getTokenListForLine(textArea.getCaretLineNumber());
				t = RSyntaxUtilities.getTokenAtOffset(t, dot);
				if (t!=null && t.isSingleChar(Token.MARKUP_TAG_DELIMITER, '>')) {
					String tagName = discoverTagName(doc, dot);
					if (tagName!=null) {
						textArea.replaceSelection("</" + tagName + ">");
						textArea.setCaretPosition(dot+1);
					}
				}

			}

		}
 
開發者ID:pyros2097,項目名稱:GdxStudio,代碼行數:27,代碼來源:AbstractMarkupLanguageSupport.java

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

示例4: createTextArea

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
private RSyntaxTextArea createTextArea() {
	final RSyntaxTextArea queryText = new RSyntaxTextArea(25, 70);
	queryText.setTabSize(3);
	queryText.setCaretPosition(0);
	queryText.requestFocusInWindow();
	queryText.setMarkOccurrences(false);
	queryText.setCodeFoldingEnabled(true);
	queryText.setClearWhitespaceLinesEnabled(false);
	queryText.setAntiAliasingEnabled(true);
	queryText.setLineWrap(false);

	return queryText;
}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:14,代碼來源:QueryEditor.java

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

示例6: rsyntaxEditor

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
public rsyntaxEditor(String selectedValue, boolean initConsoleWindow) {
    RSyntaxTextArea jep = commonEditingActions(selectedValue, true);
    GlobalValues.globalRSyntaxEditorPane = jep;
    jep.setCaretPosition(0);
    scalaExec.Interpreter.GlobalValues.editorPane.requestFocus();
    GCompletionProvider.installAutoCompletion();

}
 
開發者ID:scalalab,項目名稱:scalalab,代碼行數:9,代碼來源:rsyntaxEditor.java

示例7: setLinetoFirstof

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
private boolean setLinetoFirstof(RSyntaxTextArea area, String text) {
	SearchContext context = new SearchContext();
	if (text.length() == 0) {
		return false;
	}

	area.setCaretPosition(0);
	context.setSearchFor(text);
	context.setMatchCase(true);
	context.setRegularExpression(false);
	context.setSearchForward(true);
	context.setWholeWord(false);
	return SearchEngine.find(area, context).wasFound();
}
 
開發者ID:lazyzero,項目名稱:kkMulticopterFlashTool,代碼行數:15,代碼來源:SimonkEditorPanel.java

示例8: display

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
@Override
public void display(String title, BufferedReader r, String toFocus) {

	RSyntaxTextArea textArea = new RSyntaxTextArea(40, 80);
	try {
		textArea.read(r, null);
		r.close();
		textArea.setCaretPosition(0);
	} catch (IOException ioe) {
		UIManager.getLookAndFeel().provideErrorFeedback(null);
		ioe.printStackTrace();
		return;
	}
	textArea.setEditable(false);
	textArea.setSyntaxEditingStyle("text/zscript");
	textArea.setCodeFoldingEnabled(true);

	Frame owner = Frame.getFrames()[0];
	JDialog dialog = new JDialog(owner);
	dialog.setContentPane(new RTextScrollPane(textArea));
	dialog.setTitle(title + " (read-only)");
	dialog.pack();
	dialog.setLocationRelativeTo(null);
	dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	dialog.setVisible(true);

	SearchContext context = new SearchContext(toFocus, true);
	SearchEngine.find(textArea, context);

}
 
開發者ID:bobbylight,項目名稱:ZScriptLanguageSupport,代碼行數:31,代碼來源:DemoDocDisplayer.java

示例9: createTextArea

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
/**
 * Creates the text area for this application.
 *
 * @return The text area.
 */
private RSyntaxTextArea createTextArea() {
	RSyntaxTextArea textArea = new RSyntaxTextArea(25, 70);
	textArea.setTabSize(2);
	textArea.setCaretPosition(0);
	//textArea.addHyperlinkListener(this);
	textArea.requestFocusInWindow();
	//textArea.setMarkOccurrences(true);
	//textArea.setCodeFoldingEnabled(true);
	//textArea.setClearWhitespaceLinesEnabled(false);
	//textArea.setText("int java = 2");
	return textArea;
}
 
開發者ID:HoneyFish,項目名稱:SmartTools,代碼行數:18,代碼來源:PageLogcat.java

示例10: init

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

	cardPanel = new JPanel();
	cardLayout = new CardLayout();
	cardPanel.setLayout(cardLayout);

	paramPanel = new JPanel(new BorderLayout());
	try {
		updateParamPanel();
	} catch (PhonScriptException e1) {
		LOGGER.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
	}
	cardPanel.add(new JScrollPane(paramPanel), paramPanelId);

	// setup editor and save button
	scriptEditor = new RSyntaxTextArea();
	scriptEditor.setText(script.getScript());
	scriptEditor.setColumns(20);
	scriptEditor.setCaretPosition(0);
	RTextScrollPane scriptScroller = new RTextScrollPane(scriptEditor);
	scriptEditor.setSyntaxEditingStyle("text/javascript");
	scriptEditor.getDocument().addDocumentListener(scriptDocListener);
	cardPanel.add(scriptScroller, scriptEditorId);

	ImageIcon viewIcon =
			IconManager.getInstance().getIcon("apps/accessories-text-editor", IconSize.SMALL);
	scriptViewButton = new JToggleButton(viewIcon);
	scriptViewButton.setSelected(false);
	scriptViewButton.setToolTipText("Toggle script/form");
	scriptViewButton.putClientProperty("JButton.buttonType", "textured");
	scriptViewButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {
			boolean showEditor = scriptViewButton.isSelected();

			if(showEditor) {
				showScript();
			} else {
				showForm();
			}
			scriptViewButton.setSelected(showEditor);
		}

	});

	final FlowLayout layout = new FlowLayout(FlowLayout.RIGHT);
	layout.setVgap(0);

	formBtnPanel = new JPanel(layout);
	formBtnPanel.add(scriptViewButton);

	add(cardPanel, BorderLayout.CENTER);
	add(formBtnPanel, BorderLayout.SOUTH);
}
 
開發者ID:phon-ca,項目名稱:phon,代碼行數:57,代碼來源:ScriptPanel.java


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