Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Document map #339

Closed
pkulchenko opened this Issue · 29 comments

4 participants

@pkulchenko
Owner

Add document map (similar to Document Map in Notepad++ and Minimap in Sublime Text)

@pkulchenko pkulchenko self-assigned this
@pkulchenko pkulchenko added the Feature label
@pkulchenko
Owner

This is now available as Document Map plugin.

Couple of notes:

  • Enable document map by going to View | Document Map Window.
  • The scrolling works as in Sublime Text, not as in Notepad; the position of the shaded area follows the position of the scrollbar.
  • The last line sometimes is not shown in the map. Not sure yet what's causing it, but seems like a Scintilla issue and most likely not fixable on my side.
  • Lines in the document map are not wrapped, which means that it may display different number of lines, depending on how they are wrapped in the editor tab.
  • The current line is shown on the document map as well, using the same style/color as in the editor tab.
  • The map can be detached and positioned anywhere in the IDE; for example, you can make it longer than the editor height.
  • You can change the default zoom level by setting documentmap = {zoom = -7} (this is default).
  • It's been seen to crash in some cases on Ubuntu 12.04 64bit; I'm investigating...

Feedback welcome!

@naturally-intelligent

A nice feature, thanks! Good attempt, should come in handy.

Suggestions:

  • Can the vertical line spacing be shrunk? Might pack more in that way. The usefulness increases the more you can see at once.
  • I realize this relies on matching the font of the file, but maybe the ability to set the map font would help, since there may be better fonts for tiny sizes. Basically at that level we (I) don't need to see what it says, just the colors and "shapes" of the code...

Just as a note, it's neat to see big ASCII text on this pane, like generated here: http://patorjk.com/software/taag, you can use these to comment sections of a file with visibility in the map in mind.

@pkulchenko
Owner

Dave, good suggestions; I can't reduce the vertical spacing (can only add more), but I can definitely let the font to be configurable (both the font name and the size). Just need to expose some API calls; probably tomorrow.

Interesting idea on ASCII text generator ;).

@hollunder

Hi Paul,
I still get the assertion errors with 0.13. My distribution is Arch Linux and I use wxgtk 3.0, but there was something not quite right there. You helped me to get it to work at all using some hack, so maybe it is related to that.

@pkulchenko
Owner

@hollunder, thank you for the details. You are right, it should be 0.13 (0.14 is something I'm working on that hasn't been pushed yet). Can you try commenting out CaptureMouse and ReleaseMouse calls to see if this changes something? It should still work and I expect the errors to go away.

@hollunder

Thanks Paul. I commented out the three calls (one capture, two release). The assertion failures no longer occur, the document map seems to work fine so far.
I think I'll need some time to test it properly and make suggestions on how to improve it.

@pkulchenko
Owner

@hollunder; thank you for checking! Sounds good; please post your suggestions, if any. I'll push an update soon that includes these changes and should also improve scrolling on Linux and OSX as it occasionally seems to be behind the cursor.

@pkulchenko
Owner

If you are testing this plugin, make sure to use the latest ZeroBrane Studio (with at least c493f62 commit) as the plugin relies on some new API.

@hollunder

Hi Paul.
I'm not sure how useful it would be but I'd like to try the following: Have the document map show the whole document, no matter how long or wide it is, even though this could mean that the writing becomes incredibly small. The idea is to have a complete overview. Is this possible without too much work?

@pkulchenko
Owner

It's possible to some degree as you can set the zoom level to -10, but this is the smallest Scintilla can support and if it's still too large to display the entire file, there is not much I can do. I can tweak it a bit so it changes between the initial value (-7) and the smallest one (-10) depending on how large your file is, but not sure how useful that would be. Need to try. You can try that as well by setting zoom to -10 to see how that works for you.

I still need to fix the scrolling on OSX/Linux as I can't (yet) get it to work so that the mouse doesn't get outside the shaded area...

@hollunder

Ok, too bad, I thought it could be nice to give an idea how large the file is and an overview of the structure. I guess for people with more screen estate or shorter files this is already the case with -10.

@srdjan-m

I am getting the following error repeated 4 times on editor startup:
onEditorFocusSet event failed: src/editor/style.lua:110: bad argument #1 to 'unpack' (table expected, got nil)
Document map is blank.
It happens with the latest updates of ZB and the plugin.

@pkulchenko
Owner

@srdjan-m, strange; it seems like one of the colors is not set in your case. Just to confirm this, can you check the following values from the Local console and show me the output:

ide:GetConfig().styles.text, ide:GetConfig().styles.sel, ide:GetConfig().styles.caretlinebg

I get the following (with the default style):

{bg = {250, 250, 250}, fg = {64, 64, 64}} --[[table: 0x025c2f38]]   {bg = {208, 208, 208}} --[[table: 0x025c3398]]  {bg = {240, 240, 230}} --[[table: 0x025c34f8]]

You may be using a different color scheme with different values; I can provide defaults, but would like to confirm that this is indeed the issue.

@srdjan-m

I am getting this:
{fn = "Menlo Regular", fs = 12} --[[table: 0x046d94f8]] {bg = {192, 192, 192}} --[[table: 0x046d8bb8]] {bg = {255, 255, 204}} --[[table: 0x046d8c78]]

@pkulchenko
Owner

{fn = "Menlo Regular", fs = 12}

It seems like the default value for text has been overwritten without setting new values for fg/bg. Do you se styles.text in the config (user.lua)?

@srdjan-m

Ok, I added fg and bg values and it works now.

@pkulchenko
Owner

Yes, this would fix the issue, but I'm interested why you don't have those values; maybe I need to provide default values in the plugin. Did you change them (before) in the config?

@srdjan-m

Yes, I have my small config file.
Someone else will do the same too so having default font values is not a bad idea.

One small thing:
There is a jump when dragging of map starts. It looks like center of map jumps to the cursor y pos as soon as I start to drag. This happens when I start dragging from the top of the file. When dragging from positions other than top map jumps too but with different offset...I am on mac 10.9...

@pkulchenko
Owner

I'll set the default and will check on the jump. I'm still working on scrolling improvements. Just to confirm, you are using the latest version of docmap (0.19)?

@srdjan-m

Yes, it is 0.19.
I just noticed one more thing: I can't type anything after I drag the map. Editor must be restarted in order to work again.

@pkulchenko
Owner

Maybe the editor tab doesn't get the focus? I've tested on all supported platforms, but not the most recent version; will check again. Can you type the text after you click on the editor tab?

@srdjan-m

No, I can't type anything in the editor. But if I switch to other tabs - editor works.
Unfortunately, switching back to 'locked' tab doesn't help. Typing is not possible util I restart the editor.

That reminded me that I noticed that editor also doesn't work when Corona simulator is active. Stopping the simulator returns the editor to normal. Is this expected behaviour?

@pkulchenko
Owner

switching back to 'locked' tab doesn't help. Typing is not possible util I restart the editor.

@srdjan-m, you are right; I think this is the result of a defect in wxwidgets that doesn't generate "kill focus" event, which makes the editor to keep its read-only status. I'll put a workaround in place.

That reminded me that I noticed that editor also doesn't work when Corona simulator is active. Stopping the simulator returns the editor to normal. Is this expected behaviour?

Only when debugging. The editor tabs are switched to read-only mode in that case. If you are "running" instead of debugging, then you should still be able to edit in the editor tabs.

@pkulchenko
Owner

@srdjan-m, pushed several updates to the DocumentMap plugin that should fix all issues on OSX, including jumps. You'll need the latest ZBS as well.

@srdjan-m

So far, everything works fine. Really cool feature.
Thank you.

@srdjan-m

Sorry Paul,
That focus issue is still here. Dragging minimap moves focus from editor permanently...
I could swear that it worked yesterday...

@pkulchenko
Owner

Hm, I could swear it worked for me as well. Puzzling... I have another workaround for those KILL_FOCUS events; give me a bit of time.

@pkulchenko
Owner

@srdjan-m, give it another try. Should be fixed for good.

@srdjan-m

Using it...no problems so far. Looks like you squashed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.