editors.md: editor events

This commit is contained in:
Yann Cébron 2025-05-14 11:01:36 +02:00
parent c6f993ccb3
commit 25ce1b59af

View File

@ -1,10 +1,11 @@
<!-- Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. --> <!-- Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
# Editors # Editors
<link-summary>The Editors section overview.</link-summary> <link-summary>The Editors section overview.</link-summary>
This section covers working with text in the IntelliJ Platform editor. This section covers working with text in the IntelliJ Platform editor:
* [](editor_basics.md) * [](editor_basics.md)
* [](text_selection.md) * [](text_selection.md)
* [](multiple_carets.md) * [](multiple_carets.md)
@ -19,6 +20,12 @@ From an [Action's `DataContext`](action_system.md#determining-the-action-context
For a given PSI Element, use [`PsiEditorUtil.findEditor()`](%gh-ic%/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java) For a given PSI Element, use [`PsiEditorUtil.findEditor()`](%gh-ic%/platform/editor-ui-api/src/com/intellij/psi/util/PsiEditorUtil.java)
### How can I be notified about editor events?
Use project-level listener [`FileEditorManagerListener`](%gh-ic%/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java)
or [`FileEditorManagerListener$Before`](%gh-ic%/platform/analysis-api/src/com/intellij/openapi/fileEditor/FileEditorManagerListener.java)
to be notified about all file open/closed/selection changed events.
### How do I open an text editor for a "fake" file? ### How do I open an text editor for a "fake" file?
Create a [`LightVirtualFile`](%gh-ic%/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java) with the contents Create a [`LightVirtualFile`](%gh-ic%/platform/core-api/src/com/intellij/testFramework/LightVirtualFile.java) with the contents