/** * Sets the selection start. The new selection will be the new * selection start and the old selection end. * @param selectionStart The selection start * @see #select(int,int) */ public final void setSelectionStart(int selectionStart) { select(selectionStart,selectionEnd); }
/** * Sets the selection end. The new selection will be the old * selection start and the bew selection end. * @param selectionEnd The selection end * @see #select(int,int) */ public final void setSelectionEnd(int selectionEnd) { select(selectionStart,selectionEnd); }
/** * Sets the caret position. The new selection will consist of the * caret position only (hence no text will be selected) * @param caret The caret position * @see #select(int,int) */ public final void setCaretPosition(int caret) { select(caret,caret); }
/** * Selects all text in the document. */ public final void selectAll() { select(0,getDocumentLength()); }
public void redo() throws CannotRedoException { super.redo(); select(start,end); }
public void undo() throws CannotUndoException { super.undo(); select(start,end); }
private void doSingleClick(MouseEvent evt, int line, int offset, int dot) { if((evt.getModifiers() & InputEvent.SHIFT_MASK) != 0) { rectSelect = (evt.getModifiers() & InputEvent.CTRL_MASK) != 0; select(getMarkPosition(),dot); } else setCaretPosition(dot); }
private void doTripleClick(MouseEvent evt, int line, int offset, int dot) { select(getLineStartOffset(line),getLineEndOffset(line)-1); } }
/** * Moves the mark to the caret position. */ public final void selectNone() { select(getCaretPosition(),getCaretPosition()); }
public void mouseDragged(MouseEvent evt) { if(popup != null && popup.isVisible()) return; setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0); select(getMarkPosition(),xyToOffset(evt.getX(),evt.getY())); }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); if(select) textArea.select(textArea.getMarkPosition(),0); else textArea.setCaretPosition(0); } }
public void insertUpdate(DocumentEvent evt) { documentChanged(evt); int offset = evt.getOffset(); int length = evt.getLength(); int newStart; int newEnd; if(selectionStart > offset || (selectionStart == selectionEnd && selectionStart == offset)) newStart = selectionStart + length; else newStart = selectionStart; if(selectionEnd >= offset) newEnd = selectionEnd + length; else newEnd = selectionEnd; select(newStart,newEnd); }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int caret = textArea.getCaretPosition(); if(caret == 0) { textArea.getToolkit().beep(); return; } if(select) textArea.select(textArea.getMarkPosition(), caret - 1); else textArea.setCaretPosition(caret - 1); } }
/** * Sets the document this text area is editing. * @param document The document */ public void setDocument(SyntaxDocument document) { if(this.document == document) return; if(this.document != null) this.document.removeDocumentListener(documentHandler); this.document = document; document.addDocumentListener(documentHandler); select(0,0); updateScrollBars(); painter.repaint(); }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); if(select) textArea.select(textArea.getMarkPosition(), textArea.getDocumentLength()); else textArea.setCaretPosition(textArea .getDocumentLength()); } }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int caret = textArea.getCaretPosition(); if(caret == textArea.getDocumentLength()) { textArea.getToolkit().beep(); return; } if(select) textArea.select(textArea.getMarkPosition(), caret + 1); else textArea.setCaretPosition(caret + 1); } }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int firstLine = textArea.getFirstLine(); int visibleLines = textArea.getVisibleLines(); int line = textArea.getCaretLine(); if(firstLine < visibleLines) firstLine = visibleLines; textArea.setFirstLine(firstLine - visibleLines); int caret = textArea.getLineStartOffset( Math.max(0,line - visibleLines)); if(select) textArea.select(textArea.getMarkPosition(),caret); else textArea.setCaretPosition(caret); } }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int lineCount = textArea.getLineCount(); int firstLine = textArea.getFirstLine(); int visibleLines = textArea.getVisibleLines(); int line = textArea.getCaretLine(); firstLine += visibleLines; if(firstLine + visibleLines >= lineCount - 1) firstLine = lineCount - visibleLines; textArea.setFirstLine(firstLine); int caret = textArea.getLineStartOffset( Math.min(textArea.getLineCount() - 1, line + visibleLines)); if(select) textArea.select(textArea.getMarkPosition(),caret); else textArea.setCaretPosition(caret); } }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int caret = textArea.getCaretPosition(); int line = textArea.getCaretLine(); int lineStart = textArea.getLineStartOffset(line); caret -= lineStart; String lineText = textArea.getLineText(textArea .getCaretLine()); if(caret == lineText.length()) { if(lineStart + caret == textArea.getDocumentLength()) { textArea.getToolkit().beep(); return; } caret++; } else { String noWordSep = (String)textArea.getDocument().getProperty("noWordSep"); caret = TextUtilities.findWordEnd(lineText,caret,noWordSep); } if(select) textArea.select(textArea.getMarkPosition(), lineStart + caret); else textArea.setCaretPosition(lineStart + caret); } }
public void actionPerformed(ActionEvent evt) { JEditTextArea textArea = getTextArea(evt); int caret = textArea.getCaretPosition(); int line = textArea.getCaretLine(); if(line == 0) { textArea.getToolkit().beep(); return; } int magic = textArea.getMagicCaretPosition(); if(magic == -1) { magic = textArea.offsetToX(line, caret - textArea.getLineStartOffset(line)); } caret = textArea.getLineStartOffset(line - 1) + textArea.xToOffset(line - 1,magic); if(select) textArea.select(textArea.getMarkPosition(),caret); else textArea.setCaretPosition(caret); textArea.setMagicCaretPosition(magic); } }