How to add an inline input field to editor?

Answered

How to add an inline input field to editor? Between two lines of code, not an input dialog.
Thank you very much for any help!

1
1 comment

Hi,

You can use Component Inlay API:
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/editor/ComponentInlay.kt

Please note that this API is experimental and may change in the future without preserving backward compatibility.

Also, if you decide to use it, please note that when your component is added to the editor, all actions executed in your component will be executed in the hosting editor.

For example, using up/down/left/right arrows, your component will move caret out of the component to the editor. This can be prevented by implementing DataProvider by your component and wrapping it into TextComponentEditorImpl in case the editor data is requested:

Object getData(@NotNull @NonNls String dataId) {
   if (CommonDataKeys.EDITOR.is(dataId)) {
     return new TextComponentEditorImpl(project, this);
   }
   return null;
}
0

Please sign in to leave a comment.