|
/*********************************************************************
Copyright (C) 2001 Smaller Animals Software, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
http://www.smalleranimals.com
smallest@smalleranimals.com
--------
This code is based, in part, on:
"Syntax Coloring Text Edit Window Class " - Randy More (9, May 1998)
http://www.codeguru.com/editctrl/syntax_coloring.shtml
Though probably only 5% of the original code remains.
**********************************************************************/
#ifndef _COLORIZE_
#define _COLORIZE_
#pragma warning(disable:4786)
#include <vector>
#include <set>
using namespace std;
#pragma warning(disable:4786)
#include "Scripter.h"
// Colors for colorizing the text
#define KEYWORD_COLOR RGB(0,0,160)
#define COMMENT_COLOR RGB(0,120,0)
#define CONSTANT_COLOR RGB(128,128,0)
#define OBJECT_COLOR RGB(0,0,0)
#define FUNCTION_COLOR RGB(0,0,160)
#define ERROR_COLOR RGB(255,0,0)
#define NORMAL_COLOR RGB(0,0,0)
/*
The base class only provides keyword coloring support.
In this class, a "word" is a sequence of uninterrupted alpha-numeric
characters. The keywords are loaded with the LoadKeywordFile member.
One keyword per line in a plain text file.
You can do more-complex processing here, or in a derived class.
*/
class CColorizer
{
public:
void FindWord(CString &t);
CScripter* pScripter;
CColorizer();
virtual ~CColorizer();
// called once per text line, when the line colors need updating.
// 'colors' will be filled with one COLORREF per text character.
//
// you will definitely rewrite this function (in a derived class, probably) for your own application.
//
virtual void SetLineColors(int lineNum, CString &pString, vector<COLORREF>& colors);
// load magic keywords.
virtual void LoadKeywords(int resId);
BOOL m_bCompareCase;
protected:
virtual BOOL IsKeyWord(CString & t);
CStringList m_szKeywords; // Keywords list (doesn't match case)
CStringArray m_szStrings; // All strings (match case)
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.