void CScintillaWnd::InitScintillaWnd(void) { SendMessage(SCI_SETCODEPAGE,SC_CP_UTF8);//UTF8 //SendMessage(SCI_USEPOPUP,0,0); //关闭右键菜单,改由父窗口view类响应 //设置全局默认style,默认style只在没有明确的选择时会被应用 SetAStyle(STYLE_DEFAULT, black, white, 11, "宋体"); SendMessage(SCI_STYLECLEARALL); // 将全局默认style应用到所有 //清空所有默认的Ctrl快捷键消息,避免产生乱码 //char key = 'A'; //while (key <= 'Z') //{ // int keyDefinition = key + (SCMOD_CTRL << 16); // SendMessage(SCI_CLEARCMDKEY,(WPARAM)keyDefinition,(LPARAM)0); // keyDefinition = key + ((SCMOD_CTRL+SCMOD_ALT) << 16); // SendMessage(SCI_CLEARCMDKEY,(WPARAM)keyDefinition,(LPARAM)0); // keyDefinition = key + ((SCMOD_CTRL+SCMOD_SHIFT) << 16); // SendMessage(SCI_CLEARCMDKEY,(WPARAM)keyDefinition,(LPARAM)0); // key += 1; //} //自动完成 SendMessage(SCI_AUTOCSETSEPARATOR, static_cast<WPARAM>(10), 0); //显示当前行的淡灰色背景 SendMessage(SCI_SETCARETLINEVISIBLE,TRUE,0); SendMessage(SCI_SETCARETLINEBACK, RGB(210,210,210),0); SendMessage(SCI_SETCARETLINEBACKALPHA,100,0); SetXmlLexer(); UpdateLineNumberWidth(); }
bool CMainWindow::Initialize() { m_hWndEdit = ::CreateWindow( L"Scintilla", L"Source", WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, *this, 0, hResource, 0); if (m_hWndEdit == NULL) return false; RECT rect; GetClientRect(*this, &rect); ::SetWindowPos(m_hWndEdit, HWND_TOP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW); m_directFunction = SendMessage(m_hWndEdit, SCI_GETDIRECTFUNCTION, 0, 0); m_directPointer = SendMessage(m_hWndEdit, SCI_GETDIRECTPOINTER, 0, 0); // Set up the global default style. These attributes are used wherever no explicit choices are made. CRegStdDWORD used2d(L"Software\\TortoiseSVN\\ScintillaDirect2D", TRUE); bool enabled2d = false; if (IsWindows7OrGreater() && DWORD(used2d)) enabled2d = true; std::wstring fontNameW = CRegStdString(L"Software\\TortoiseSVN\\UDiffFontName", L"Consolas"); std::string fontName; fontName = CUnicodeUtils::StdGetUTF8(fontNameW); SetAStyle(STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffFontSize", 10), fontName.c_str()); SendEditor(SCI_SETTABWIDTH, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffTabSize", 4)); SendEditor(SCI_SETREADONLY, TRUE); LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"_99999"); SendEditor(SCI_SETMARGINWIDTHN, 0, pix); SendEditor(SCI_SETMARGINWIDTHN, 1); SendEditor(SCI_SETMARGINWIDTHN, 2); //Set the default windows colors for edit controls SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW)); SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT)); SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT)); SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT)); if (enabled2d) { SendEditor(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITERETAIN); SendEditor(SCI_SETBUFFEREDDRAW, 0); } SendEditor(SCI_SETVIEWWS, 1); SendEditor(SCI_SETWHITESPACESIZE, 2); SendEditor(SCI_SETWHITESPACEFORE, true, ::GetSysColor(COLOR_3DSHADOW)); SendEditor(SCI_STYLESETVISIBLE, STYLE_CONTROLCHAR, TRUE); return true; }
bool CMainWindow::Initialize() { m_hWndEdit = ::CreateWindow( _T("Scintilla"), _T("Source"), WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, *this, 0, hResource, 0); if (m_hWndEdit == NULL) return false; RECT rect; GetClientRect(*this, &rect); ::SetWindowPos(m_hWndEdit, HWND_TOP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW); m_directFunction = SendMessage(m_hWndEdit, SCI_GETDIRECTFUNCTION, 0, 0); m_directPointer = SendMessage(m_hWndEdit, SCI_GETDIRECTPOINTER, 0, 0); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), // Reusing TortoiseBlame's setting which already have an user friendly // pane in TortoiseSVN's Settings dialog, while there is no such // pane for TortoiseUDiff. CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), CUnicodeUtils::StdGetUTF8(CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str()); SendEditor(SCI_SETTABWIDTH, 4); SendEditor(SCI_SETREADONLY, TRUE); LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"_99999"); SendEditor(SCI_SETMARGINWIDTHN, 0, pix); SendEditor(SCI_SETMARGINWIDTHN, 1); SendEditor(SCI_SETMARGINWIDTHN, 2); //Set the default windows colors for edit controls SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW)); SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT)); SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT)); SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT)); CRegStdDWORD used2d(L"Software\\TortoiseGit\\ScintillaDirect2D", FALSE); if (SysInfo::Instance().IsWin7OrLater() && DWORD(used2d)) { SendEditor(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITE); SendEditor(SCI_SETBUFFEREDDRAW, 0); } SendEditor(SCI_SETVIEWWS, 1); SendEditor(SCI_SETWHITESPACESIZE, 2); SendEditor(SCI_SETWHITESPACEFORE, true, ::GetSysColor(COLOR_3DSHADOW)); SendEditor(SCI_STYLESETVISIBLE, STYLE_CONTROLCHAR, TRUE); return true; }
void DMApp::InitialiseEditor() { SendEditor(SCI_SETLEXER, SCLEX_HTML); SendEditor(SCI_SETSTYLEBITS, 7); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(STYLE_DEFAULT, black, white, 12, "Courier New"); SendEditor(SCI_STYLECLEARALL); // Copies global style to all others }
void CMainWindow::SetupWindow(bool bUTF8) { SendEditor(SCI_SETCODEPAGE, bUTF8 ? SC_CP_UTF8 : GetACP()); SendEditor(SCI_SETUNDOCOLLECTION, 1); ::SetFocus(m_hWndEdit); SendEditor(EM_EMPTYUNDOBUFFER); SendEditor(SCI_SETSAVEPOINT); SendEditor(SCI_GOTOPOS, 0); SendEditor(SCI_CLEARDOCUMENTSTYLE, 0, 0); SendEditor(SCI_SETSTYLEBITS, 5, 0); //SetAStyle(SCE_DIFF_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_DIFF_COMMAND, RGB(0x0A, 0x24, 0x36)); SetAStyle(SCE_DIFF_POSITION, RGB(0xFF, 0, 0)); SetAStyle(SCE_DIFF_HEADER, RGB(0x80, 0, 0), RGB(0xFF, 0xFF, 0x80)); SetAStyle(SCE_DIFF_COMMENT, RGB(0, 0x80, 0)); SendEditor(SCI_STYLESETBOLD, SCE_DIFF_COMMENT, TRUE); SetAStyle(SCE_DIFF_DELETED, ::GetSysColor(COLOR_WINDOWTEXT), RGB(0xFF, 0x80, 0x80)); SetAStyle(SCE_DIFF_ADDED, ::GetSysColor(COLOR_WINDOWTEXT), RGB(0x80, 0xFF, 0x80)); SendEditor(SCI_SETLEXER, SCLEX_DIFF); SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)"revision"); SendEditor(SCI_COLOURISE, 0, -1); ::ShowWindow(m_hWndEdit, SW_SHOW); }
void CDialogEdit::InitialiseEditor() { // Punt if we already have a window if (::IsWindow(m_hwndEditor)) return; // Create editor window m_hwndEditor = CreateWindowEx(0, "Scintilla", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN, 0, 0, 500, 400, GetSafeHwnd(), NULL /*(HMENU)GuiID*/, AfxGetApp()->m_hInstance, NULL); // Did we get the editor window? if (!::IsWindow(m_hwndEditor)) { TRACE( "Unable to create editor window\n" ); return; } // CPP lexer SendEditor(SCI_SETLEXER, SCLEX_CPP); // Set number of style bits to use SendEditor(SCI_SETSTYLEBITS, 5); // Set tab width SendEditor(SCI_SETTABWIDTH, 4); // Use CPP keywords SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)g_cppKeyWords); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(STYLE_DEFAULT, black, white, 10, "Courier New"); // Set caret foreground color //SendEditor(SCI_SETCARETFORE, RGB(255, 255, 255)); // Set all styles SendEditor(SCI_STYLECLEARALL); // Set selection color SendEditor(SCI_SETSELBACK, TRUE, RGB(240, 240, 240)); // Set syntax colors for ( long i = 0; g_rgbSyntaxCpp[i].iItem != -1; i++ ) { SendEditor(SCI_STYLESETFORE, g_rgbSyntaxCpp[i].iItem, g_rgbSyntaxCpp[i].rgb); } SendEditor(SCI_SETHSCROLLBAR, false); //SendEditor(SCI_SETVIEWWS, SCWS_VISIBLEALWAYS); SendEditor(SCI_SETMARGINWIDTHN, 0, 32); SendEditor(SCI_SETMARGINWIDTHN, 1, 0); }
bool CMainWindow::LoadFile(LPCTSTR filename) { SendEditor(SCI_SETREADONLY, FALSE); SendEditor(SCI_CLEARALL); SendEditor(EM_EMPTYUNDOBUFFER); SendEditor(SCI_SETSAVEPOINT); SendEditor(SCI_CANCEL); SendEditor(SCI_SETUNDOCOLLECTION, 0); FILE *fp = NULL; _tfopen_s(&fp, filename, _T("rb")); if (fp) { //SetTitle(); char data[4096]; int lenFile = fread(data, 1, sizeof(data), fp); bool bUTF8 = IsUTF8(data, lenFile); while (lenFile > 0) { SendEditor(SCI_ADDTEXT, lenFile, reinterpret_cast<LPARAM>(static_cast<char *>(data))); lenFile = fread(data, 1, sizeof(data), fp); } fclose(fp); SendEditor(SCI_SETCODEPAGE, bUTF8 ? SC_CP_UTF8 : GetACP()); } else { return false; } SendEditor(SCI_SETUNDOCOLLECTION, 1); ::SetFocus(m_hWndEdit); SendEditor(EM_EMPTYUNDOBUFFER); SendEditor(SCI_SETSAVEPOINT); SendEditor(SCI_GOTOPOS, 0); SendEditor(SCI_SETREADONLY, TRUE); SendEditor(SCI_CLEARDOCUMENTSTYLE, 0, 0); SendEditor(SCI_SETSTYLEBITS, 5, 0); //SetAStyle(SCE_DIFF_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_DIFF_COMMAND, RGB(0x0A, 0x24, 0x36)); SetAStyle(SCE_DIFF_POSITION, RGB(0xFF, 0, 0)); SetAStyle(SCE_DIFF_HEADER, RGB(0x80, 0, 0), RGB(0xFF, 0xFF, 0x80)); SetAStyle(SCE_DIFF_COMMENT, RGB(0, 0x80, 0)); SendEditor(SCI_STYLESETBOLD, SCE_DIFF_COMMENT, TRUE); SetAStyle(SCE_DIFF_DELETED, ::GetSysColor(COLOR_WINDOWTEXT), RGB(0xFF, 0x80, 0x80)); SetAStyle(SCE_DIFF_ADDED, ::GetSysColor(COLOR_WINDOWTEXT), RGB(0x80, 0xFF, 0x80)); SendEditor(SCI_SETLEXER, SCLEX_DIFF); SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)"revision"); SendEditor(SCI_COLOURISE, 0, -1); ::ShowWindow(m_hWndEdit, SW_SHOW); return true; }
bool CMainWindow::Initialize() { m_hWndEdit = ::CreateWindow( L"Scintilla", L"Source", WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, *this, nullptr, hResource, nullptr); if (!m_hWndEdit) return false; RECT rect; GetClientRect(*this, &rect); ::SetWindowPos(m_hWndEdit, HWND_TOP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW); m_directFunction = SendMessage(m_hWndEdit, SCI_GETDIRECTFUNCTION, 0, 0); m_directPointer = SendMessage(m_hWndEdit, SCI_GETDIRECTPOINTER, 0, 0); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffFontSize", 10), CUnicodeUtils::StdGetUTF8(CRegStdString(L"Software\\TortoiseGit\\UDiffFontName", L"Consolas")).c_str()); SendEditor(SCI_SETTABWIDTH, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffTabSize", 4)); SendEditor(SCI_SETREADONLY, TRUE); LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<LPARAM>("_99999")); SendEditor(SCI_SETMARGINWIDTHN, 0, pix); SendEditor(SCI_SETMARGINWIDTHN, 1); SendEditor(SCI_SETMARGINWIDTHN, 2); //Set the default windows colors for edit controls SetupColors(false); if (CRegStdDWORD(L"Software\\TortoiseGit\\ScintillaDirect2D", FALSE) != FALSE) { SendEditor(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITERETAIN); SendEditor(SCI_SETBUFFEREDDRAW, 0); } SendEditor(SCI_SETVIEWWS, 1); SendEditor(SCI_SETWHITESPACESIZE, 2); SendEditor(SCI_STYLESETVISIBLE, STYLE_CONTROLCHAR, TRUE); return true; }
void CMainWindow::SetupColors(bool recolorize) { SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW)); SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT)); SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT)); SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_SETWHITESPACEFORE, true, ::GetSysColor(COLOR_3DSHADOW)); SendEditor(SCI_CLEARDOCUMENTSTYLE, 0, 0); HIGHCONTRAST highContrast = { 0 }; highContrast.cbSize = sizeof(HIGHCONTRAST); if (SystemParametersInfo(SPI_GETHIGHCONTRAST, 0, &highContrast, 0) == TRUE && (highContrast.dwFlags & HCF_HIGHCONTRASTON)) { SendEditor(SCI_SETLEXER, SCLEX_NULL); return; } //SetAStyle(SCE_DIFF_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_DIFF_COMMAND, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForeCommandColor", UDIFF_COLORFORECOMMAND), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackCommandColor", UDIFF_COLORBACKCOMMAND)); SetAStyle(SCE_DIFF_POSITION, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForePositionColor", UDIFF_COLORFOREPOSITION), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackPositionColor", UDIFF_COLORBACKPOSITION)); SetAStyle(SCE_DIFF_HEADER, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForeHeaderColor", UDIFF_COLORFOREHEADER), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackHeaderColor", UDIFF_COLORBACKHEADER)); SetAStyle(SCE_DIFF_COMMENT, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForeCommentColor", UDIFF_COLORFORECOMMENT), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackCommentColor", UDIFF_COLORBACKCOMMENT)); SendEditor(SCI_STYLESETBOLD, SCE_DIFF_COMMENT, TRUE); for (int style : { SCE_DIFF_ADDED, SCE_DIFF_PATCH_ADD, SCE_DIFF_PATCH_DELETE }) { SetAStyle(style, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForeAddedColor", UDIFF_COLORFOREADDED), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackAddedColor", UDIFF_COLORBACKADDED)); } for (int style : { SCE_DIFF_DELETED, SCE_DIFF_REMOVED_PATCH_ADD, SCE_DIFF_REMOVED_PATCH_DELETE }) { SetAStyle(style, CRegStdDWORD(L"Software\\TortoiseGit\\UDiffForeRemovedColor", UDIFF_COLORFOREREMOVED), CRegStdDWORD(L"Software\\TortoiseGit\\UDiffBackRemovedColor", UDIFF_COLORBACKREMOVED)); } SendEditor(SCI_SETLEXER, SCLEX_DIFF); SendEditor(SCI_SETKEYWORDS, 0, reinterpret_cast<LPARAM>("revision")); if (recolorize) SendEditor(SCI_COLOURISE, 0, -1); }
void ShaderEditOverlay::initialiseSelectionList() { mSelectionList.Command(SCI_SETSTYLEBITS, 7); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(mSelectionList, STYLE_DEFAULT, 0xFFFFFFFF, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); mSelectionList.Command(SCI_STYLECLEARALL); // Copies global style to all others mSelectionList.Command(SCI_SETMARGINWIDTHN, 1, 0);//Calculate correct width mSelectionList.Command(SCI_SETUSETABS, 1); mSelectionList.Command(SCI_SETTABWIDTH, 4); mSelectionList.Command(SCI_SETSELBACK, 1, 0xD0CC9966); mSelectionList.Command(SCI_SETCARETFORE, 0x00FFFFFF, 0); mSelectionList.Command(SCI_SETCARETLINEVISIBLE, 1); mSelectionList.Command(SCI_SETCARETLINEBACK, 0xFFFFFFFF); mSelectionList.Command(SCI_SETCARETLINEBACKALPHA, 0x20); }
void CMainWindow::SetupWindow(bool bUTF8) { SendEditor(SCI_SETCODEPAGE, bUTF8 ? SC_CP_UTF8 : GetACP()); SendEditor(SCI_SETUNDOCOLLECTION, 1); ::SetFocus(m_hWndEdit); SendEditor(EM_EMPTYUNDOBUFFER); SendEditor(SCI_SETSAVEPOINT); SendEditor(SCI_GOTOPOS, 0); SendEditor(SCI_CLEARDOCUMENTSTYLE, 0, 0); SendEditor(SCI_SETSTYLEBITS, 5, 0); //SetAStyle(SCE_DIFF_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_DIFF_COMMAND, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForeCommandColor", UDIFF_COLORFORECOMMAND), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackCommandColor", UDIFF_COLORBACKCOMMAND)); SetAStyle(SCE_DIFF_POSITION, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForePositionColor", UDIFF_COLORFOREPOSITION), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackPositionColor", UDIFF_COLORBACKPOSITION)); SetAStyle(SCE_DIFF_HEADER, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForeHeaderColor", UDIFF_COLORFOREHEADER), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackHeaderColor", UDIFF_COLORBACKHEADER)); SetAStyle(SCE_DIFF_COMMENT, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForeCommentColor", UDIFF_COLORFORECOMMENT), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackCommentColor", UDIFF_COLORBACKCOMMENT)); SendEditor(SCI_STYLESETBOLD, SCE_DIFF_COMMENT, TRUE); SetAStyle(SCE_DIFF_ADDED, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForeAddedColor", UDIFF_COLORFOREADDED), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackAddedColor", UDIFF_COLORBACKADDED)); SetAStyle(SCE_DIFF_DELETED, CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffForeRemovedColor", UDIFF_COLORFOREREMOVED), CRegStdDWORD(L"Software\\TortoiseSVN\\UDiffBackRemovedColor", UDIFF_COLORBACKREMOVED)); SendEditor(SCI_SETLEXER, SCLEX_DIFF); SendEditor(SCI_SETKEYWORDS, 0, (LPARAM)"revision"); SendEditor(SCI_COLOURISE, 0, -1); ::ShowWindow(m_hWndEdit, SW_SHOW); }
void CCsgIdeView::OnInitialUpdate() { CScintillaView::OnInitialUpdate(); CScintillaCtrl& rCtrl = GetCtrl(); //Setup the Lexer rCtrl.SetLexer(SCLEX_LUA); rCtrl.StyleSetFont(STYLE_DEFAULT, "Consolas"); rCtrl.StyleSetSize(STYLE_DEFAULT, 10); rCtrl.SetKeyWords(0, LuaKeywords); //Setup styles SetAStyle(STYLE_DEFAULT, RGB(0, 0, 0), RGB(0xff, 0xff, 0xff), 11, "Consolas"); rCtrl.StyleClearAll(); SetAStyle(SCE_LUA_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_LUA_COMMENT, RGB(0, 0x80, 0)); SetAStyle(SCE_LUA_COMMENTLINE, RGB(0, 0x80, 0)); SetAStyle(SCE_LUA_COMMENTDOC, RGB(0, 0x80, 0)); SetAStyle(SCE_LUA_NUMBER, RGB(0, 0x80, 0x80)); SetAStyle(SCE_LUA_WORD, RGB(0, 0, 0x80)); //rCtrl.StyleSetBold(SCE_LUA_WORD, 1); SetAStyle(SCE_LUA_STRING, RGB(0x80, 0, 0x80)); SetAStyle(SCE_LUA_IDENTIFIER, RGB(0, 0, 0)); SetAStyle(SCE_LUA_PREPROCESSOR, RGB(0x80, 0, 0)); SetAStyle(SCE_LUA_OPERATOR, RGB(0x80, 0x80, 0)); rCtrl.SetKeyWords(1, LuaFunctions); SetAStyle(SCE_LUA_WORD2, RGB(0x20, 0x20, 0x80)); //rCtrl.StyleSetBold(SCE_LUA_WORD2, 1); rCtrl.SetKeyWords(2, UserFunctions); SetAStyle(SCE_LUA_WORD3, RGB(150, 0, 50)); //rCtrl.StyleSetBold(SCE_LUA_WORD3, 1); rCtrl.SetKeyWords(3, UserConstants); SetAStyle(SCE_LUA_WORD4, RGB(255, 0, 0)); //rCtrl.StyleSetBold(SCE_LUA_WORD4, 1); rCtrl.SetKeyWords(4, UserVariables); SetAStyle(SCE_LUA_WORD5, RGB(200, 50, 0)); //rCtrl.StyleSetBold(SCE_LUA_WORD5, 1); //Setup folding rCtrl.SetMarginWidthN(2, 16); rCtrl.SetMarginSensitiveN(2, TRUE); rCtrl.SetMarginTypeN(2, SC_MARGIN_SYMBOL); rCtrl.SetMarginMaskN(2, SC_MASK_FOLDERS); rCtrl.SetProperty(_T("fold"), _T("1")); rCtrl.SetTabWidth(4); //Setup markers DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0xFF)); DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); //Setup auto completion rCtrl.AutoCSetSeparator(10); //Use a separator of line feed //Setup call tips rCtrl.SetMouseDwellTime(1000); //Enable Multiple selection rCtrl.SetMultipleSelection(TRUE); CDocument *pDoc = GetDocument(); LoadFile(pDoc->GetPathName()); }
void CCppDocContentView::OnInitialUpdate() { //Let the base class do its thing CScintillaView::OnInitialUpdate(); CScintillaCtrl& rCtrl = GetCtrl(); //Setup the Lexer rCtrl.SetLexer(SCLEX_CPP); rCtrl.SetKeyWords(0, cppKeyWords); //Setup styles SetAStyle(STYLE_DEFAULT, RGB(0, 0, 0), RGB(0xff, 0xff, 0xff), 10, "Verdana"); rCtrl.StyleClearAll(); SetAStyle(SCE_C_DEFAULT, RGB(0, 0, 0)); SetAStyle(SCE_C_COMMENT, RGB(0, 0x80, 0)); SetAStyle(SCE_C_COMMENTLINE, RGB(0, 0x80, 0)); SetAStyle(SCE_C_COMMENTDOC, RGB(0, 0x80, 0)); SetAStyle(SCE_C_COMMENTLINEDOC, RGB(0, 0x80, 0)); SetAStyle(SCE_C_COMMENTDOCKEYWORD, RGB(0, 0x80, 0)); SetAStyle(SCE_C_COMMENTDOCKEYWORDERROR, RGB(0, 0x80, 0)); SetAStyle(SCE_C_NUMBER, RGB(0, 0x80, 0x80)); SetAStyle(SCE_C_WORD, RGB(0, 0, 0x80)); rCtrl.StyleSetBold(SCE_C_WORD, 1); SetAStyle(SCE_C_STRING, RGB(0x80, 0, 0x80)); SetAStyle(SCE_C_IDENTIFIER, RGB(0, 0, 0)); SetAStyle(SCE_C_PREPROCESSOR, RGB(0x80, 0, 0)); SetAStyle(SCE_C_OPERATOR, RGB(0x80, 0x80, 0)); //Setup folding rCtrl.SetMarginWidthN(2, 16); rCtrl.SetMarginSensitiveN(2, TRUE); rCtrl.SetMarginTypeN(2, SC_MARGIN_SYMBOL); rCtrl.SetMarginMaskN(2, SC_MASK_FOLDERS); rCtrl.SetProperty(_T("fold"), _T("1")); //Setup markers DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0xFF)); DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0)); //Setup auto completion rCtrl.AutoCSetSeparator(10); //Use a separator of line feed //Setup call tips rCtrl.SetMouseDwellTime(1000); //Enable Multiple selection rCtrl.SetMultipleSelection(TRUE); //Set Tab width to 2 characters rCtrl.SetTabWidth(2); //Turn off default context menu rCtrl.SendMessage(SCI_USEPOPUP, 0, 0); //Turn on line numbers rCtrl.SetMarginWidthN(0, 32); #ifdef _DEBUG AfxDump(this); #endif }
bool CMainWindow::Initialize() { CRegStdDWORD pos(_T("Software\\TortoiseGit\\UDiffViewerPos"), 0); CRegStdDWORD width(_T("Software\\TortoiseGit\\UDiffViewerWidth"), (DWORD)640); CRegStdDWORD height(_T("Software\\TortoiseGit\\UDiffViewerHeight"), (DWORD)480); if (DWORD(pos) && DWORD(width) && DWORD(height)) { RECT rc; rc.left = LOWORD(DWORD(pos)); rc.top = HIWORD(DWORD(pos)); rc.right = rc.left + DWORD(width); rc.bottom = rc.top + DWORD(height); HMONITOR hMon = MonitorFromRect(&rc, MONITOR_DEFAULTTONULL); if (hMon) { // only restore the window position if the monitor is valid MoveWindow(*this, LOWORD(DWORD(pos)), HIWORD(DWORD(pos)), DWORD(width), DWORD(height), FALSE); } } m_hWndEdit = ::CreateWindow( _T("Scintilla"), _T("Source"), WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, *this, 0, hResource, 0); if (m_hWndEdit == NULL) return false; RECT rect; GetClientRect(*this, &rect); ::SetWindowPos(m_hWndEdit, HWND_TOP, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW); m_directFunction = SendMessage(m_hWndEdit, SCI_GETDIRECTFUNCTION, 0, 0); m_directPointer = SendMessage(m_hWndEdit, SCI_GETDIRECTPOINTER, 0, 0); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), // Reusing TortoiseBlame's setting which already have an user friendly // pane in TortoiseSVN's Settings dialog, while there is no such // pane for TortoiseUDiff. CRegStdDWORD(_T("Software\\TortoiseGit\\BlameFontSize"), 10), WideToMultibyte(CRegStdString(_T("Software\\TortoiseGit\\BlameFontName"), _T("Courier New"))).c_str()); SendEditor(SCI_SETTABWIDTH, 4); SendEditor(SCI_SETREADONLY, TRUE); LRESULT pix = SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, (LPARAM)"_99999"); SendEditor(SCI_SETMARGINWIDTHN, 0, pix); SendEditor(SCI_SETMARGINWIDTHN, 1); SendEditor(SCI_SETMARGINWIDTHN, 2); //Set the default windows colors for edit controls SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT)); SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW)); SendEditor(SCI_SETSELFORE, TRUE, ::GetSysColor(COLOR_HIGHLIGHTTEXT)); SendEditor(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT)); SendEditor(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT)); return true; }
void CScintillaWnd::SetXmlLexer() { SendMessage(SCI_SETLEXER, SCLEX_XML); SendMessage(SCI_SETSTYLEBITS, 7); // 设置全局style. 这些属性会在无其它选择时被应用. SetAStyle(STYLE_DEFAULT, black, white, 11, "Verdana"); SendMessage(SCI_STYLECLEARALL); const COLORREF CR_RED = RGB(0xFF, 0, 0); const COLORREF CR_OFFWHITE = RGB(0xFF, 0xFB, 0xF0); const COLORREF CR_DARKGREEN = RGB(0, 0x80, 0); const COLORREF CR_DARKBLUE = RGB(0, 0, 0x80); SendMessage(SCI_STYLESETBOLD, STYLE_CONTROLCHAR, 1); // Hypertext default is used for all the document's text SetAStyle(SCE_H_DEFAULT, black, white, 11, "宋体"); SetAStyle(SCE_H_TAG, 128); SetAStyle(SCE_H_TAGEND, 128); SetAStyle(SCE_H_ATTRIBUTE, CR_RED); SetAStyle(SCE_H_NUMBER, RGB(0x80,0,0x80)); SetAStyle(SCE_H_DOUBLESTRING, RGB(0,0,0x80)); SetAStyle(SCE_H_SINGLESTRING, RGB(0,0,0x80)); SetAStyle(SCE_H_OTHER, RGB(0x80,0,0x80)); SetAStyle(SCE_H_COMMENT, RGB(0,0x80,0)); SetAStyle(SCE_H_ENTITY, RGB(0x80,0,0x80)); SetAStyle(SCE_H_XMLSTART, CR_DARKBLUE); // <? SetAStyle(SCE_H_XMLEND, CR_DARKBLUE); // ?> SetAStyle(SCE_HB_DEFAULT, black); SetAStyle(SCE_HB_COMMENTLINE, CR_DARKGREEN); SetAStyle(SCE_HB_NUMBER, RGB(0,0x80,0x80)); SetAStyle(SCE_HB_WORD, CR_DARKBLUE); SendMessage(SCI_STYLESETBOLD, SCE_HB_WORD, 1); SetAStyle(SCE_HB_STRING, RGB(0x80,0,0x80)); SetAStyle(SCE_HB_IDENTIFIER, black); const COLORREF lightBlue = RGB(0xA6, 0xCA, 0xF0); SendMessage(SCI_STYLESETBACK, SCE_HB_STRINGEOL, RGB(0x7F,0x7F,0xFF)); SendMessage(SCI_STYLESETFONT, SCE_HB_COMMENTLINE, reinterpret_cast<LPARAM>("宋体")); // 设置代码折叠规则 SendMessage(SCI_SETPROPERTY, (WPARAM)"fold", (LPARAM)"1"); SendMessage(SCI_SETPROPERTY, (WPARAM)"fold.compact", (LPARAM)"0"); SendMessage(SCI_SETPROPERTY, (WPARAM)"fold.html", (LPARAM)"1"); SendMessage(SCI_SETPROPERTY, (WPARAM)"fold.html.preprocessor", (LPARAM)"1"); SendMessage(SCI_SETMARGINWIDTHN, MARGIN_SCRIPT_FOLD_INDEX, 0); SendMessage(SCI_SETMARGINTYPEN, MARGIN_SCRIPT_FOLD_INDEX, SC_MARGIN_SYMBOL); SendMessage(SCI_SETMARGINMASKN, MARGIN_SCRIPT_FOLD_INDEX, SC_MASK_FOLDERS); SendMessage(SCI_SETMARGINWIDTHN, MARGIN_SCRIPT_FOLD_INDEX, 20); SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_PLUS); //折叠时显示 + SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS); //打开时显示 - SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY); SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY); SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY); SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY); SendMessage(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY); SendMessage(SCI_SETFOLDFLAGS, 16, 0); // 16 折叠完后画一条线 SendMessage(SCI_SETMARGINSENSITIVEN, MARGIN_SCRIPT_FOLD_INDEX, 1); //---------代码折叠设置完毕----------- }
BOOL CScriptDlg::OnInitDialog() { CExtResizableDialog::OnInitDialog(); CRect WindowRect; CWnd* pSize = GetDlgItem(IDC_SCRIPT); pSize->GetWindowRect(&WindowRect); pSize->DestroyWindow(); ScreenToClient(&WindowRect); m_Script.Create("Scintilla", WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL|WS_BORDER, WindowRect, this, 10000); m_Script.Init(); SetAStyle(STYLE_DEFAULT, RGB(255, 255, 255), RGB(255, 255, 255), 10, "Courier New" ); ////////////////////////// // Setup Scintilla window ////////////////////////// m_Script.SendMessage(SCI_SETCARETLINEBACK, RGB(240,240,255),0 ); m_Script.SendMessage(SCI_SETCARETLINEVISIBLE, (long)true, 0); m_Script.ID = 0; m_Script.ModifyStyleEx(0,WS_EX_WINDOWEDGE,0); m_Script.SetFocus(); SetPythonStyle(m_Script); // Remove margins to the left m_Help.SendMessage(SCI_SETMARGINWIDTHN, 0, 0); m_Help.SendMessage(SCI_SETMARGINWIDTHN, 1, 0); InitPythonInfo(); m_Script.SetText(m_script); HelpMe(); UpdateList(); UpdateClassList(); // Resizing dlgMan.Load(this->m_hWnd, "Software\\Construct\\ScriptDlg3a"); dlgAnchor.Init(this->m_hWnd); dlgAnchor.Add(IDC_HELPLINE, ANCHOR_TOP | ANCHOR_LEFT | ANCHOR_RIGHT); dlgAnchor.Add(m_Script, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT); dlgAnchor.Add(m_Help, ANCHOR_LEFT | ANCHOR_BOTTOM | ANCHOR_RIGHT); dlgAnchor.Add(IDC_FUNCTIONS, ANCHOR_TOP | ANCHOR_RIGHT | ANCHOR_BOTTOM); dlgAnchor.Add(IDC_CLASSES, ANCHOR_RIGHT | ANCHOR_BOTTOM); dlgAnchor.Add(IDOK, ANCHOR_RIGHT | ANCHOR_BOTTOM); dlgAnchor.Add(IDCANCEL, ANCHOR_RIGHT | ANCHOR_BOTTOM); // Toolbar m_wndToolBar.LoadToolBar(IDR_PYTHONTOOLBAR); CWnd::RepositionBars(0,0xFFFF,0); return TRUE; }
void ShaderEditOverlay::initialiseShaderEditor() { mShaderEditor.Command(SCI_SETSTYLEBITS, 7); mLexer->SetLexer(SCLEX_CPP); mLexer->SetWordList(0, glslKeyword); mLexer->SetWordList(1, glslType); mLexer->SetWordList(4, glslBuiltin); mLexer->PropSet("fold", "1"); // Set up the global default style. These attributes are used wherever no explicit choices are made. SetAStyle(mShaderEditor, STYLE_DEFAULT, 0xFFFFFFFF, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); mShaderEditor.Command(SCI_STYLECLEARALL); // Copies global style to all others SetAStyle(mShaderEditor, STYLE_INDENTGUIDE, 0xFFC0C0C0, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); SetAStyle(mShaderEditor, STYLE_BRACELIGHT, 0xFF00FF00, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); SetAStyle(mShaderEditor, STYLE_BRACEBAD, 0xFF0000FF, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); SetAStyle(mShaderEditor, STYLE_LINENUMBER, 0xFFC0C0C0, 0xD0333333, 16, "c:/windows/fonts/cour.ttf"); mShaderEditor.Command(SCI_SETFOLDMARGINCOLOUR, 1, 0xD01A1A1A); mShaderEditor.Command(SCI_SETFOLDMARGINHICOLOUR, 1, 0xD01A1A1A); mShaderEditor.Command(SCI_SETSELBACK, 1, 0xD0CC9966); mShaderEditor.Command(SCI_SETCARETFORE, 0xFFFFFFFF, 0); mShaderEditor.Command(SCI_SETCARETLINEVISIBLE, 1); mShaderEditor.Command(SCI_SETCARETLINEBACK, 0xFFFFFFFF); mShaderEditor.Command(SCI_SETCARETLINEBACKALPHA, 0x20); mShaderEditor.Command(SCI_SETMARGINWIDTHN, 0, 44);//Calculate correct width mShaderEditor.Command(SCI_SETMARGINWIDTHN, 1, 20);//Calculate correct width mShaderEditor.Command(SCI_SETMARGINMASKN, 1, SC_MASK_FOLDERS);//Calculate correct width for (int i = 0 ; i < NB_FOLDER_STATE ; i++) { mShaderEditor.Command(SCI_MARKERDEFINE, markersArray[FOLDER_TYPE][i], markersArray[4][i]); mShaderEditor.Command(SCI_MARKERSETBACK, markersArray[FOLDER_TYPE][i], 0xFF6A6A6A); mShaderEditor.Command(SCI_MARKERSETFORE, markersArray[FOLDER_TYPE][i], 0xFF333333); } mShaderEditor.Command(SCI_SETUSETABS, 1); mShaderEditor.Command(SCI_SETTABWIDTH, 4); mShaderEditor.Command(SCI_SETINDENTATIONGUIDES, SC_IV_REAL); SetAStyle(mShaderEditor, SCE_C_DEFAULT, 0xFFFFFFFF, 0xD0000000, 16, "c:/windows/fonts/cour.ttf"); SetAStyle(mShaderEditor, SCE_C_WORD, 0xFF0066FF, 0xD0000000); SetAStyle(mShaderEditor, SCE_C_WORD2, 0xFFFFFF00, 0xD0000000); //WTF??? SetAStyle(SCE_C_GLOBALCLASS, 0xFF0000FF, 0xFF000000); SetAStyle(mShaderEditor, SCE_C_PREPROCESSOR, 0xFFC0C0C0, 0xD0000000); SetAStyle(mShaderEditor, SCE_C_NUMBER, 0xFF0080FF, 0xD0000000); SetAStyle(mShaderEditor, SCE_C_OPERATOR, 0xFF00CCFF, 0xD0000000); SetAStyle(mShaderEditor, SCE_C_COMMENT, 0xFF00FF00, 0xD0000000); SetAStyle(mShaderEditor, SCE_C_COMMENTLINE, 0xFF00FF00, 0xD0000000); }