Custom editor - inline text, click+drag line folding.

I'm fairly new to IntelliJ, and very new to Plugin development. I might be asking about things that have already been implemented or posted (I searched), and if so I apologize. Basically, I'm wondering which openapi classes to get started with.

I want to make an editor with all the editing capabilities/features of the build-in editor (highlighting, inspection, etc.), plus some additional functionality. I want persistent text (comments) that will appear inline, without changing the underlying file. I also want to click a line number, drag it, and fold all the lines dragged over. Reverse to unfold.

For the first bit, I could probably get the original Document, combine it with editor state info to make another Document, and write changes through as appropriate. However, I want line numbers to ignore my special text, and I don't think that's possible with the default editor.

For click-drag, I don't think I can use the default editor at all, since line numbers aren't selectable...

Ideally, what I want is to take the default editor, with its default rendering, chop the rendered display into pieces, and hide/intersperse those as necessary. I'm fairly sure that's impossible, though. Can I use the editor, but just change its rendering? I want to change as little as possible, since I can't tell from the API documentation what behavior is inherited by any editor, and what behavior is implemented in the default editor.



I also have some more questions, about Go To Implementation, and a possible Go Back operation... should I post those in a separate thread?

2 comments
Comment actions Permalink

Hello ehecht,

I'm fairly new to IntelliJ, and very new to Plugin development. I
might be asking about things that have already been implemented or
posted (I searched), and if so I apologize. Basically, I'm wondering
which openapi classes to get started with.

I want to make an editor with all the editing capabilities/features of
the build-in editor (highlighting, inspection, etc.), plus some
additional functionality. I want persistent text (comments) that will
appear inline, without changing the underlying file.


The only way to achieve this in the current version of IDEA is to show persistent
text using collapsed fold regions. See the Camouflage plugin for an inspiration
(its source should be available somewhere as well):
http://plugins.intellij.net/plugin/?id=57

I also want to
click a line number, drag it, and fold all the lines dragged over.
Reverse to unfold.


You can file a JIRA issue requesting to add a mouse events listener for the
line numbers area.

For the first bit, I could probably get the original Document, combine
it with editor state info to make another Document, and write changes
through as appropriate. However, I want line numbers to ignore my
special text, and I don't think that's possible with the default
editor.

For click-drag, I don't think I can use the default editor at all,
since line numbers aren't selectable...

Ideally, what I want is to take the default editor, with its default
rendering, chop the rendered display into pieces, and hide/intersperse
those as necessary. I'm fairly sure that's impossible, though. Can I
use the editor, but just change its rendering? I want to change as
little as possible, since I can't tell from the API documentation what
behavior is inherited by any editor, and what behavior is implemented
in the default editor.


If you do want to rewrite our editor, you're on your own. The rendering of
the editor is not customizable on the level you want.

I also have some more questions, about Go To Implementation, and a
possible Go Back operation... should I post those in a separate
thread?


Yes, probably. Note that there is a "Go Back" operation already (Ctrl-Alt-Left).

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks for your help.

I got the Camouflage plugin, but couldn't find any source for it... also, the author mentioned difficulties with persistence in the release notes. I'll research collapsed fold regions to see if they provide the functionality I need.

I filed the JIRA issue, correctly I hope:
http://www.jetbrains.net/jira/browse/IDEA-19258

Rewriting the Editor would be very time-consuming and difficult, so I'll see if I can do what I want without it. Hopefully fold regions will solve the problem.

I've written a Go To/Go Back plugin that I think is fairly useful, I'll post in the Plugins forum if/when I get permission to release it.

(I don't know how to interweave this reply with the previous one...)

0

Please sign in to leave a comment.