Click here to Skip to main content
15,893,486 members
Articles / Desktop Programming / MFC

Brainchild, A syntax coloring edit control

Rate me:
Please Sign up or sign in to vote.
4.85/5 (64 votes)
16 Jun 2005CPOL5 min read 709.5K   26.8K   263  
Syntax coloring, multi-level undo/redo editor control.
//
//	keywords.h
//
//	(C) Copyright 2000-2002 by Jan van den Baard.
//	    All Rights Reserved.
//
//	Keyword editor dialog.
//

// Forward declarations.
class KWEdit;
class SyntaxPage;

// Keyword dialog class.
class KeywordEdit : public ClsDialog
{
	friend class KWEdit;	 // Needs to access some protected fields.
	friend class SyntaxPage; // Needs to access some protected functions.
	_NO_COPY( KeywordEdit );

public:
	// Construction/destruction.
	KeywordEdit();
	virtual ~KeywordEdit();
	
	// Implementation.
	void Edit( ClsWindow& Parent, LPPARSER pParser );
	
protected:
	// Overidables.
	virtual LRESULT OnInitDialog( LPPROPSHEETPAGE pPsp );
	virtual LRESULT OnCommand( UINT nNotifyCode, UINT nCtrlID, HWND hWndCtrl );
	virtual LRESULT WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam );

	// Helpers.
	void SetupControls();
	static LPTSTR StringArrayCopy( LPARRAY pArray, LPTSTR pszString );
	static void FreeKeyList( LPKEYLIST pKeyList );
	void FreeKeyHashes();
	static BOOL AddKeyword2Node( LPKEYWORDS pKeywords, LPTSTR pszKeyword );
	static BOOL Hash2List( LPKEYLIST pKeyList, LPPARSER pParser );
	BOOL ReadKeywords( LPCTSTR pszFilename );
	BOOL UseKeywords( LPKEYLIST pKeyList );

	// Static helpers.
	static int _cdecl CompareKeywords( LPTSTR *ppStr1, LPTSTR *ppStr2 );
	static void RemoveTrailingBlanks( LPTSTR pszString );
	
	// Data
	EditToolbar	m_Tools, m_Keys;
	ColorList	m_List;
	LPPARSER	m_pParser;
	ClsListBox	m_KeyList;
	ClsCheckBox	m_Case;
	KEYLIST		m_KeyLst;
	BOOL		m_bCase;
};

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Netherlands Netherlands
I have been programming for a hobby since 1985. I have started programming on the C= 64. After that I migrated to the C= Amiga which I traded in for a PC back in 1997 I believe. Back in 2000 I decided to lose a hobby and start developing software for a living.

Currently I am working mainly in developing software for building security and access control systems.

Comments and Discussions