use of com.intellij.find.EditorSearchSession in project intellij-community by JetBrains.
the class HighlightUsagesHandler method doRangeHighlighting.
private static void doRangeHighlighting(Editor editor, Project project) {
if (!editor.getSelectionModel().hasSelection())
return;
final String text = editor.getSelectionModel().getSelectedText();
if (text == null)
return;
if (editor instanceof EditorWindow) {
// highlight selection in the whole editor, not injected fragment only
editor = ((EditorWindow) editor).getDelegate();
}
EditorSearchSession oldSearch = EditorSearchSession.get(editor);
if (oldSearch != null) {
if (oldSearch.hasMatches()) {
String oldText = oldSearch.getTextInField();
if (!oldSearch.getFindModel().isRegularExpressions()) {
oldText = StringUtil.escapeToRegexp(oldText);
oldSearch.getFindModel().setRegularExpressions(true);
}
String newText = oldText + '|' + StringUtil.escapeToRegexp(text);
oldSearch.setTextInField(newText);
return;
}
}
EditorSearchSession.start(editor, project).getFindModel().setRegularExpressions(false);
}
use of com.intellij.find.EditorSearchSession in project intellij-community by JetBrains.
the class FindAllAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
Editor editor = e.getRequiredData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
if (project.isDisposed())
return;
FindModel oldModel = FindManager.getInstance(project).getFindInFileModel();
FindModel newModel = oldModel.clone();
String text = search.getTextInField();
if (StringUtil.isEmpty(text))
return;
newModel.setStringToFind(text);
FindUtil.findAllAndShow(project, editor, newModel);
}
use of com.intellij.find.EditorSearchSession in project intellij-community by JetBrains.
the class RestorePreviousSettingsAction method update.
@Override
public void update(AnActionEvent e) {
Project project = e.getProject();
EditorSearchSession search = e.getData(EditorSearchSession.SESSION_KEY);
e.getPresentation().setEnabled(project != null && search != null && !project.isDisposed() && search.getTextInField().isEmpty() && FindManager.getInstance(project).getPreviousFindModel() != null);
}
use of com.intellij.find.EditorSearchSession in project intellij-community by JetBrains.
the class SelectAllAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
search.selectAllOccurrences();
search.close();
}
use of com.intellij.find.EditorSearchSession in project intellij-community by JetBrains.
the class SwitchToFind method update.
@Override
public void update(AnActionEvent e) {
if (KeymapUtil.isEmacsKeymap()) {
// Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that
// activates 'incremental search'. Hence, we do the similar hack here for them.
ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT).update(e);
} else {
EditorSearchSession search = e.getData(EditorSearchSession.SESSION_KEY);
e.getPresentation().setEnabledAndVisible(search != null);
}
}
Aggregations