Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Variable exanpsion in Codesnippets

(1/1)

mariocup:
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.

thomas:
Add MacrosManager::Get()->ReplaceMacros(yourPathVariable); to your code. This should be all you need to do.

mariocup:

--- 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>

--- End code ---
[/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.

thomas:
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.

mariocup:
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.

Navigation

[0] Message Index

Go to full version