[ANN] Code Outline Plugin v0.0.1 (initial release)
I have released the first version of Code Outline Plugin. This plugin shows an outline of your code while you are editing it.
Screenshot is at http://www.intellij.org/twiki/pub/Main/CodeOutline/screenshot.png.
Website and download is at http://www.intellij.org/twiki/bin/view/Main/CodeOutline.
Please sign in to leave a comment.
Cool. It's one of those tools that feels like it should be very useful, but I can't honestly say what for yet. Sometimes those turn out to be the best.
--Dave
Thanks, I feel the same way.
I think eventually it will be very powerful for editing Java when I begin to use PSI for java file editing. I think an obvious improvement would be to highlight the code in each method as a different color, and possibly to show the name of the method above the method body's outline.
In general I would like to make the code outline more dynamic, where each line is not necessarily a line in the editor. What I mean is maybe at a method's definition, in a small font just large enough to read, the method name could be printed, and the same for inner class definitions.
Another feature I want to add would show the outlines of all open files in the tool window, each directly below (vertically) the previous. You could navigate between files by simply clicking on that file's region of the panel. I think people who used to put all of their C/C++ code and classes in just a few files (instead of one class per file) would like this. It might replace the functionality of the tab bar. A problem with this is that many files are too long to fit more than one or two in the panel. I don't know how this would work.
I think a feature that might be cool and might make the outline more useful would be to magnify the code under the cursor (when the mouse is over the code outline, I mean) like the OS X dock does.
The code is very well javadocked, so if anyone wanted to try out implementing this sort of thing, I don't think it should be too hard.
Keith, Cool plugin and I find it useful for positioning the editor once
you get a visual map of the program. I'm having some trouble moving the
viewpane horizontally although vertically it is fine. It follows the
editor scrolling fine but doesn't seem to work too well from the code
outline. Also, can you give us control over the zoom level along with
reasonable defaults?
Thanks,
Jon
Keith
I've wished for this feature for a long time, but was too lazy to write
it myself.
Thanks a lot.
problem:
folded regions are shown expanded, whatever their state is.
request:
Draw a thin blue rectangle.around inner classes
Alain
Thanks, I'm glad you find the plugin useful. Scrolling from the code outline always scrolls to the end of the line that you click. I realize now that you say it, that is probably not what you want if you have a file which is wider than the editor window.
Do you think the cursor should go to the horizontal position that you click as well as the vertical position? This was the original behavior, but I found it took too long to visually find the cursor after clicking, and placing it at the end of the line made it more obvious.
Controllable zoom level is a good idea, and I will add this (probably via Ctrl+Scroll) when the code outline supports scaling/zooming at all (right now, if a file has more lines than the height of the code outline window, it is simply cut off). What kind of zooming would you want? Would 1x/.5x/.25x/.125x/etc. (powers of 1/2) be suitable? Note that 1x would mean "1 pixel in outline = 1 character in editor." Would you want only vertical zooming, or proportional (normal) zooming? Note that when a file is opened, it will automatically zoom so that the entire file is visible.
I'm not yet sure how I'll implement zooming. I'm concerned about speed and memory use. If you think about it, the only way to implement a dynamic view of the file efficiently (with respect to speed) is to keep an image in memory which is as tall and wide as the file, substituting characters for pixels, and then scaling the image as a postprocess.
Requiring that much memory is not desirable, though, as each code outline image is (generally, depending on system) an array of 4-byte integers, 4 bytes per pixel. This would make a complete outline of a file like Pattern.java in the JDK require 2MB of memory.
I think this could be optimized, though, since the code outline itself is grayscale, and actually it's all black, with only opacity varying. The benefit to using the current format (which is simply the format of the display device itself), however, is that the image data can be stored in video memory and copied bit for bit to the display, without any image processing operations. I think this makes the display as fast as it is.
If it could be optimized down to a single byte per pixel, representing opacity, I think maybe 500KB for a file as huge as Pattern.java would be acceptable, and even an 800-line file would be approximately 80KB.
Jon (or anyone else who has any ideas), how do you suggest "scrolling" be done if the file is zoomed such that it is too tall to fit in the code outline panel? I see a few options:
1. The current viewing area will always be in the center of the code outline panel - to scroll to the very top of the file you might have to click at the top of the panel several times.
2. The current viewing area will always be made visible somnehow (but not necessarily in the center), and to scroll to a place in the file which is not shown you must use the scroll wheel.
3. A miniature Swing scrollbar along with automatic scrolling behavior like #1 or #2.
Sorry, but folding regions will probably stay expanded until the request at http://www.intellij.net/tracker/idea/viewSCR?publicId=19935 is implemented.
I plan to do more with editing Java files using PSI, and outlining inner classes will be a good feature to add once I get started on that. I think this will be a whole new level of complexity, using PSI, so I don't think it will be coming too soon.
Keith Lea wrote:
Yes, I was trying to scroll for a section that was wider than the editor.
Well, I think going to the the left side is ok for clicking in a new
areas. But I want to be able to horizontally drag it smoothly. That's
what I was having trouble doing.
Hmm, not sure what the best usability would be for zooming. Would like
to see all the options in action before I decide. ;)
I don't think I like #1. What do the JetBrains think?
Jon
Keith,
Although I never missed such a thing, only taking a look at the
screenshot yet tells me, that I will find it very useful. Thanks so far.
Tom
great plugin ... like the ruby editor i use sometimes
(http://homepage2.nifty.com/sakazuki/rde_e.html) ...
perhaps different coloring for comments, code etc would be great
one small bug ... when used as a floating window the codeoutline window
is not updated if i change to another source-file. in the normal mode
the window is correctly updated.
keep up the cool plugin!
christian koestlin
Keith, one single word will describe my feeling : WWWAAAaaaAAOOooOOOO ;)
That's a really nice idea !
Thank you
Guillaume Laforge
click as well as the vertical position? This was the original behavior, but
I found it took too long to visually find the cursor after clicking, and
placing it at the end of the line made it more obvious.
Please ! Place it at the beginning of the line
I have some long lines, and I dislike when I just see the indentation in my
editor because the cursor is at the end of the line.
Ctrl+Scroll) when the code outline supports scaling/zooming at all (right
now, if a file has more lines than the height of the code outline window, it
is simply cut off). What kind of zooming would you want? Would
1x/.5x/.25x/.125x/etc. (powers of 1/2) be suitable? Note that 1x would mean
"1 pixel in outline = 1 character in editor." Would you want only vertical
zooming, or proportional (normal) zooming? Note that when a file is opened,
it will automatically zoom so that the entire file is visible.
The zooming option is not the most important thing : we need first to scale
the whole file to see it entirely.
like #1 or #2.
I like the idea of a little scrollbar.
Guillaume Laforge
Nifty...I think I'll find it useful as well.
A request: Have an option to have the background color
mimic the editors right gutter colors (does this bar have
a specific name?). For instance, I'd like to be able
to see the diffs and bookmarks from your plugin.
Thanks!
-- Rick
This is pretty cool. I am still playing around with it.
I was wondering, could you put in a an alternate type of preview.
Basically, when your cursor is over in the Outline pane, a popup window would appear over the tabs and show you the code around the line where the cursor is pointing.
I like the preview, except if I want to look at my current code and the code I have my cursor over at the same time, I can do it.
Also, though I am not sure how it would be done, would it be possible to use this to create an editor split. What I mean is that the area of the code that I have my cursor over could be used to split the editor(assuming it is not already) and the position of one of the split windows would stay at the current position and the other would automatically be position to the code that the cursor is hovering over in the outline.
Anyway, a few possible suggestion to add to the flurry of ones that this new pluggin has already generated.
Once again, nicely done.
By the way, the scaled picture should be aligned with the right gutter.
I mean that (if it's possible) the image, once it will be scaled to be
visible in full length of a file, should have the same height and position
as the scroll bar in the editor and as the right gutter.
But I'm afraid it might not be possible to know exactly where to position
the outline :(
Guillaume Laforge
A simple split of the editor window is currently not recognized by the plugin. It sticks with one of the part sand doesn't change with the focus.
Small issue, hopefully.
Cool plugin!
Unfortunately, I don't think color coding will go in until I am able to:
1. Query IDEA for the color of a certain character
2. Be notified when the coloring of a region changes.
As far as I can tell IDEA sort of supports #1 and does not support #2.
Unfortunately, this cannot happen until I am able to add listeners for highlighting/markup regions. I plan to file an SCR about this.
Thanks for the feedback,
I implemented such a tooltip before, but I had problems getting it to look right, and a friend pointed out that the same functionality was there with the Preview Scroll, so I stopped working on it.
Another friend suggested that I perform a "magnification" like the OSX dock, when moving the mouse over code. I'm not sure how this would work internally but I think it would be pretty cool if I could get it to work.
What would you think of double-middle-click opening a new split pane? I don't know if the API for opening a new pane is open, but if it is, I can surely implement it.
I think I know how to fix this and I will address it in the next release. I forgot that you could split editors - I was wondering how a file could have multiple editors open as the API allows :)
I'm not looking forward to implementing such a feature, but I'm sure it's possible somehow, as long as I can get a reference to the JScrollPane or maybe just JScrollBar being used. I don't know if I want this or not, but I may make it an option. Do you edit many files whose code outline is taller than your scrollbar? The way I paint the code outline would make it look funny to stretch files smaller than the window, to fit the entire height of the window. So I think this feature probably won't go in.
Definitely a nice plugin :)
Being able to configure the zoom factor would really be nice. I think making
it an option through an actual tab in the Options->IDE Settings might be the
way to go.
Also, to me the left-click action could be made more intuitive. I'd like to
be able to drag the pink viewpane around by just left-clicking into it and
dragging it around.
Maybe something like:
- left click/release: goto line
- left click/drag/release: move viewpane
I'd like to be able to disable the green highlight line in the editor too. I
care about having a high-level vision through the viewpane, but once I see
stuff in my editor it's just easier to go there directly rather than trying
to use the green line.
With all the things you have in mind I think you won't be able to stay away
from an Options->IDE Settings tab for configuring your plugin :)
Great work.
Vince.
"Keith Lea" <keith@cs.oswego.edu> wrote in message
news:10995853.1067374125468.JavaMail.itn@is.intellij.net...
shows an outline of your code while you are editing it.
>
http://www.intellij.org/twiki/pub/Main/CodeOutline/screenshot.png.
>
http://www.intellij.org/twiki/bin/view/Main/CodeOutline.
don't know if the API for opening a new pane is open, but if it is, I can
surely implement it.
Double-middle-click might be really hard to do for people who don't have a
middle button (think laptop users). I hope you're planning to let people
remap the actions :)
Vince.
That left-click thing is a good idea.
You can disable the green highlight in the Right-click context menu. I decided to use a context menu for configuration instead of IDE options, since there are currently so few options, and my IDE options window is cluttered with plugin options panels, I didn't want to add more.
Interestingly I popped up that context menu a few times but only registered
the Animated Scroll and Refresh. Hmmm.. Need to start paying more attention
to what I'm doing ;)
Vince.
One more request: More functionality for non-Java files. I would think that
showing the highlight and the current view would not need PSI, would it?
Keith Lea wrote:
--
Erb
==============================================================
"Most of you are familiar with the virtues of a programmer.
There are three, of course: laziness, impatience, and hubris."
- Larry Wall
==============================================================
What do you mean more functionality for non-Java files? What do you mean the highlight and current view?