Author Topic: Variable exanpsion in Codesnippets  (Read 5248 times)

mariocup

  • Guest
Variable exanpsion in Codesnippets
« on: September 02, 2007, 04:33:10 pm »
Hi Pecan,

I am working on different PC and want to use the same configuration file personality.conf. I have some file links in the codesnippets like C:\wxwidgets\docs\htmlhelp\wx.chm but what I need is something like $(#wx)\docs\htmlhelp\wx.chm or normal varialbles $(myvar)\.... This is would be nice if you move a installation and your documentation. The info of the file links is saved in the codesnippets.xml is it possible to have variable expansion in the codesnippets plugin? This would be also nice to have a predefined codesnippets.xml that is only configured by a variable in Codeblocks.


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Variable exanpsion in Codesnippets
« Reply #1 on: September 03, 2007, 10:47:49 am »
Add MacrosManager::Get()->ReplaceMacros(yourPathVariable); to your code. This should be all you need to do.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

mariocup

  • Guest
Re: Variable exanpsion in Codesnippets
« Reply #2 on: September 04, 2007, 12:10:47 pm »
Code
Hi Thomas, Hi Pecan,

the Code Snippets Plugin uses the codesnippets.xml as file for url, file links etc.
[code]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<snippets>
<item name="Test category" type="category" />
<item name="Test item 1" type="snippet" />
<snippet>// Test 1</snippets>
</item>
</item>
<item name="Test item 2" type="snippet" />
<snippet>// Test 2</snippets>
<item>
</snippets>
[/code]

If I use a $(VAR) within a file link instead of a absolute path it will be converted to a text/code snippet. I would like to use $(VAR) in file links to make it more configurable.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Variable exanpsion in Codesnippets
« Reply #3 on: September 04, 2007, 12:30:10 pm »
So you want $VAR not to expand initially, only at the very last moment when the code is instantiated? Is that it? Actually, thinking about it, this makes perfect sense... it seems kind of stupid to expand it early, that binds it to one machine.

Then you must remove all calls to MacrosManager::ReplaceMacros() and instead insert exactly one just before the wxString containing the text is sent to wxScintilla.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

mariocup

  • Guest
Re: Variable exanpsion in Codesnippets
« Reply #4 on: September 04, 2007, 12:38:17 pm »
Hi Thomas,

yes that's it. I want that the xml file contains only the name of the variable and the variable is expanded when I instantiated, so I can use the same codesnippets.xml file on different PC or platforms. Another advantage is that you can send a predefined xml file to different users and they have only to configure the variables.