User forums > Using Code::Blocks
Color for "Search results" window...
(1/1)
Crepuscule:
Hello!
I am using Code:Blocks 10.05. I would like to know if it is possible to have color when I am doing a search in my project...
The aim is to detect quickly when code is commented with : /* ... */
For example, imagine you have a code like this:
--------------------------------------------------
int a = 1;
int b = 2;
int c = 3;
/*
int d = 4;
int e = 5;
*/
c = a + b;
---------------------------------------------------
If I tape "Ctrl"+"Shift"+"F" and I search "d = 4", Code::Blocks will find (in the "Search results" window) :
int d = 4;
But with this view I can't know if the line found is about a comment or about source code used.
In the Code::Blocks environment, this line is written in grey because it is a comment.
I would like to know if the colors can be integrated to the "Search result" window.
Regards
Crepuscule
Alpha:
Currently, syntax highlighting in the "Search results" window is not available.
If you are searching only in a single file, you could try Incremental search (Ctrl-I). If you are searching through multiple files, you could try Thread search; the "Thread search" log displays a preview of the currently selected result (with syntax highlighting).
Crepuscule:
Thanks for your response.
I already know Thread search and incremental search. It is not really what I want.
I asked the question because I try to follow some rules. There is one rule about comment: it is not permitted to use // to comment but only /* and */. So, when I make a search in Code::Blocks, I would like to see immediatly the code commented and the code uncommented. If a commented line is written with // I can see it immediatly in a simple search. But if the code is commented with /* ... a lot of lines ... */, if the wanted line is between these lines, I can't see it before going to theses lines.
I downloaded the code of code::blocks, I will try to get the color in the search (if it is not too hard)... and if it is possible, I will add an checkbox to display or not the commented code in the search.
Regards,
Crepuscule 8)
Alpha:
If you want "Find in files..." to only show // style comments, you can use the regular expression
//.*SearchTerm
However, "Find in files..." only deals with single lines, so using a regex (ex. /\*(.|[\r\n])*?\*/) for multi-line /* */ style comments is impossible.
If you plan to make a patch (:)), I have been messing around with syntax highlighting recently. The following are some useful things I discovered in relation to this (if you need a place to start).
--- Code: ---#include <cbstyledtextctrl.h>
[...]
int posOfSearchTerm = pos;
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
cbStyledTextCtrl* control = ed->GetControl();
[...]
myColoringFunction(control->GetStyleAt(posOfSearchTerm));
--- End code ---
src/sdk/resources/lexers/lexer_cpp.xml
src/sdk/wxscintilla/include/wx/wxscintilla.h
Crepuscule:
Thanks for your help! :P
I took a look yesterday during some minutes and I think I was watching around the code you give me here. I will see if I can do something with this code today.
Regards,
Crepuscule
Navigation
[0] Message Index
Go to full version