// SyntaxRichTextBox.h
#pragma once

	
namespace SyntaxTextBox   {
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Data;
	using namespace System::Windows::Forms;
	using namespace System::Drawing;
	using namespace System::Drawing;
	using namespace System::Runtime::InteropServices;

	public ref class SyntaxList
	{
		
		System::Collections::ArrayList^ m_kwList;
		System::Drawing::Color m_color;
	public:
		SyntaxList()
		{
			this->m_kwList = gcnew System::Collections::ArrayList();
			m_color = System::Drawing::Color::Black;
		};
		~SyntaxList()
		{
		};
		System::Collections::ArrayList^ KeywordList()
		{
			return m_kwList;
		}
		void AddKeyword(System::String^ strKeyword)
		{
			this->m_kwList->Add(strKeyword);
		}
	};

	public ref class SyntaxSettings
	{
	public:
		SyntaxList m_Keywords;
		static System::Drawing::Color m_colorComment;
		static System::Drawing::Color m_colorString;
		static System::Drawing::Color m_colorDelimiter;
		static System::Drawing::Color m_colorDecimal;
		static System::Drawing::Color m_colorKeywords;
		static System::Drawing::Color m_colorIdent;
		static System::Boolean m_bSyntaxHighLighting = true;
		SyntaxSettings()
		{
			this->m_colorKeywords	= System::Drawing::Color::Blue;
			this->m_colorComment	= System::Drawing::Color::Gray;
			this->m_colorString		= System::Drawing::Color::DarkRed;
			this->m_colorDecimal	= System::Drawing::Color::DarkCyan;
			this->m_colorIdent		= System::Drawing::Color::Black;
			this->m_colorDelimiter  = System::Drawing::Color::Red; 
		};
	};

	public ref class SyntaxRichTextBox: public System::Windows::Forms::RichTextBox
	{
		// TODO: Add your methods for this class here.
	private:
		SyntaxTextBox::SyntaxSettings^ m_settings;
		static bool m_bPaint = true;
		static System::String^ m_strLine = "";
		static int m_nContentLength;
		static int m_nLineLength = 0;
		static int m_nLineStart = 0;
		static int m_nLineEnd = 0;
		static int m_nCurSelection = 0;
		static System::String^ m_strKeywords = "";
		void ProcessLine();
		void ColoringWord(int nStart, int nLength, System::Drawing::Color^ color);
		//void ProcessRegex(System::String^ strRegex, System::Drawing::Color^ color);
		//void CompileKeywords();
	public:
		SyntaxRichTextBox():System::Windows::Forms::RichTextBox()
		{
			m_nContentLength = 0;
			this->m_settings = gcnew SyntaxSettings();
			//this->CompileKeywords();
		};
		SyntaxTextBox::SyntaxSettings^ Settings()
		{
			return m_settings;
		};
		void ProcessAllLines();
	protected:
		virtual void WndProc(Message% m) override ;
		virtual void OnTextChanged(EventArgs^ e) override;
			
	};

	

	
}
