Author Topic: Patch to make #include pop up completion list of header files  (Read 5430 times)

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Patch to built in command:
c_expand_space

Written for:
SlickEdit 14.0, but can probably be applied to 13 (maybe even earlier versions).

Description:
Typing #include in a Slick-C file and then pressing Spacebar pops up a list of header files from the current project, to autocomplete the #include directive.  This patch adds the same functionality in C/C++ files.

Installation:
1.  Open the macros\c.e file.
2.  Find the c_expand_space command.
3.  Find the line "} else if ( pos(' 'word' ',EXPAND_WORDS) ) {" in the function.
4.  Insert the patch code from below above that line.
5.  Reload the module (Macro|Load Module).

Warning:  Modifying built in macros can potentially be dangerous, and modifications can get overridden when upgrading.  Exercise caution.

Code: [Select]
// BEGIN PATCH
   } else if ( word=="#include") {
      replace_line(indent_string(width)word' ""');
      _end_line();
      left();
      _do_list_members(false, true);
// END PATCH
   } else if ( pos(' 'word' ',EXPAND_WORDS) ) {

matthewh

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Patch to make #include pop up completion list of header files
« Reply #1 on: July 22, 2009, 07:04:08 pm »
Very cool  8)

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Patch to make #include pop up completion list of header files
« Reply #2 on: July 22, 2009, 07:38:58 pm »
Note that this patch was incorporated into the official 14.0.2:  there is a new setting def_c_expand_include which you can set to 1 to activate the patch (it is off by default).  At the SlickEdit command line invoke "set-var def_c_expand_include" to change it.

mcarlson

  • Community Member
  • Posts: 15
  • Hero Points: 0
Re: Patch to make #include pop up completion list of header files
« Reply #3 on: October 05, 2009, 07:52:06 pm »
This is very nice!

In my source tree we have several include subdirs, each has .h files that I would like to see in the list.

src/inlcude/foo/ (with foo1.h foo2.h foo3.h)
src/include/bar/ (with bar1.h bar2.h bar3.h)
src/include/baz/ (with baz1.h baz2.h baz3.h)

(Obviously it's not THAT crazy, but it's an example)

I've noticed that if I add "src/include/foo" to the Project directories I get autocomplete for
#include "foo1.h"
but I need
#include "foo/foo1.h"

I would like to add "src/include" and have all subdirs added, or even each added individualy but get the output desired.
 
Any ideas on how I could adjust to get this?

M@