Author Topic: Can't beautify my C files - menu option is greyed out  (Read 3561 times)

timur

  • Senior Community Member
  • Posts: 179
  • Hero Points: 3
Can't beautify my C files - menu option is greyed out
« 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.
« Last Edit: July 18, 2011, 12:34:16 am by timur »

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 769
  • Hero Points: 50
Re: Can't beautify my C files - menu option is greyed out
« Reply #1 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++

timur

  • Senior Community Member
  • Posts: 179
  • Hero Points: 3
Re: Can't beautify my C files - menu option is greyed out
« Reply #2 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.

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 769
  • Hero Points: 50
Re: Can't beautify my C files - menu option is greyed out
« Reply #3 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++

timur

  • Senior Community Member
  • Posts: 179
  • Hero Points: 3
Re: Can't beautify my C files - menu option is greyed out
« Reply #4 on: July 18, 2011, 12:44:46 am »
Just ".c" and ".h", like any normal C files.

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 769
  • Hero Points: 50
Re: Can't beautify my C files - menu option is greyed out
« Reply #5 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++

timur

  • Senior Community Member
  • Posts: 179
  • Hero Points: 3
Re: Can't beautify my C files - menu option is greyed out
« Reply #6 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?

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 769
  • Hero Points: 50
Re: Can't beautify my C files - menu option is greyed out
« Reply #7 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++