Templates file format

Working on new editor enhancements?
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Templates file format

Post by blueb »

My Templates file is getting large (~ 500k bytes)

It's getting harder to find code that I wish to insert into my program.

So I've decided that I have to build a search engine for the Templates.prefs file.

Is there a way to get the format of this file? :?:
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
freak
PureBasic Team
PureBasic Team
Posts: 5929
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Templates file format

Post by freak »

Its a rather simple format:
  • First line must be "TEMPLATES:1.0" (case sensitive, without the quotes)
  • Following lines are either in the form "keyword:data" or just "keyword" where:
    • whitespace around keyword and data is ignored
    • the keyword is case insensitive
  • Possible keywords are:
    • Directory - starts a new directory. The data is the directory name
    • Expanded - if directly following a "Directory", this means that the directory is expanded in the view
    • CloseDirectory - end of a directory
    • Template - defines a template. The data is the template name
    • Comment - defines the comment for the most recent template (optional). The data is the comment (escaped)
    • Code - defines the code for the most recent template. The data is the code (escaped) on one line
  • Anything that does not match one of these keywors (like empty lines) is simply ignored
The comment and code fields are escaped so they only consist of one line each. This is done by:
  • Replacing every "\" with "\\"
  • Replacing every newline with "\n"
  • No other special chars are escaped
One day I'll replace this with something that is easier to manage (like XML or JSON).
quidquid Latine dictum sit altum videtur
User avatar
blueb
Addict
Addict
Posts: 1044
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Templates file format

Post by blueb »

Thanks Freak.. That's enough to get me started. :)
- It was too lonely at the top.

System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply