SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: timur on July 17, 2011, 03:40:35 am

Title: Can't beautify my C files - menu option is greyed out
Post by: timur on July 17, 2011, 03:40:35 am
I have a project of C files, and the Tools->Beautify option is greyed out.  When I try the "gui-beautify" command, the status line says, "Command is disabled for this object".  I don't even know what this means.

I'm using Slickedit 2011 for Linux x86-64.
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: Rodney on July 18, 2011, 12:06:45 am
The only thing I can think of is that SlickEdit does not recognize the extension as C/C++. If that is the case, then go to Tools>Options>File Extension Manager, New. Add the offending extension and associate it with C/C++.

--rodney++
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: timur on July 18, 2011, 12:33:45 am
I've associated them with ANSI-C, because I don't want it to recognize C++ keywords.  I changed the association back to C/C++, but that didn't fix it.

I even deleting my ~/.slickedit folder to reset all options, and it's still greyed out.
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: Rodney on July 18, 2011, 12:43:03 am
I would have expected deleting your config-directory to have solved it for sure. What exactly is the extension on these files?

--rodney++
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: timur on July 18, 2011, 12:44:46 am
Just ".c" and ".h", like any normal C files.
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: Rodney on July 18, 2011, 12:47:34 am
Okay. When you have one of these files open, bring up the Document menu. For the "Select Mode" item you should see:

Select Mode (C/C++)...

Please confirm.

--rodney++
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: timur on July 18, 2011, 12:49:03 am
Ah, I changed the document mode from ANSI-C to C/C++ and now it works.

Why can't I beautify ANSI-C code?
Title: Re: Can't beautify my C files - menu option is greyed out
Post by: Rodney on July 18, 2011, 01:12:10 am
The C++ beautifier cannot deal with 'class' as a keyword. I do not believe it likes old-style function signatures either. Those are just a couple good reasons. For now you will have to switch modes. I leave you with a code sample I plucked from the internet that would give our beautifier fits:

Code: [Select]
static void class_release(struct kobject *kobj)
{
        struct class_private *cp = to_class(kobj);
        struct class *class = cp->class;

        pr_debug("class '%s': release.\n", class->name);

        if (class->class_release)
                class->class_release(class);
        else
                pr_debug("class '%s' does not have a release() function, "
                         "be careful\n", class->name);

        kfree(cp);
}

--rodney++