本文整理汇总了Java中com.intellij.openapi.editor.EditorModificationUtil.deleteSelectedText方法的典型用法代码示例。如果您正苦于以下问题:Java EditorModificationUtil.deleteSelectedText方法的具体用法?Java EditorModificationUtil.deleteSelectedText怎么用?Java EditorModificationUtil.deleteSelectedText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.EditorModificationUtil
的用法示例。
在下文中一共展示了EditorModificationUtil.deleteSelectedText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeWriteAction
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
@Override
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
CommandProcessor.getInstance().setCurrentCommandGroupId(EditorActionUtil.DELETE_COMMAND_GROUP);
CopyPasteManager.getInstance().stopKillRings();
boolean camelMode = editor.getSettings().isCamelWords();
if (myNegateCamelMode) {
camelMode = !camelMode;
}
if (editor.getSelectionModel().hasSelection()) {
EditorModificationUtil.deleteSelectedText(editor);
return;
}
deleteToWordEnd(editor, camelMode);
}
示例2: deleteToTargetPosition
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
public static void deleteToTargetPosition(@NotNull Editor editor, @NotNull LogicalPosition pos) {
LogicalPosition logicalPosition = editor.getCaretModel().getLogicalPosition();
if (logicalPosition.line != pos.line) {
LOGGER.error("Unexpected caret position: " + logicalPosition + ", target indent position: " + pos);
return;
}
if (pos.column < logicalPosition.column) {
int targetOffset = editor.logicalPositionToOffset(pos);
int offset = editor.getCaretModel().getOffset();
editor.getSelectionModel().setSelection(targetOffset, offset);
EditorModificationUtil.deleteSelectedText(editor);
}
else if (pos.column > logicalPosition.column) {
EditorModificationUtil.insertStringAtCaret(editor, StringUtil.repeatSymbol(' ', pos.column - logicalPosition.column));
}
}
示例3: afterJump
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
@Override
public void afterJump() {
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (inSameEditor()) {
selectJumpArea();
_se.getSelectionModel().copySelectionToClipboard();
EditorModificationUtil.deleteSelectedText(_se);
_se.getSelectionModel().removeSelection();
}
}
};
AppUtil.runWriteAction(runnable, _se);
}
示例4: charDeleted
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
public boolean charDeleted(final char c, @NotNull final PsiFile file, @NotNull final Editor editor) {
if (myTargetPosition != null) {
final int offset = editor.getCaretModel().getOffset();
editor.getSelectionModel().setSelection(offset - editor.getCaretModel().getVisualPosition().column + myTargetPosition.column, offset);
EditorModificationUtil.deleteSelectedText(editor);
editor.getCaretModel().moveToLogicalPosition(myTargetPosition);
myTargetPosition = null;
return true;
}
return false;
}
示例5: executeWriteAction
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
@Override
public void executeWriteAction(Editor editor, DataContext dataContext) {
if(!editor.getSelectionModel().hasSelection()) {
if (Registry.is(CopyAction.SKIP_COPY_AND_CUT_FOR_EMPTY_SELECTION_KEY)) {
return;
}
editor.getSelectionModel().selectLineAtCaret();
}
editor.getSelectionModel().copySelectionToClipboard();
EditorModificationUtil.deleteSelectedText(editor);
}
示例6: makeOneSpaceBetween
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
private void makeOneSpaceBetween(final int begin, final int end) {
Runnable runnable = new Runnable() {
@Override
public void run() {
_editor.getSelectionModel().setSelection(begin, end);
EditorModificationUtil.deleteSelectedText(_editor);
EditorModificationUtil.insertStringAtCaret(_editor, " ");
}
};
AppUtil.runWriteAction(runnable, _editor);
}
示例7: cutSelection
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
private void cutSelection() {
Runnable cutRunnable = new Runnable() {
@Override
public void run() {
_editor.getSelectionModel().copySelectionToClipboard();
EditorModificationUtil.deleteSelectedText(_editor);
}
};
AppUtil.runWriteAction(cutRunnable, _editor);
}
示例8: deleteToTargetPosition
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
public static void deleteToTargetPosition(@Nonnull Editor editor, @Nonnull LogicalPosition pos) {
final int offset = editor.getCaretModel().getOffset();
final int targetOffset = editor.logicalPositionToOffset(pos);
editor.getSelectionModel().setSelection(targetOffset, offset);
EditorModificationUtil.deleteSelectedText(editor);
editor.getCaretModel().moveToLogicalPosition(pos);
}
示例9: executeWriteAction
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
@Override
public void executeWriteAction(Editor editor, DataContext dataContext) {
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editor.getContentComponent()));
if (project == null) {
if (myOriginalHandler != null) {
myOriginalHandler.execute(editor, dataContext);
}
return;
}
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == null) {
if (myOriginalHandler != null) {
myOriginalHandler.execute(editor, dataContext);
}
return;
}
SelectionModel selectionModel = editor.getSelectionModel();
if (!selectionModel.hasSelection() && !selectionModel.hasBlockSelection()) {
if (Registry.is(CopyAction.SKIP_COPY_AND_CUT_FOR_EMPTY_SELECTION_KEY)) {
return;
}
selectionModel.selectLineAtCaret();
if (!selectionModel.hasSelection()) return;
}
int start = selectionModel.getSelectionStart();
int end = selectionModel.getSelectionEnd();
EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_COPY).execute(editor, dataContext);
if (start != end) {
// There is a possible case that 'sticky selection' is active. It's automatically removed on copying then, so, we explicitly
// remove the text.
editor.getDocument().deleteString(start, end);
}
else {
EditorModificationUtil.deleteSelectedText(editor);
}
}
示例10: deleteRange
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
public static void deleteRange(Class<? extends Selector> selectorClass, Editor editor) {
selectRangeOf(selectorClass, editor);
EditorModificationUtil.deleteSelectedText(editor);
}
示例11: afterJump
import com.intellij.openapi.editor.EditorModificationUtil; //导入方法依赖的package包/类
@Override
public void afterJump() {
final Runnable runnable = new Runnable() {
@Override
public void run() {
TextRange sourceRange = EditorUtils.getRangeOf(_selectorClass, _te);
if (inSameEditor()) {
boolean noNeedToMove = sourceRange.contains(_soff);
if (noNeedToMove) {
_se.getCaretModel().moveToOffset(_soff);
return;
}
}
int textSourceStartOffset = sourceRange.getStartOffset();
EditorUtils.copyRange(_selectorClass, _te);
if ( !inSameEditor() || textSourceStartOffset > _soff) {
deleteTextSource(_te);
pasteClipboardToOffset();
} else {
pasteClipboardToOffset();
focusTargetCaret();
deleteTextSource(_te);
focusSourceCaret();
int cur_offset = _se.getCaretModel().getOffset();
if (_config._needSelectTextAfterJump) {
EditorUtils.selectTextRange(_se, cur_offset - _length, cur_offset);
}
}
}
private void deleteTextSource(Editor editor) {
EditorUtils.selectRangeOf(_selectorClass, editor);
EditorModificationUtil.deleteSelectedText(editor);
}
private void pasteClipboardToOffset() {
focusSourceCaret();
TextRange[] tr = EditorCopyPasteHelperImpl.getInstance().pasteFromClipboard(_se);
if (_config._needSelectTextAfterJump) {
EditorUtils.selectTextRange(_se, tr);
}
_length = tr[0].getEndOffset() - tr[0].getStartOffset();
}
};
AppUtil.runWriteAction(runnable, _se);
}