Click here to Skip to main content
15,880,608 members
Articles / Programming Languages / C++
Article

Level Add-in

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
29 Jan 2001 72.9K   594   10   10
An add-in that helps you hide 'inactive' pieces of your code in include files
  • Download source files - 24 Kb
  • Download add-in - 18 Kb
  • Introduction

    Have you ever worked with extremely long source files? I did and found that it may be quite difficult to find those pieces of code you need right now. Level add-in can help you hide 'inactive' pieces of your code into include files. So, for example if you don't work with function exampleFunction right now.

    int ExampleFunction( void )
    {
    	// function body
    	return 1;
    }

    You may use the level add-in commands and have, instead,

    int ExampleFunction( void )
    #include "./level/in312897.h";

    The body of ExampleFunction will be hidden inside of the file ./level/in312897.h. The file with ExampleFunction still will be perfectly compilable, but it will be much smaller in size. Level add-in also easily reverses the operation and restores normal text.

    I think you get the main idea. Now the details.

    Level Add-In has 6 commands.

    1. Wrap Selection

    This will take the selected text and hide it into an include file. To execute this command, select text and press the first toolbar button.

    2. Wrap Function

    This will take text, enclosed it in a couple of '{' '}' braces and save it into an include file. You may use this command not only for function. This function will be executed when you push the second button on the toolbar.

    3. Restore

    This will restore the original text. You need to put the cursor on the string with the corresponding #include and press the first button on the toolbar again.

    4. Restore in File

    This will restore the original text in the current file. Just press the third button ( red arrow up ) and Add-In will search for all #include "./level in the current file and restore it.

    5. Restore in Project

    This will restore the original text in the whole project. To invoke you need to press the fourth button ( two yellow arrows up ). All files in the current project will be restored.

    6. delete backup files

    The Add-In doesn't delete restored include files automatically, but rather waits for you to press the fifth button - familiar garbage bucket :)

     

    Installation of the Level add-in is as usual, just please, before using it, restart Developer Studio.

    I have some ideas on how to improve this add-in, but your suggestions, comments or bug reports are welcome.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    United States United States
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    QuestionFolder at root? Pin
    adamsd56-Sep-00 7:12
    adamsd56-Sep-00 7:12 
    General"origami" editor Pin
    J Cardinal4-Sep-00 6:23
    sussJ Cardinal4-Sep-00 6:23 
    GeneralFunction Folding Pin
    Anonymous4-Sep-00 7:44
    Anonymous4-Sep-00 7:44 
    GeneralRe: Function Folding Pin
    GlennC5-Sep-00 4:54
    GlennC5-Sep-00 4:54 
    GeneralRe: Function Folding Pin
    Nick Carruthers1-Feb-01 5:18
    Nick Carruthers1-Feb-01 5:18 
    GeneralRe: Function Folding Pin
    6-Feb-01 1:54
    suss6-Feb-01 1:54 
    GeneralA possibly better approach... Pin
    Mike30-Aug-00 18:38
    Mike30-Aug-00 18:38 
    GeneralRe: A possibly better approach... Pin
    MickAB20-Nov-00 1:58
    MickAB20-Nov-00 1:58 
    I 'sort-of' agree with the last comment, 'code-size is the lesser of the problems'.

    But, for example, if you have code with a large amount of switch statements, it would be useful to collapse detail into just the case x.... statements.

    The problem then moves from functional scope to a logical grouping of statements.

    e.g. a function is a logical grouping of statements, an if statement is a logical grouping of statements, similarly with loops, or any other groupings (structs, classes). Anyone see a pattern here?

    So, this is collapsability on a much more fine-grained level. The problem I think is beyond the scope of a single macro. You would somehow need to override the editor view class of Visual Studio such that it could identify groupings and collapse/expand on the fly.

    If the analogy is that syntax colour-coding of source files helps alleviate common coding errors (mismatched comments &c), then collapsing function groupings both makes code more readable and helps maintainability, e.g. when recoding a routing to produce a more streamlined condition path, thus reducing cyclomatic complexity.

    But, if the only code you ever touch is your own, then you don't need this type of editor functionality. However, I work for a German company, and the particular combination of legacy code with non-standard formatting and German comments is bloody distracting. Smile | :)
    GeneralRe: A possibly better approach... Pin
    5-Feb-01 12:27
    suss5-Feb-01 12:27 
    GeneralRe: A possibly better approach... Pin
    6-Feb-01 11:02
    suss6-Feb-01 11:02 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.