NO

Author Topic: Code Tree  (Read 9800 times)

Holger Buick

  • Guest
Code Tree
« on: June 29, 2006, 11:16:43 PM »
Hello,

after some time I have a little time again for C-programming.
Congratulations Pelle, your PellesC gets always better, excellent!

Some years ago I wrote an indenting tool (an addin that I always use).

Now I have the idea, to use this code to make something like that nice code folding in PellesC IDE and like the treeviews, where you can find functions in modules, or classes in CPP modules in other IDEs.

The number of tabulators, used to indent the code, i.e.: the level of nesting, is equal to the level in a treeview.
I feed a treeview with the complete code of a source file.
Each line gets one treeview item text.
Same indent level means sibling item.
Increasing level means child item.
Decreasing level (one less tabulator) means parent item.

The fully expanded tree looks like an indented code.
A partly collapsed tree shows the main structure of a function or a  long switch.
A fully collapsed tree shows the definitions and function names.

That is what I have now.

I would like to make code modification within the treeview by drag and drop, for example moving functions or loops or switches.

Or search function of a keyword with automatically expanding the tree to all the locations of the discoverd keyword at once to get a good overview of its use.

The macro:
BOOL AddIn_GetDocumentInfo(HWND hwnd, PADDIN_DOCUMENT_INFO pDocInfo);
to retrieve the filename,
seems not to work in my code.
Why?

Attached is the code and the DLL (to use as an addin in PellesC).

Holger Buick

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Code Tree
« Reply #1 on: June 30, 2006, 08:47:17 PM »
Quote from: "Holger Buick"

after some time I have a little time again for C-programming.
Congratulations Pelle, your PellesC gets always better, excellent!

Thanks, Holger - and welcome back! :-)

Quote from: "Holger Buick"

Now I have the idea, to use this code to make something like that nice code folding in PellesC IDE and like the treeviews, where you can find functions in modules, or classes in CPP modules in other IDEs.

Nice idea.

Quote from: "Holger Buick"

The macro:
BOOL AddIn_GetDocumentInfo(HWND hwnd, PADDIN_DOCUMENT_INFO pDocInfo);
to retrieve the filename,
seems not to work in my code.
Why?


The help file could say this better, but you need to set the cbSize member of addin_di before the call to AddIn_GetDocumentInfo() - it works like a "version number". Something like this, for example:

Code: [Select]

ADDIN_DOCUMENT_INFO  addin_di={ .cbSize = sizeof(addin_di) };
/Pelle

Holger Buick

  • Guest
Code Tree
« Reply #2 on: June 30, 2006, 10:58:18 PM »
Hello Pelle,

thanks a lot, now it works.

I had forgotten to add the icon to the uploaded files.
Added now RES1.ico to the CodeTree.zip in the first post.

Thanks, Holger.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Code Tree
« Reply #3 on: June 30, 2006, 11:40:55 PM »
Hello Holger,

Quote from: "Holger Buick"
thanks a lot, now it works.

Very good. I will add a note to the help file about the cbSize member (for future reference...).

Pelle
/Pelle

Holger Buick

  • Guest
New version of CodeTree
« Reply #4 on: July 11, 2006, 10:19:40 AM »
Hello,

- CodeTree formats the source when opening the code tree
- each IDE-document has its own code tree window as child window
- your selection in the tree selects the corresponding line in the IDE-document.
- indenting of "else" and "else if" added

warning: opening the codetree will format your code and so the IDE will not be able to make a "undo" of preveous changes.

Source and DLL attached (you have to be logged in to view the download)

Holger

kalikiana

  • Guest
Code Tree
« Reply #5 on: July 11, 2006, 02:00:21 PM »
Sounds interesting... what version is this DLL for? I copied it into the AddIn folder but the IDE doesn't list it in the addins window...

Holger Buick

  • Guest
Code Tree
« Reply #6 on: July 11, 2006, 08:43:56 PM »
Hello Kalikiana,

it should work for all versions, I currently use PellesC version 4.50.90 .

The addins of the folder are listet in -> Tools -> Customize -> AddIns ,
but new addins only after closing and reopening the IDE (!!!), after copying them into the addin folder.
Only if checked there,ยด
they get visible in -> Tools -> Options -> AddIns
and for the codetree addin, there should appear an icon at the toolbar then.

So:

1.: Copy the DLL into the  folder ...\PellesC\Bin\AddIns
2.: Close the IDE
3.: Open the IDE
4.: Goto   -> Tools -> Customize -> AddIns
5.: Check the AddIn "Code Tree"
6.: Do not close the dialog without clicking the "OK" Button
7.: Click to the new icon in the toolbar to use the AddIn

ready.

Maybe, I should make an installer for the addin...? It would be easier.

If it does not work then, it may be a bug in my code with using the addin structure in "ADDINAPI BOOL WINAPI AddInMain" ...

Holger.

kalikiana

  • Guest
Code Tree
« Reply #7 on: July 11, 2006, 10:32:12 PM »
Hm... the add-in doesn't work. I redownloaded the ZIP archive and copied the DLL into bin\addins again. I restarted PellesC three times, one time standalone, two times from different project files. Even compiling the DLL from the sources didn't do it. :(

Maybe I'll install PellesC 4.5 anyway and see if it works then...

Gerome

  • Guest
Code Tree
« Reply #8 on: July 12, 2006, 09:59:30 AM »
Dear Holger,

Your DLL works like a charm under Win2k SP4 FR and WinXP SP1 FR !!!
Very cool addition btw :)

It'd be only now nice to have a right click support for a 'copy block', like we have into VStudio, that allows to copy a collapsed at once : very useful when you want to quick copy a code block :)

BTW, thanks for this tool!

Holger Buick

  • Guest
Code Tree
« Reply #9 on: July 12, 2006, 10:22:16 AM »
Hello Gerome,

thanks a lot for trying the DLL and your positive feedback.

The copy function that you mentioned I will soon begin to work on.

Holger

Gerome

  • Guest
Code Tree
« Reply #10 on: July 12, 2006, 11:00:21 AM »
Hi,

Quote from: "Holger Buick"
Hello Gerome,

thanks a lot for trying the DLL and your positive feedback.

The copy function that you mentioned I will soon begin to work on.

Holger


Excellent!
Looking for that implementation ;)

Holger Buick

  • Guest
Code Tree
« Reply #11 on: July 15, 2006, 12:27:51 AM »
Hello Gerome,

here is the copy function:

Select the first line of the range you want to select in the codetree with your mouse.
Then select the last line of the range in the code tree with your mouse while pressing the CTRL-key.
By this the range in the source window will be selected.
Copy with CTRL + C.

When you have changed the source, reload the codetree by clicking onto the icon in the toolbar.

Added: When opening the codetree, the selection in the codetree corresponds to the selection of the source window.

Holger