How To

(more items will be added here later)
 

Change the language for a file:

To change the language of a file, select  "Edit" / "Compiler Settings" / "File"  on the CSD window menu. Choose the "Language Specific" tab on the settings dialog. Select the desired language from the "Language" combo box. Once a language is selected, jGRASP will remember this setting. Also, the icons in file dialogs and in the browse window will reflect this setting.


 
 

Drag files into jGRASP:

Single or multiple files can be dragged onto the virtual desktop, or onto the control panel menu bar, to the right of the menus. The files will be opened in text mode.


 
 

Open a file in binary mode:

Using the  "File" / "Open File"  menu on the control panel or the  "File" / "Open"  menu on the CSD window menu will bring up a dialog that has "Text" vs. "Binary" radio buttons. All other methods of opening a file will open it in text mode. Opening a binary file in text mode is likely to corrupt it, since all three types of line terminators will be converted to a single type when the file is saved.


 
 

Search for the selected text:

F9 and Shift-F9 or Find and Shift-Find will search forward and backward for the selected text in a CSD window. This works across CSD windows - the selected text does not have to be in the window being searched.


 
 

Make ".h" a default file extension for C or C++ files only:

Default extensions can be set at the global or project level. Select "Edit" / "Compiler Settings" / "Global" or "Project" on a CSD window, or "Settings" / "Compiler Settings" / "Global" or "Project" from the control panel. Select "C" or "C++" from the "Language" combo box, whichever one you don't want to be the default. Select the "Extensions" tab, click the default box for extensions off, and add the desired extensions (without "h" or "H"). You can use Ctrl-C and Ctrl-V to copy the old extensions and paste them back after clicking the default box off.


 
 

Get C and C++ files with lots of ugly macros or compiler extensions to parse:

If you set up the CSD generation environment (include path, predefined macros) exactly like the environment your compile command sees, and set the parse mode to "All Files", and if no structures are partly in a header file and partly in a source file (like an included function header), and if the code is ANSI C, CSD generation should work for your code. Setting all that up can be a pain, and parsing thousands of lines of headers can be slow, so this is usually not an option, unless you just want to generate a CSD once for printing or viewing.

If you can edit the code, the easiest thing to do is surround weird code with  #ifndef _GRASP_IGNORE  and  #endif . _GRASP_IGNORE  is set in the predefined macros for all compiler environments by default. For example:

   #ifndef _GRASP_IGNORE
   BEGIN_MESSAGE_MAP(CPrintApp, CWinApp)
   ON_COMMAND(ID_SETUP, CWinApp::OnFilePrintSetup)
   END_MESSAGE_MAP()
   #endif

This is an MFC message map. Without the ifndef, if all headers are parsed and the include path is set correctly, a CSD will be generated for this structure, but the indentation will not be what you expect, because the real structure is not what you expect.

For compiler extensions, setting predefined macros in the compiler environment can solve many problems. For example, you might define  far  to be nothing in an old 16 bit compiler.

For your own code, it is a good idea to use macros that look like real code. For example, you should leave a trailing semicolon out of a macro so it will be required in the code.