Folding, bookmarks, listening for fold events

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Folding, bookmarks, listening for fold events

Postby plaidflannel » Thu Mar 01, 2012 5:06 pm

Another newbie question: I'm experimenting with using RSTA as the editor for a custom language. I use the gutter to display an error icon for each error returned by a parser. I also have a custom FoldParser. Both of these features are working.

What I need now is to combine the two features. In particular, when a fold is collapsed or expanded via a mouse click on a fold icon, I'd like the error icons to disappear, appear, or move accordingly. Currently that does not happen.

Is there an event listener that I can use to catch the fold events? If so, I could move all my error icons accordingly. The FoldManager fires property change events, but apparently these do not include collapse and expand events.

I understand that code folding is a relatively new feature and still subject to further development. Is support for such events contemplated for a future release?
plaidflannel
 
Posts: 8
Joined: Wed Feb 22, 2012 4:02 am

Re: Folding, bookmarks, listening for fold events

Postby robert » Fri Mar 02, 2012 12:35 am

This is a bug, the icons should adjust their positions when folds are collapsed automatically, just like the line numbers do. I'll take a look.
User avatar
robert
 
Posts: 788
Joined: Sat May 10, 2008 5:16 pm

Re: Folding, bookmarks, listening for fold events

Postby robert » Thu Mar 08, 2012 4:48 am

I just pushed a fix for this to Subversion. When you get a a chance, please check it out and make sure it looks good for you. If you still want expand/collapse events fired for some reason, let me know. It would be easy to add, but I'm not sure whether there's a need at the moment.
User avatar
robert
 
Posts: 788
Joined: Sat May 10, 2008 5:16 pm

Re: Folding, bookmarks, listening for fold events

Postby plaidflannel » Sat Mar 10, 2012 2:45 am

Thanks for the rapid response. I had not used Subversion before, but it turned out to be a relatively simple task to install Subclipse and check out the project.

I built the project from the "trunk" source and tried it in my test project. In my main program, I build a JFrame containing an RSTA component. When I invoke pack() on the JFrame before making it visible, I get an exception. Here are the last (top) few lines of the stack trace:

Code: Select all
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
   at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.getPreferredSpan(WrappedSyntaxView.java:394)
   at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1342)
   at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:910)
   at javax.swing.plaf.basic.BasicTextAreaUI.getPreferredSize(BasicTextAreaUI.java:103)
   at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
   at javax.swing.JTextArea.getPreferredSize(JTextArea.java:617)


I'll watch for future releases.
plaidflannel
 
Posts: 8
Joined: Wed Feb 22, 2012 4:02 am

Re: Folding, bookmarks, listening for fold events

Postby robert » Sun Mar 11, 2012 6:11 am

Oops, seems it was broken if your RSTA *started* with line wrap enabled (starting with it disabled and toggling it on worked OK). I've pushed a fix for this; please try again!
User avatar
robert
 
Posts: 788
Joined: Sat May 10, 2008 5:16 pm

Re: Folding, bookmarks, listening for fold events

Postby plaidflannel » Sun Mar 11, 2012 5:56 pm

The new version works for me now: folding hides and shows my error icons in the gutter as expected. Thanks.

As of now, I don't have a need for expand and collapse events. On the other hand, I can imagine that a click on an error icon might be a useful event—it could trigger the display of a detailed error message.
plaidflannel
 
Posts: 8
Joined: Wed Feb 22, 2012 4:02 am

Re: Folding, bookmarks, listening for fold events

Postby robert » Sun Mar 11, 2012 8:31 pm

Yes, the icon area definitely needs more interactivity, even if it's just a simple way to add a MouseListener. FWIW in the next release (currently in SVN) you can customize the Gutter's components (icon row header, line number list, and fold indicator) since they're created via createXXX() in RSyntaxTextAreaEditorKit, so there is a hook available that wasn't there previously for something like MouseListener. But there's currently nothing nice and clean like "IconRowHeader.addIconClickListener(...)". This is definitely something to consider for a future release though.
User avatar
robert
 
Posts: 788
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests