Fold ini and inf files

Discuss syntax highlighting or submit new syntax files.
Post Reply
iorx
Posts: 4
Joined: 30 Jun 2008 13:41

Fold ini and inf files

Post by iorx »

Hello!

First post. Very nice editor you've made! :-)

I've fooling around with syx-files. Managed to make folding work on Batch-files if (), do (). Now I struggling with folding on ini, and inf.

The folding should be done from "[" to next "[" (or \n ? for last section...) I've figured. But can't get it working. Any suggestions?

-------------------

[section]
foo=bar
foo=bar
foo=bar

[section]
foo=bar
foo=bar
foo=bar

-------------------

Brgs,
Iorx
User avatar
Rickard Johansson
Site Admin
Posts: 6627
Joined: 19 Jul 2006 14:29

Post by Rickard Johansson »

You could use regions.

In the syntax file:

Code: Select all

  Rgn_Start = "$START" 
  Rgn_End = "$END" 
  Rgn_CommentStart = ";" 
In code write:

Code: Select all

   ;$START "This is section 1" 
   [section]
   foo=bar
   foo=bar 
   ;$END

   ;$START "This is section 2"
   [section]
   foo=bar
   foo=bar
   ;$END
iorx
Posts: 4
Joined: 30 Jun 2008 13:41

Post by iorx »

[quote="Rickard Johansson"]You could use regions.

In the syntax file:

Code: Select all

  Rgn_Start = "$START" 
  Rgn_End = "$END" 
  Rgn_CommentStart = ";" 

I was more in for the solution that NP++ has. Like this, a .reg file.

Image

Possible to parse for an empty line?
User avatar
Rickard Johansson
Site Admin
Posts: 6627
Joined: 19 Jul 2006 14:29

Post by Rickard Johansson »

I'll see what I can do. We could enable the use of a wildcard (*) and maybe use something like:

Id=[*]
End=

Notice the empty option value (End=). This would create a foldable block at the first empty line.

I have desided to release a version 4.51. I'll add some small features and fix a few small issues. I'll try to make this work in this version.
User avatar
Rickard Johansson
Site Admin
Posts: 6627
Joined: 19 Jul 2006 14:29

Post by Rickard Johansson »

I think a better solution would be to add an option to fold by indent (like Notepad++). This could be set in the syntax file and used with files like .boo, .ini, .reg...

It will also check for the next keyword (block...) if the text have the same indention.
E.g.

[keyword]
text=bla
text=bla
[keyword]
[keyword]
text=bla

And if we have two keyword after another, we can skip the first. I think this is how the Scintilla editor component (in Notepad++) does it. This option will also disable normal folding (by syntax elements).

It will require some work to implement. It'll have to wait til v4.60.
Post Reply