#671 distinguish types from statements in C syntax highlighting

open
nobody
None
5
2013-05-18
2013-05-18
Adam Dingle
No

In C syntax highlighting, It would be nice if Geany distinguished build-in types (int, bool, const) from statements (if, for).

Discussion

  • Adam Dingle
    Adam Dingle
    2013-05-18

    I've attached a patch that implements this.

     
  • Matthew Brush
    Matthew Brush
    2013-05-19

    Doesn't this make the non-data-type reserved language keywords in "secondary" the same colour as user-defined/session/tags types? If so, -1. At least if you swapped primary and secondary in your patch all "types" would get the same colour, but I think you wouldn't be able to distinguish between official language keywords and those from the stdlib or other libraries (ex. "int" and "gint" would be coloured the same, which is better than "return" and "gint" being coloured the same, but still not great, IMO).

     
  • Lex Trotman
    Lex Trotman
    2013-05-19

    @adamdingle, the entries in your types and storage classes list are all keywords (including int and float), see the table in 6.4.1 of the C standard.

    So I don't agree with this change, sorry.

     
  • Matthew Brush
    Matthew Brush
    2013-05-19

    The filetypes could have the 4th keyword list "global classes and type names" (from LexCPP.cxx) in it and have that merged with the session types. Then you could have "primary" for non-data-type language keywords, "secondary" for data-type language keywords and "user_types" for custom static user types and also have it merged with the dynamic session types. In this way we could make "primary" and "secondary" styled the same by default but still allow users to change it to a different colour.

     
  • Adam Dingle
    Adam Dingle
    2013-05-19

    @Lex: Yes, certainly these are all keywords in C. But in my opinion it would be nice to distinguish keywords representing types and type modifiers (e.g. volatile const int) from statements (if, for, while) since they represent different semantic categories. I'm migrating to Geany from gedit, which highlights these categories differently and I've always liked it there.

    @Matthew: Thanks for the feedback. I'll need to look into Geany's syntax highlighting mechanism in more depth before I can reasonably respond to your points. Arguably I should have done that before submitting this patch. :) I'lll try to get to that soon.