Custom folding in text mode (addFold, session,unfold)

751 views
Skip to first unread message

Fogel

unread,
Aug 18, 2015, 11:02:13 AM8/18/15
to Ajax.org Cloud9 Editor (Ace)



Hi guys,

For a build system application we created a logviewer and we are using it to display our build logs and so far everything work perfectly.

Now I'm trying to implement a feature that fold part of the log depending the section a user wants to look into.

I can easily addFold to the editor session :

 for (var i = 0; i < value.Sections.Section.length; i++) {
                            var rangeFold = new range(parseInt(value.Sections.Section[i].LineNumber), 0, parseInt(value.Sections.Section[i].LineNumber) + parseInt(value.Sections.Section[i].Length), Infinity);
                            ace.edit("editor").getSession().addFold(value.Name, rangeFold);
 }

And the code is folded but when I unfold, the log  I can't fold it back and it seem the folddata disapear from the session.

In the end all the custom folding I'm adding , I would like it to be persistent much like  when fold/unfolding comment in any programming language. (having the +/- on the margin , to fold/unfold)

I'm getting a bit frustrasted trying to figure this out so how I would do that ?

Any help would be appreciated.

thank you very much.

Harutyun Amirjanyan

unread,
Aug 18, 2015, 11:06:48 AM8/18/15
to ace-d...@googlegroups.com
you need to implement cusotm folding with getFoldWidget method see  https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/folding/cstyle.js#L75 

Fogel

unread,
Aug 18, 2015, 2:14:44 PM8/18/15
to Ajax.org Cloud9 Editor (Ace)


Ok I see thank you, once I implement my custom folding mode.

How do I use it ? Call this.$setFolding with it ? 

Harutyun Amirjanyan

unread,
Aug 18, 2015, 2:20:06 PM8/18/15
to ace-d...@googlegroups.com
either call setFolding or if you have a custom mode set foldingRules property on it similar to https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/javascript.js#L48

On Tue, Aug 18, 2015 at 9:21 PM, Fogel <amr...@hotmail.com> wrote:


Ok I see thank you, once I implement my custom folding mode.

How do I use it ? Call this.$setFolding with it ? 

--
You received this message because you are subscribed to the Google Groups "Ajax.org Cloud9 Editor (Ace)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ace-discuss...@googlegroups.com.
To post to this group, send email to ace-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/ace-discuss.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Harutyun Amirjanyan

unread,
Aug 19, 2015, 10:41:32 AM8/19/15
to ace-d...@googlegroups.com
probably you are returning invalid range object, i can't know what exactly you are doing wrong without seeing your code.

Reply all
Reply to author
Forward
0 new messages