Author Topic: GenComment by Gary Ash on SE 2017  (Read 4760 times)

nlangenberg

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
GenComment by Gary Ash on SE 2017
« on: December 05, 2017, 08:00:13 AM »
We recently upgraded to SlickEdit 2017.
However, the Macro 'GenComment' by Gary Ash doesn't work anymore.

I already contacted him, but he doesn't have SE 2017, so I (and he) was hoping someone here can help us further with getting GenComment working again on SE 2017.

Some background information about the Macro if you don't know it: it is able to create a comment-box above a function with a fixed layout. It can extract ingoing and outgoing parameters and the function name so a nice comment-box is created with a fixed style. In the fixed box you can of course enter additional comment after the parameter variable names to explain the parameters and the complete function.

We are using it for a couple of years now and it's really handy.

After some research by myself I got it working now, but it's not as flexible as it should be.
Gary Ash also gave a reaction and he says the so called 'lexer' system has changed, which is indeed true. However, I have no knowledge about this 'lexer' system so it would take me a lot of time to adjust the current GenComment to the new 'lexer' system.

Hope someone can help me (and of course others) by adjusting GenComment to be compatible with SlickEdit 2017.

I have it working now, but not very flexible.
It works for us because we only do C programming and only need a commentbox above the functions in a .C file.
What I have done is disabled searching for the ‘Lexer’ files like this in 'gc_comment.e':
    //g_VslickLexerFile = slick_path_search(SYSTEM_LEXER_FILENAME);
    //g_UsersLexerFile  = slick_path_search(USER_LEXER_FILENAME);
    //g_UserStateFile   = slick_path_search(STATE_FILENAME);

And I removed ‘MB_DEFBUTTON2’ from an option list, SE 2017 doesn’t known that, so:
        _message_box("Are you sure?", "Delete GenComment Configuration", MB_YESNO|MB_ICONQUESTION) == IDYES)

Loading the macro file ‘gc_comment.e’ does work after that and an .ex is created.
What doesn’t work is the macro ‘gc-configure’. It fails.

However, what does work is ‘gc-edit’ what we use to get the correct commentbox above a function which we need.

I have searched for another, SE included macro, how they now do the Lexer system, but it’s too difficult for me to simply adjust it without any knowledge of what it exactly does.
Here an example on the an old Lexer system in an older file (SE v11) and the new SE 2017.
I took the included ‘enum.e’
In SE v11:
--
         _str lexer_name=p_lexer_name;
         p_buf_id=old;
         if (lexer_name!="") {
            _str filename=usercfg_path_search(USER_LEXER_FILENAME);
            typeless status=1;
            _str styles="";
            if (filename!="") {
               status=_ini_get_value(filename,lexer_name,"styles",styles,"");
            }
            filename=get_env('VSROOT'):+(SYSTEM_LEXER_FILENAME);
            if (filename!="") {
               // IF there was an error and it wasn't because the string did not exist in the section
               if (status && status!=STRING_NOT_FOUND_RC) {
                  _ini_get_value(SYSTEM_LEXER_FILENAME,lexer_name,"styles",styles,"");
               }
            }
            if (pos("xhex",styles,1,"i")) {
               gleading="0x";
            } else if (pos("amphhex",styles,1,"i")) {
               gleading="&H";
            } else if (pos("hexh",styles,1,"i")) {
               gtrailing="H";
            } else if (pos("dollarhex",styles,1,"i")) {
               gleading="$";
            }
         }
         if (gleading=="" && gtrailing=="") {
            gleading="0x";
         }
--
==

In SE 2017:
--
            _str lexer_name=p_lexer_name;
            p_buf_id=old;
            if (lexer_name!="") {
               styles:=_plugin_get_property(VSCFGPACKAGE_COLORCODING_PROFILES,lexer_name,'styles');
               if (pos("xhex",styles,1,"i")) {
                  gleading="0x";
               } else if (pos("amphhex",styles,1,"i")) {
                  gleading="&H";
               } else if (pos("hexh",styles,1,"i")) {
                  gtrailing="H";
               } else if (pos("dollarhex",styles,1,"i")) {
                  gleading="$";
               }
            }
            if (gleading=="" && gtrailing=="") {
               gleading="0x";
            }

--

Hope someone can help me/us further.
« Last Edit: December 05, 2017, 08:02:24 AM by nlangenberg »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: GenComment by Gary Ash on SE 2017
« Reply #1 on: December 05, 2017, 11:46:48 AM »
Have you tried the global alias - functioncomment.
I have a global alias called funccom as follows.  I don't know if it's a shipped alias or not - it probably is.  I use it in conjunction with the func_comment macro below.  If the cursor is within a function, the macro adds the function comment stuff at the top of the function.

Code: [Select]
/*******************************************************************************
 * FUNCTION NAME : %\o
 * %\S
 * DESCRIPTION : %\S
 *     %\c
 *
 * INPUTS : %\u
 *     @param %\p %\c
 *
 * OUTPUTS : %\v
 *     @return %\r %\c%\v
 *
 ******************************************************************************/


Code: [Select]
_command void func_comment() name_info(',')
{
   _str ll;
   get_line(ll);
   if (length(strip(ll)) == 0) {
      next_proc();
      up();
   }
   else {
      down();
      prev_proc();
      up();
   }
   keyin("funccom");
   expand_alias();
}


nlangenberg

  • Junior Community Member
  • Posts: 5
  • Hero Points: 0
Re: GenComment by Gary Ash on SE 2017
« Reply #2 on: December 05, 2017, 12:54:30 PM »
Thnx Greame!

Just tried you suggestion. To be honest I never heard/played with aliases before, but I managed to get your macro working.
Notes: 'functioncomment' isn't an alias anymore in SE 2017 (there is also a topic about it that it is removed), but I managed to create an alias with the name 'funccom' and with your included code.

It does work!

Because we don't want to change our coding guidelines I (and our other engineers) will keep on working with GenComment because I got a working workaround, but it's sure good to have an alternative.
Is there a manual of all the parameters that we can use in the 'funccom' alias?

Currently we only have the function name in the box comment without the full prototype, e.g.
BOOLEAN TermDevSetPresent(unsigned char ReaderNr)

top header will become in GenComment's commentbox:

Code: [Select]
/********************************************************************
 * TermDevSetPresent
 *
 

while top header will become in the alias commentbox:

Code: [Select]
/********************************************************************
 * FUNCTION NAME : BOOLEAN TermDevSetPresent(unsigned char ReaderNr)
 *
 

We aren't interested in the exact prototype of the complete function, only the name.
Probably we can get only the name with another %\o

A manual should be fine. Probably already exists somewhere, but please help me find the options we have in this alias.

Thanks again for this new method.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: GenComment by Gary Ash on SE 2017
« Reply #3 on: December 06, 2017, 11:22:07 AM »
Hi
See the topic aliases or aliases::escape sequences in the help.  There's a full list of what's available there.  %\n gets the function name without signature.  You can prompt for arguments or call a macro.  %\c creates multiple cursors.

If you feel like customizing anything, see the function expand_alias_line in alias.e.