/** * @param str - if null -> reset current highlights */ private void highlightAllMatches(@Nullable String str) { SearchContext context = new SearchContext(str); context.setMarkAll(true); context.setMatchCase(true); context.setWholeWord(true); SearchEngine.markAll(this, context); }
@Override public void actionPerformed(ActionEvent event) { if (textField.getText().length() == 0) return; RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea(); if (pane == null) return; SearchContext context = new SearchContext(); context.setSearchFor(textField.getText()); context.setMatchCase(mcase.isSelected()); context.setRegularExpression(regex.isSelected()); context.setSearchForward(!reverse.isSelected()); context.setWholeWord(wholew.isSelected()); if (!SearchEngine.find(pane, context).wasFound()) { if (wrap.isSelected()) { pane.setSelectionStart(0); pane.setSelectionEnd(0); } else { mainWindow.getLabel().setText("Search Complete"); } } }
public void closeOpenTab(int index) { RTextScrollPane co = (RTextScrollPane) house.getComponentAt(index); RSyntaxTextArea pane = (RSyntaxTextArea) co.getViewport().getView(); OpenFile open = null; for (OpenFile file : hmap) if (pane.equals(file.textArea)) open = file; if (open != null && hmap.contains(open)) hmap.remove(open); house.remove(co); if (open != null) open.close(); }
else textArea.setSyntaxEditingStyle(SYNTAX_STYLE_PROPERTIES_FILE); scrollPane = new RTextScrollPane(textArea, true); scrollPane.setIconRowHeaderEnabled(true); textArea.setText(""); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); final JScrollBar verticalScrollbar = scrollPane.getVerticalScrollBar(); if (verticalScrollbar != null) { verticalScrollbar.addAdjustmentListener(new AdjustmentListener() { for (MouseWheelListener listeners : scrollPane.getMouseWheelListeners()) { scrollPane.removeMouseWheelListener(listeners); scrollPane.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) {
/** * Paints editor augmentations added by RTextArea: highlighted lines, * current line highlight, and margin line. * * @param g The graphics context with which to paint. */ protected void paintEditorAugmentations(Graphics g) { Rectangle visibleRect = textArea.getVisibleRect(); paintLineHighlights(g); paintCurrentLineHighlight(g, visibleRect); paintMarginLine(g, visibleRect); }
private RCompoundEdit startCompoundEdit(UndoableEdit edit) { lastOffset = textArea.getCaretPosition(); compoundEdit = new RCompoundEdit(); compoundEdit.addEdit(edit); addEdit(compoundEdit); return compoundEdit; }
/** * Inserts the selected item into the editor and disposes of this popup. */ private void insertSelectedItem() { Object lvp = list.getSelectedValue(); if (lvp!=null) { listener.uninstallAndHide(); String text = ((LabelValuePair)lvp).value; textArea.replaceSelection(text); ClipboardHistory.get().add(text); // Move this item to the top } }
@Override public void setRoundedSelectionEdges(boolean rounded) { if (getRoundedSelectionEdges()!=rounded) { markAllHighlightPainter.setRoundedEdges(rounded); super.setRoundedSelectionEdges(rounded); // Fires event. } }
/** * Toggles whether or not line numbers are visible. * * @param enabled Whether or not line numbers should be visible. * @see #getLineNumbersEnabled() */ public void setLineNumbersEnabled(boolean enabled) { gutter.setLineNumbersEnabled(enabled); checkGutterVisibility(); }
if (scrollPane.isWheelScrollingEnabled() && e.getWheelRotation() != 0) { JScrollBar toScroll = scrollPane.getVerticalScrollBar(); int direction = e.getWheelRotation() < 0 ? -1 : 1; int orientation = SwingConstants.VERTICAL; if (toScroll == null || !toScroll.isVisible()) { toScroll = scrollPane.getHorizontalScrollBar(); if (toScroll == null || !toScroll.isVisible()) { return; JViewport vp = scrollPane.getViewport(); if (vp == null) { return;
/** * Called when this component is removed from the view hierarchy. */ @Override public void removeNotify() { super.removeNotify(); if (textArea!=null) { l.uninstall(textArea); } }
/** * Adds an action event to the current macro. This shouldn't be called * directly, as it is called by the actions themselves. * * @param id The ID of the recordable text action. * @param actionCommand The "command" of the action event passed to it. */ static synchronized void addToCurrentMacro(String id, String actionCommand) { currentMacro.addMacroRecord(new Macro.MacroRecord(id, actionCommand)); }
/** * Returns whether this caret's selection uses rounded edges. * * @return Whether this caret's edges are rounded. * @see #setRoundedSelectionEdges */ public boolean getRoundedSelectionEdges() { return ((ChangeableHighlightPainter)getSelectionPainter()). getRoundedEdges(); }
@Override public void run() { JScrollBar verticalScrollbar = scrollPane.getVerticalScrollBar(); if (verticalScrollbar == null) return; int scrollMax = verticalScrollbar.getMaximum() - verticalScrollbar.getMinimum(); long newScrollValue = Math.round(position * scrollMax) + verticalScrollbar.getMinimum(); if (newScrollValue < verticalScrollbar.getMinimum()) newScrollValue = verticalScrollbar.getMinimum(); if (newScrollValue > verticalScrollbar.getMaximum()) newScrollValue = verticalScrollbar.getMaximum(); verticalScrollbar.setValue((int) newScrollValue); } });
@Override public void actionPerformed(ActionEvent e) { if (textField.getText().length() == 0) return; RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea(); if (pane == null) return; SearchContext context = new SearchContext(); context.setSearchFor(textField.getText()); context.setMatchCase(mcase.isSelected()); context.setRegularExpression(regex.isSelected()); context.setSearchForward(direction); context.setWholeWord(wholew.isSelected()); if (!SearchEngine.find(pane, context).wasFound()) { if (wrap.isSelected()) { pane.setSelectionStart(0); pane.setSelectionEnd(0); } else { mainWindow.getLabel().setText("Search Complete"); } } }
private Component makeCell(JNode node, int column) { if (column == 0) { JLabel label = new JLabel(node.makeLongString() + " ", node.getIcon(), SwingConstants.LEFT); label.setFont(font); label.setOpaque(true); label.setToolTipText(label.getText()); return label; } if (!node.hasDescString()) { return emptyLabel; } RSyntaxTextArea textArea = CodeArea.getDefaultArea(mainWindow); textArea.setLayout(new GridLayout(1, 1)); textArea.setEditable(false); textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); textArea.setText(" " + node.makeDescString()); textArea.setRows(1); textArea.setColumns(textArea.getText().length() + 1); if (highlightText != null) { SearchContext searchContext = new SearchContext(highlightText); searchContext.setMatchCase(!highlightTextCaseInsensitive); searchContext.setMarkAll(true); SearchEngine.markAll(textArea, searchContext); } return textArea; }
public RSyntaxTextArea getCurrentTextArea() { RSyntaxTextArea currentTextArea = null; try { int pos = house.getSelectedIndex(); System.out.println(pos); if (pos >= 0) { RTextScrollPane co = (RTextScrollPane) house.getComponentAt(pos); currentTextArea = (RSyntaxTextArea) co.getViewport().getView(); } } catch (Exception e1) { Luyten.showExceptionDialog("Exception!", e1); } if (currentTextArea == null) { getLabel().setText("No open tab"); } return currentTextArea; }
boolean wholeWord = wholeWordCB.isSelected(); SearchContext context = new SearchContext(); context.setSearchFor(searchText); context.setMatchCase(matchCase); context.setRegularExpression(regex); context.setSearchForward(forward); context.setWholeWord(wholeWord); context.setMarkAll(markAllCB.isSelected()); SearchResult result = SearchEngine.find(rTextArea, context); if (!result.wasFound()) { int pos = SearchEngine.getNextMatchPos(searchText, rTextArea.getText(), forward, matchCase, wholeWord); if (pos != -1) { rTextArea.setCaretPosition(forward ? 0 : rTextArea.getDocument().getLength() - 1);