void LuaScriptEditorView::SetupSourceEditor()
{
   StyleSetFont(STYLE_DEFAULT, "Courier New");
   StyleSetSize(STYLE_DEFAULT, 11);
   SetEdgeColumn(100);
   SetEdgeMode(EDGE_LINE);
   SetMarginWidthN(0, 50); // margin 0 displays line numbers, but has default width 0

   StyleSetFore(0,  RGB(0x80, 0x80, 0x80));
   StyleSetFore(1,  RGB(0x00, 0x7f, 0x00));
   StyleSetFore(2,  RGB(0x00, 0x7f, 0x00));
   StyleSetFore(3,  RGB(0x7f, 0x7f, 0x7f));
   StyleSetFore(4,  RGB(0x00, 0x7f, 0x7f));
   StyleSetFore(5,  RGB(0x00, 0x00, 0x7f));
   StyleSetFore(6,  RGB(0x7f, 0x00, 0x7f));
   StyleSetFore(7,  RGB(0x7f, 0x00, 0x7f));
   StyleSetFore(8,  RGB(0x00, 0x7f, 0x7f));
   StyleSetFore(9,  RGB(0x7f, 0x7f, 0x7f));
   StyleSetFore(10, RGB(0x00, 0x00, 0x00));
   StyleSetFore(11, RGB(0x00, 0x00, 0x00));
   StyleSetBold(5,  true);
   StyleSetBold(10, true);

   SetLexer(SCLEX_LUA);

   // set Lua keywords and add RemotePhotoTool specific classes
   SetKeyWords(0,
      "and break do else elseif end for function if in "
      "local nil not or repeat return then until while "
      "App Sys Constants RemoteReleaseControl SourceDevice "
      "ImageProperty DeviceProperty ShootingMode Viewfinder "
      "BulbReleaseControl");

   SetTabWidth(3);
   SetUseTabs(true);

   // only notify about text edits in SCEN_CHANGE messages
   SetModEventMask(SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT);
}
Пример #2
0
void ScriptEditCtrl::Impl::PreSubclassWindow()
{
	self_->m_hWnd = m_hWnd;	// expose HWND

	SetupDirectAccess();

	// If we are running as Unicode, then use the UTF8 codepage
#ifdef _UNICODE
	SetCodePage(SC_CP_UTF8);
#endif

	SetLexer(SCLEX_LUA);
	StyleSetFont(STYLE_DEFAULT, "Lucida Console");
	StyleSetSize(STYLE_DEFAULT, 10);
	SetKeyWords(0, LuaKeywords);
	SetKeyWords(1, LuaFunctions);
	if (enable_input_attribs_)
		SetKeyWords(2, LuaUser);
	SetKeyWords(3, ConcatAttributes().c_str());

	COLORREF comment= RGB(0,128,128);
	COLORREF string= RGB(128,128,0);

	StyleSetFore(SCE_LUA_COMMENT, comment);
	StyleSetFore(SCE_LUA_COMMENTLINE, comment);
	StyleSetFore(SCE_LUA_COMMENTDOC, comment);
	StyleSetFore(SCE_LUA_NUMBER, RGB(0,0,255));
	StyleSetFore(SCE_LUA_WORD, RGB(34,78,160));		// keywords
	StyleSetFore(SCE_LUA_STRING, string);
	StyleSetFore(SCE_LUA_CHARACTER, string);
	StyleSetFore(SCE_LUA_LITERALSTRING, string);
	StyleSetFore(SCE_LUA_WORD2, RGB(53,113,202));	// functions
	StyleSetFore(SCE_LUA_WORD3, RGB(124,37,203));	// test & number
	StyleSetBack(SCE_LUA_WORD3, CalcColor(::GetSysColor(COLOR_WINDOW), RGB(0,0,255), 0.95f));
	StyleSetFore(SCE_LUA_WORD4, RGB(164,97,49));	// todo: attributes

	StyleSetFont(SCE_LUA_WORD, "Lucida Console");
	StyleSetSize(SCE_LUA_WORD, 10);
	StyleSetBold(SCE_LUA_WORD, true);

	//#define SCE_LUA_PREPROCESSOR 9
	//#define SCE_LUA_OPERATOR 10
	//#define SCE_LUA_IDENTIFIER 11
	//#define SCE_LUA_STRINGEOL 12
	//#define SCE_LUA_WORD2 13
	//#define SCE_LUA_WORD3 14
	//#define SCE_LUA_WORD4 15
	//#define SCE_LUA_WORD5 16
	//#define SCE_LUA_WORD6 17
	//#define SCE_LUA_WORD7 18
	//#define SCE_LUA_WORD8 19

	Colorize(0, -1);

	//MarkerDefine(MARKER_POINTER, SC_MARK_ARROW);
	//MarkerSetBack(MARKER_POINTER, RGB(255,255,0));

	//MarkerDefine(MARKER_BREAKPOINT, SC_MARK_ROUNDRECT);
	//MarkerSetBack(MARKER_BREAKPOINT, RGB(0,0,255));

	//MarkerDefine(MARKER_ERROR, SC_MARK_ARROW);
	//MarkerSetBack(MARKER_ERROR, RGB(255,0,0));

	int width= 0;
	SetMarginWidthN(1, width);

	SetScrollWidthTracking(true);
	SetScrollWidth(1);

	SetWrapMode(SC_WRAP_WORD);
	SetWrapVisualFlags(SC_WRAPVISUALFLAG_END);

	SetSelBack(true, CalcShade(::GetSysColor(COLOR_HIGHLIGHT), 50.0f));

	SetTabWidth(4);
	SetIndent(4);

	DWORD pixels= 1;
	::SystemParametersInfo(SPI_GETCARETWIDTH, 0, &pixels, 0);
	SetCaretWidth(pixels);

	// hwnd is attached, but message processing is not working yet, we are not yet subclassed,
	// so postpone this WM_NCCALCSIZE call:
	PostMessage(WM_APP+1234);
}