Author Topic: C++ User-Defined Keyword Syntax Highlighting  (Read 8286 times)

penguino

  • Guest
C++ User-Defined Keyword Syntax Highlighting
« on: April 05, 2006, 10:26:34 pm »
I'm not sure if this topic's subject is appropriately named or not - hopefully I'll make some sense.  :?

Is it possible to add syntax highlighting for user-defined typedefs, structs, defines, etc... without having to add them individually to the C++ keyword list?

For example, suppose you have the following code:

Code: cpp
#define WIN32_LEAN_AND_MEAN

//////////////////////////////////////////////////////////////////////////////////////////

#include <windows.h>

//////////////////////////////////////////////////////////////////////////////////////////

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wcx;

wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = App::ToolWindow::CallBack;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = GetModuleHandle(NULL);
wcx.hIcon = NULL;
wcx.hCursor = NULL;
wcx.hbrBackground = (HBRUSH) GetSysColorBrush(COLOR_BTNFACE);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = App::Version;
wcx.hIconSm = NULL;

if (RegisterClassEx(&wcx) == FALSE)
{
MessageBox(NULL, "AppWindow\n\nRegisterClassEx() failed...", "Error", MB_OK | MB_ICONEXCLAMATION);
return 0;
}

if (CreateWindowEx(NULL, wcx.lpszClassName, App::Title, WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_SIZEBOX | WS_SYSMENU | WS_VISIBLE, 10, 10, 400, 400, GetDesktopWindow(), NULL, wcx.hInstance, NULL) == NULL)
{
MessageBox(NULL, "AppWindow\n\nCreateWindowEx() failed...", "Error", MB_OK | MB_ICONEXCLAMATION);
return 0;
}

MSG msg;

while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == 0)
{
WaitMessage();
}
else
{
DispatchMessage(&msg);
}
}

UnregisterClass(wcx.lpszClassName, wcx.hInstance);

return msg.wParam;
}

Would it be possible for C::B to recognize these:

1) typedefs such as HINSTANCE, LPSTR
2) structs such as WNDCLASSEX, MSG
2) defines such as WIN32_LEAN_AND_MEAN, CS_OWNDC, CS_VREDRAW, etc...

and consider them keywords (to change color highlight) without having to add all of them individually to the C++ keyword set?
« Last Edit: April 05, 2006, 10:28:34 pm by penguino »

takeshimiya

  • Guest
Re: C++ User-Defined Keyword Syntax Highlighting
« Reply #1 on: April 05, 2006, 10:31:07 pm »
Is it possible to add syntax highlighting for user-defined typedefs, structs, defines, etc... without having to add them individually to the C++ keyword list?
Currently not, submit a feature request, it would be a very handy feature. :)
I hope CodeCompletion and Scintilla will interact well.

penguino

  • Guest
Re: C++ User-Defined Keyword Syntax Highlighting
« Reply #2 on: April 05, 2006, 10:40:34 pm »
Is it possible to add syntax highlighting for user-defined typedefs, structs, defines, etc... without having to add them individually to the C++ keyword list?
Currently not, submit a feature request, it would be a very handy feature. :)
I hope CodeCompletion and Scintilla will interact well.

I agree.

Having to add keywords for multiple libraries (Win32, DirectX, OpenGL, etc...) is a pain.

Maybe someone can submit a clearer and accurate feature request on my behalf.  :P

takeshimiya

  • Guest
Re: C++ User-Defined Keyword Syntax Highlighting
« Reply #3 on: April 05, 2006, 10:50:28 pm »
Is it possible to add syntax highlighting for user-defined typedefs, structs, defines, etc... without having to add them individually to the C++ keyword list?
Currently not, submit a feature request, it would be a very handy feature. :)
I hope CodeCompletion and Scintilla will interact well.

I agree.

Having to add keywords for multiple libraries (Win32, DirectX, OpenGL, etc...) is a pain.

Maybe someone can submit a clearer and accurate feature request on my behalf.  :P
The feature is called "Enhanced Syntax Coloring" in Visual Assist X.
You can see it in action here: http://www.wholetomato.com/products/features/color.html

It's those kind of features that once you become used you can't live without.

Anyways, CodeCompletion is WIP, don't expect anything soon.

penguino

  • Guest
Re: C++ User-Defined Keyword Syntax Highlighting
« Reply #4 on: April 05, 2006, 11:33:13 pm »
The feature is called "Enhanced Syntax Coloring" in Visual Assist X.
You can see it in action here: http://www.wholetomato.com/products/features/color.html

It's those kind of features that once you become used you can't live without.

Yes! That feature is exactly what I was trying to explain. If only C::B had it right now... :x
« Last Edit: April 06, 2006, 12:44:20 am by penguino »