Code::Blocks

User forums => General (but related to Code::Blocks) => Topic started by: Roman on August 05, 2007, 03:48:32 pm

Title: Standard Header Highlighting
Post by: Roman on August 05, 2007, 03:48:32 pm
Dear guys!

The C++ standard library is a great place to learn good programming techniques. Because of that I often use "open #include fie 'streambuf'" command in the rightclick menu. But <streambuf> has no extension and C::B doesn't use appropriate syntax highlighting scheme. So my suggestion is to 'hardcode' the names of new style standard C++ library header files so they will be highlighted as C++ by default.

Best Regards,
Roman
Title: Re: Standard Header Highlighting
Post by: dmoore on August 05, 2007, 04:52:29 pm
another way would give users the option to change the lexer of any open editor (a la Scite)
Title: Re: Standard Header Highlighting
Post by: mandrav on August 05, 2007, 05:48:03 pm
another way would give users the option to change the lexer of any open editor (a la Scite)

Edit->Highlight mode
Title: Re: Standard Header Highlighting
Post by: Roman on August 05, 2007, 07:25:39 pm

Quote
Edit->Highlight mode

<iostream>
  <istream>
    <ios>
  <ostream>
    <ios>

When travelling from top to <ios> content I usually use Edit->Highlight mode but it would be more comfortable not to do so )

Best Regards,
Roman
Title: Re: Standard Header Highlighting
Post by: rhf on August 05, 2007, 07:49:40 pm
Edit->Highlight mode

Hmm, interesting. When I open a standard C++ header with no file extension, there is no syntax highlighting.
Edit->Highlight mode shows the list with C/C++ selected. Reselecting C/C++ or closing the menu has no effect.

However, if I Edit->Highlight mode and select, say, Batch, highlighting appears.
Then I can Edit->Highlight mode and select C/C++ and get the desired syntax highlighting.

This does not seem correct. Am I missing a refresh command or something?

Windows XP,  Nightly SVN 4338.


Title: Re: Standard Header Highlighting
Post by: Roman on August 05, 2007, 10:04:17 pm
Same thing
Title: Re: Standard Header Highlighting
Post by: mandrav on August 05, 2007, 10:14:32 pm

Quote
Edit->Highlight mode

<iostream>
  <istream>
    <ios>
  <ostream>
    <ios>

When travelling from top to <ios> content I usually use Edit->Highlight mode but it would be more comfortable not to do so )

Best Regards,
Roman

Does the fact that I quoted dmoore give you a hint that maybe I replied to him? He made a specific suggestion and I replied that it's already there :).
For the rest of the things mentioned in this topic, file a feature request.
Title: Re: Standard Header Highlighting
Post by: dmoore on August 06, 2007, 06:28:38 pm
Edit->Highlight mode

:oops: I've even used this before, but use so infrequently I forgot its existence...

So my suggestion is to 'hardcode' the names of new style standard C++ library header files so they will be highlighted as C++ by default.

Roman: instead of hardcoding a list, how about automatically changing to the C/C++ lexer (or the currently active lexer) if you follow a #include? that should be easy to implement

Hmm, interesting. When I open a standard C++ header with no file extension, there is no syntax highlighting.
Edit->Highlight mode shows the list with C/C++ selected. Reselecting C/C++ or closing the menu has no effect.

having troubles replicating this. my version doesn't even show a check next to the current lexer. If I open a file without extension it defaults to plain text. I can change to c/c++ but can't change back to text.

anyway, I can work on these issues in the next week or two if someone else wants to put a bug/feature request on berlios.

Title: Re: Standard Header Highlighting
Post by: rhf on August 06, 2007, 07:07:46 pm
...I can work on these issues in the next week or two if someone else wants to put a bug/feature request on berlios.

Thanks. Bug 011720.
Title: Re: Standard Header Highlighting
Post by: Biplab on August 06, 2007, 07:20:28 pm
Thanks. Bug 011720.

I was about to commit a fix for this bug. But dmoore reported another one and I stopped. ;)

having troubles replicating this. my version doesn't even show a check next to the current lexer. If I open a file without extension it defaults to plain text. I can change to c/c++ but can't change back to text.

Both the bugs are fixed in rev 4353. :)
Title: Re: Standard Header Highlighting
Post by: thomas on August 07, 2007, 01:17:39 pm
Quote
So my suggestion is to 'hardcode' the names of new style standard C++ library header files so they will be highlighted as C++ by default.
No way, sorry.

Quote
Roman: instead of hardcoding a list, how about automatically changing to the C/C++ lexer (or the currently active lexer) if you follow a #include? that should be easy to implement
That would break languages with similar/identical preprocessor syntax. Two such examples are Cg and Objective-C (there are probably more).
Title: Re: Standard Header Highlighting
Post by: dmoore on August 07, 2007, 01:42:35 pm
Quote
Roman: instead of hardcoding a list, how about automatically changing to the C/C++ lexer (or the currently active lexer) if you follow a #include? that should be easy to implement
That would break languages with similar/identical preprocessor syntax. Two such examples are Cg and Objective-C (there are probably more).

note the alternative:

Quote
(or the currently active lexer)

surely this won't break unless a language can #include code written in another language, or a language uses a different lexer for its #includes?
Title: Re: Standard Header Highlighting
Post by: Biplab on August 07, 2007, 01:49:04 pm
Quote
So my suggestion is to 'hardcode' the names of new style standard C++ library header files so they will be highlighted as C++ by default.
No way, sorry.

I do have the same opinion as of Thomas.

One way to identify is to read the file for some embedded highlighting tags. E.g., iostream begins with the following line-
Quote
// Standard iostream objects -*- C++ -*-
which indicates that it's a C++ file. But this behavior is not uniform and MS supplied headers doesn't have these identifiers. :)
Title: Re: Standard Header Highlighting
Post by: dmoore on August 07, 2007, 03:54:36 pm
i still don't see what is wrong with assuming the same lexer as the file they are linking from. what am i missing?
Title: Re: Standard Header Highlighting
Post by: Roman on August 07, 2007, 10:01:35 pm
i still don't see what is wrong with assuming the same lexer as the file they are linking from. what am i missing?

I'm missing it too )
Title: Re: Standard Header Highlighting
Post by: thomas on August 08, 2007, 01:11:20 pm
i still don't see what is wrong with assuming the same lexer as the file they are linking from. what am i missing?
That would probably work.