/** * Actually inserts the newline into the document, and auto-indents * if appropriate. This method can be called by token makers who * implement a custom action for inserting newlines. * * @param textArea * @param noSelection Whether there is no selection. */ protected void handleInsertBreak(RSyntaxTextArea textArea, boolean noSelection) { // If we're auto-indenting... if (noSelection && textArea.isAutoIndentEnabled()) { insertNewlineWithAutoIndent(textArea); } else { textArea.replaceSelection("\n"); if (noSelection) { possiblyCloseCurlyBrace(textArea, null); } } }
sta.setSelectionEnd(end); sta.replaceSelection(sb.toString()); sta.replaceSelection("\t"); sta.replaceSelection("\n"); ble.printStackTrace();
(firstMlcLine ? " * " : "*") + m.group(3); textArea.replaceSelection("\n" + header); if (nested) {
rsta.replaceSelection("/"); rsta.replaceSelection(tagName + (char)(ch+2));
@Override public boolean doCut() { boolean result = false; final String selected = this.editor.getSelectedText(); if (selected != null && !selected.isEmpty()) { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(selected), null); this.editor.replaceSelection(""); //NOI18N } return result; }
@Override public boolean doCut() { boolean result = false; final String selected = this.editor.getSelectedText(); if (selected != null && !selected.isEmpty()) { final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(selected), null); this.editor.replaceSelection(""); //NOI18N } return result; }
@Override public boolean doPaste() { boolean result = false; final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); String text = null; try { if (Utils.isDataFlavorAvailable(clipboard, DataFlavor.stringFlavor)) { text = clipboard.getData(DataFlavor.stringFlavor).toString(); } } catch (Exception ex) { LOGGER.warn("Can't get data from clipboard : " + ex.getMessage()); //NOI18N } if (text != null) { this.editor.replaceSelection(text); result = true; } return result; }
@Override public boolean doPaste() { boolean result = false; final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); String text = null; try { if (Utils.isDataFlavorAvailable(clipboard, DataFlavor.stringFlavor)) { text = clipboard.getData(DataFlavor.stringFlavor).toString(); } } catch (Exception ex) { LOGGER.warn("Can't get data from clipboard : " + ex.getMessage()); //NOI18N } if (text != null) { this.editor.replaceSelection(text); result = true; } return result; }
rSyntaxTextArea.replaceSelection(highlightedTextArea.replace("%", "")); } else { String[] array = highlightedTextArea.split("\n"); rSyntaxTextArea.replaceSelection(commentedCodeBuilder.toString());
/** * Block comment the selected text in the given script panel. * * @param scriptPanel Script panel */ private static void blockComment(RSyntaxTextArea scriptPanel) { // Recover the index of the start of the selection. final int startOffset = scriptPanel.getSelectionStart(); // Comment the selection. final String commentedSelection = BLOCK_COMMENT_START + scriptPanel.getSelectedText() + BLOCK_COMMENT_END; scriptPanel.replaceSelection(commentedSelection); // Select the commented selection. scriptPanel.setSelectionStart(startOffset); scriptPanel.setSelectionEnd(startOffset + commentedSelection.length()); }
/** * Actually inserts the newline into the document, and auto-indents * if appropriate. This method can be called by token makers who * implement a custom action for inserting newlines. * * @param textArea * @param noSelection Whether there is no selection. */ protected void handleInsertBreak(RSyntaxTextArea textArea, boolean noSelection) { // If we're auto-indenting... if (noSelection && textArea.isAutoIndentEnabled()) { insertNewlineWithAutoIndent(textArea); } else { textArea.replaceSelection("\n"); if (noSelection) { possiblyCloseCurlyBrace(textArea, null); } } }
sta.replaceRange(null, start,end); sta.replaceSelection(sb.toString()); sta.replaceSelection("\t"); sta.replaceSelection("\n"); ble.printStackTrace();
sta.setSelectionEnd(end); sta.replaceSelection(sb.toString()); sta.replaceSelection("\t"); sta.replaceSelection("\n"); ble.printStackTrace();
sta.setSelectionEnd(end); sta.replaceSelection(sb.toString()); sta.replaceSelection("\t"); sta.replaceSelection("\n"); ble.printStackTrace();
@Override 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); } } } }
public static void quoteSQL(SQLConsolePanel entryPanel, boolean sbAppend) { int[] bounds = entryPanel.getBoundsOfCurrentSQLStatement(); if (bounds[0] == bounds[1]) { return; } String textToQuote = entryPanel.getCurrentSQLStatement(); if (null == textToQuote) { return; } String quotedText = QuoteUtilities.quoteText(textToQuote, sbAppend); entryPanel.getScriptPanel().setSelectionStart(bounds[0]); entryPanel.getScriptPanel().setSelectionEnd(bounds[1]); entryPanel.getScriptPanel().replaceSelection(quotedText); }
textArea.replaceSelection(replaceField.getText());
public static void unquoteSQL(SQLConsolePanel entryPanel) { int[] bounds = entryPanel.getBoundsOfCurrentSQLStatement(); if (bounds[0] == bounds[1]) { return; } String textToUnquote = entryPanel.getCurrentSQLStatement(); if (null == textToUnquote) { return; } String unquotedText = QuoteUtilities.unquoteText(textToUnquote); entryPanel.getScriptPanel().setSelectionStart(bounds[0]); entryPanel.getScriptPanel().setSelectionEnd(bounds[1]); entryPanel.getScriptPanel().replaceSelection(unquotedText); } }
rsta.replaceSelection("/"); rsta.replaceSelection(tagName + (char)(ch+2));
rsta.replaceSelection("/"); rsta.replaceSelection(tagName + (char)(ch+2));