public void handleEvent( Event e ) { text.setCaretOffset( -1 ); while ( findText() ) { replaceText(); } } } );
public void dragOver( DropTargetEvent e ) { styledText.setFocus(); Point location = xParent.getDisplay().map( null, styledText, e.x, e.y ); location.x = Math.max( 0, location.x ); location.y = Math.max( 0, location.y ); try { int offset = styledText.getOffsetAtLocation( new Point( location.x, location.y ) ); styledText.setCaretOffset( offset ); } catch ( IllegalArgumentException ex ) { int maxOffset = styledText.getCharCount(); Point maxLocation = styledText.getLocationAtOffset( maxOffset ); if ( location.y >= maxLocation.y ) { if ( location.x >= maxLocation.x ) { styledText.setCaretOffset( maxOffset ); } else { int offset = styledText.getOffsetAtLocation( new Point( location.x, maxLocation.y ) ); styledText.setCaretOffset( offset ); } } else { styledText.setCaretOffset( maxOffset ); } } }
private void redo() { if ( redoStack.size() > 0 ) { UndoRedoStack urs = redoStack.remove( 0 ); if ( undoStack.size() == MAX_STACK_SIZE ) { undoStack.remove( undoStack.size() - 1 ); } UndoRedoStack rro = new UndoRedoStack( urs.getCursorPosition(), urs.getReplacedText(), styledText.getText(), urs .getEventLength(), urs.getType() ); bFullSelection = false; styledText.setText( urs.getReplacedText() ); if ( urs.getType() == UndoRedoStack.INSERT ) { styledText.setCaretOffset( urs.getCursorPosition() ); } else if ( urs.getType() == UndoRedoStack.DELETE ) { styledText.setCaretOffset( urs.getCursorPosition() + urs.getEventLength() ); styledText.setSelection( urs.getCursorPosition(), urs.getCursorPosition() + urs.getEventLength() ); if ( styledText.getSelectionCount() == styledText.getCharCount() ) { bFullSelection = true; } } undoStack.add( 0, rro ); } }
private void printKeyValue(final StyledText styledText,String key, String value) { value += styledText.getLineDelimiter(); StyleRange style = getKeyStyle(); style.start = styledText.getCharCount(); style.length = key.length(); styledText.append(key); styledText.setStyleRange(style); styledText.setCaretOffset(styledText.getCharCount()); styledText.showSelection(); StyleRange style1 = getValueStyle(); style1.start = styledText.getCharCount(); style1.length = value.length(); styledText.append(value); styledText.setStyleRange(style1); styledText.setCaretOffset(styledText.getCharCount()); styledText.showSelection(); }
private void undo() { if ( undoStack.size() > 0 ) { UndoRedoStack urs = undoStack.remove( 0 ); if ( redoStack.size() == MAX_STACK_SIZE ) { redoStack.remove( redoStack.size() - 1 ); } UndoRedoStack rro = new UndoRedoStack( urs.getCursorPosition(), urs.getReplacedText(), styledText.getText(), urs .getEventLength(), urs.getType() ); bFullSelection = false; styledText.setText( urs.getReplacedText() ); if ( urs.getType() == UndoRedoStack.INSERT ) { styledText.setCaretOffset( urs.getCursorPosition() ); } else if ( urs.getType() == UndoRedoStack.DELETE ) { styledText.setCaretOffset( urs.getCursorPosition() + urs.getEventLength() ); styledText.setSelection( urs.getCursorPosition(), urs.getCursorPosition() + urs.getEventLength() ); if ( styledText.getSelectionCount() == styledText.getCharCount() ) { bFullSelection = true; } } redoStack.add( 0, rro ); } }
public void setCaretOffset(AccessibleTextEvent e) { StyledText.this.setCaretOffset(e.offset); e.result = ACC.OK; } public void getSelectionRange(AccessibleTextEvent e) {
@Override public void setCaretOffset(AccessibleTextEvent e) { StyledText.this.setCaretOffset(e.offset); e.result = ACC.OK; } @Override
@Override public void setCaretOffset(AccessibleTextEvent e) { StyledText.this.setCaretOffset(e.offset); e.result = ACC.OK; } @Override
@Override protected void setCaretPosition(final int position) { getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position)); } }
/** * Moves the caret in front of the first character of the widget content. */ void doContentStart() { setCaretOffset(0, SWT.DEFAULT); showCaret(); } /**
@Override protected void setCaretPosition(final int position) { getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position)); } }
/** * Moves the caret in front of the first character of the widget content. */ void doContentStart() { setCaretOffset(0, SWT.DEFAULT); showCaret(); } /**
protected void setCaretPosition(final int position) { getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position)); } }
/** * Moves the caret to the start of the previous word. */ void doSelectionWordPrevious() { int offset = getWordPrevious(caretOffset, SWT.MOVEMENT_WORD); setCaretOffset(offset, OFFSET_LEADING); showCaret(); } /**
/** * Moves the caret to the start of the previous word. */ void doSelectionWordPrevious() { int offset = getWordPrevious(caretOffset, SWT.MOVEMENT_WORD); setCaretOffset(offset, OFFSET_LEADING); showCaret(); } /**
@Override public void mouseScrolled(MouseEvent e) { int caretOffset = fMinimapTextWidget.getOffsetAtPoint(new Point(0, fTopIndexY)); int lineIndex = fMinimapTextWidget.getLineAtOffset(caretOffset); if (e.count > 0) { lineIndex = Math.max(0, lineIndex - NB_LINES_SCROLL); } else { lineIndex = Math.min(fMinimapTextWidget.getCharCount(), lineIndex + NB_LINES_SCROLL); } caretOffset = fMinimapTextWidget.getOffsetAtLine(lineIndex); fMinimapTextWidget.setCaretOffset(caretOffset); }
/** * Moves the caret one character to the left. Do not go to the previous line. * When in a bidi locale and at a R2L character the caret is moved to the * beginning of the R2L segment (visually right) and then one character to the * left (visually left because it's now in a L2R segment). */ void doVisualPrevious() { int offset = getClusterPrevious(caretOffset, getCaretLine()); setCaretOffset(offset, SWT.DEFAULT); showCaret(); } /**
/** * Moves the caret one character to the left. Do not go to the previous line. * When in a bidi locale and at a R2L character the caret is moved to the * beginning of the R2L segment (visually right) and then one character to the * left (visually left because it's now in a L2R segment). */ void doVisualPrevious() { int offset = getClusterPrevious(caretOffset, getCaretLine()); setCaretOffset(offset, SWT.DEFAULT); showCaret(); } /**
/** * Moves the caret one character to the right. Do not go to the next line. * When in a bidi locale and at a R2L character the caret is moved to the * end of the R2L segment (visually left) and then one character to the * right (visually right because it's now in a L2R segment). */ void doVisualNext() { int offset = getClusterNext(caretOffset, getCaretLine()); setCaretOffset(offset, SWT.DEFAULT); showCaret(); } /**
public void run(){ text.append(str); if(autoScroolToBottom){ text.setTopIndex(text.getLineCount() - 1); text.setCaretOffset(text.getText().length()); } } });