/* TextEditor::setupFoldMargin * Sets up the code folding margin *******************************************************************/ void TextEditor::setupFoldMargin(TextStyle* margin_style) { if (!txed_fold_enable) { SetMarginWidth(1, 0); return; } wxColour col_fg, col_bg; if (margin_style) { col_fg = WXCOL(margin_style->getForeground()); col_bg = WXCOL(margin_style->getBackground()); } else { col_fg = WXCOL(StyleSet::currentSet()->getStyle("foldmargin")->getForeground()); col_bg = WXCOL(StyleSet::currentSet()->getStyle("foldmargin")->getBackground()); } SetMarginType(1, wxSTC_MARGIN_SYMBOL); SetMarginWidth(1, 16); SetMarginSensitive(1, true); SetMarginMask(1, wxSTC_MASK_FOLDERS); SetFoldMarginColour(true, col_bg); SetFoldMarginHiColour(true, col_bg); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, col_bg, col_fg); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, col_bg, col_fg); }
Edit::Edit (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; m_FoldingID = 2; // initialize language m_language = NULL; // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers MarkerDefine (wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, wxT("BLACK"), wxT("WHITE")); MarkerDefine (wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, wxT("BLACK"), wxT("WHITE")); MarkerDefine (wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); MarkerDefine (wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, wxT("BLACK"), wxT("BLACK")); // annotations AnnotationSetVisible(wxSTC_ANNOTATION_BOXED); // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key SetLayoutCache (wxSTC_CACHE_PAGE); UsePopUp(wxSTC_POPUP_ALL); }
ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { Hide(); if(!wxStyledTextCtrl::Create(parent, id, pos, size, style | wxNO_BORDER, name)) { return; } wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); for(int i = 0; i < wxSTC_STYLE_MAX; ++i) { StyleSetBackground(i, bgColour); } znConfigItem data; clConfig conf("zoom-navigator.conf"); conf.ReadItem(&data); SetEditable(false); SetUseHorizontalScrollBar(false); SetUseVerticalScrollBar(data.IsUseScrollbar()); HideSelection(true); SetMarginWidth(1, 0); SetMarginWidth(2, 0); SetMarginWidth(3, 0); m_zoomFactor = data.GetZoomFactor(); m_colour = data.GetHighlightColour(); MarkerSetBackground(1, m_colour); SetZoom(m_zoomFactor); EventNotifier::Get()->Connect(wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL, this); EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this); MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour); #ifndef __WXMSW__ SetTwoPhaseDraw(false); SetBufferedDraw(false); SetLayoutCache(wxSTC_CACHE_DOCUMENT); #endif MarkerSetAlpha(1, 10); m_timer = new wxTimer(this); Bind(wxEVT_TIMER, &ZoomText::OnTimer, this, m_timer->GetId()); Show(); }
bool wxSTEditorShell::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if (!wxSTEditor::Create(parent, id, pos, size, style, name)) return false; // set this up in case they don't want to bother with the preferences SetMarginWidth(STE_MARGIN_NUMBER,0); SetMarginWidth(STE_MARGIN_FOLD,0); SetMarginWidth(marginPrompt, 16); SetMarginType(marginPrompt, wxSTC_MARGIN_SYMBOL); SetMarginMask(marginPrompt, 1<<markerPrompt); // after creation you can change this to whatever prompt you prefer MarkerDefine(markerPrompt, wxSTC_MARK_ARROWS, *wxBLACK, wxColour(255,255,0)); return true; }
ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, style | wxNO_BORDER, name) { znConfigItem data; clConfig conf("zoom-navigator.conf"); conf.ReadItem(&data); SetEditable(false); SetUseHorizontalScrollBar(false); SetUseVerticalScrollBar(data.IsUseScrollbar()); HideSelection(true); SetMarginWidth(1, 0); SetMarginWidth(2, 0); SetMarginWidth(3, 0); m_zoomFactor = data.GetZoomFactor(); m_colour = data.GetHighlightColour(); MarkerSetBackground(1, m_colour); SetZoom(m_zoomFactor); EventNotifier::Get()->Connect( wxEVT_ZN_SETTINGS_UPDATED, wxCommandEventHandler(ZoomText::OnSettingsChanged), NULL, this); EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(ZoomText::OnThemeChanged), NULL, this); MarkerDefine(1, wxSTC_MARK_BACKGROUND, m_colour, m_colour); #ifndef __WXMSW__ SetTwoPhaseDraw(false); SetBufferedDraw(false); SetLayoutCache(wxSTC_CACHE_DOCUMENT); #endif MarkerSetAlpha(1, 10); wxTheApp->Bind(wxEVT_IDLE, &ZoomText::OnIdle, this); }
void IWnd_stc::_Init() { param.nlang = -1; // Use all the bits in the style byte as styles, not indicators. SetStyleBits(8); wxFont font (ms_param.nsize, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground(wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground(wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground(wxSTC_STYLE_LINENUMBER,wxColour (wxT("DARK GREY"))); StyleSetBackground(wxSTC_STYLE_LINENUMBER,*wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, wxT("WHITE"), wxT("BLACK")); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, wxT("WHITE"), wxT("BLACK")); UpdateStyle(); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // annotations AnnotationSetVisible(wxSTC_ANNOTATION_BOXED); CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key SetLayoutCache (wxSTC_CACHE_PAGE); }
void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) { wxStyledTextCtrl::Create(parent, id , pos, size, style); // Clear all styles StyleClearAll(); // Font extern sysSettings *settings; wxFont fntSQLBox = settings->GetSQLFont(); wxColour bgColor = settings->GetSQLBoxColourBackground(); if (settings->GetSQLBoxUseSystemBackground()) { bgColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); } wxColour frColor = settings->GetSQLBoxColourForeground(); if (settings->GetSQLBoxUseSystemForeground()) { frColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); } StyleSetBackground(wxSTC_STYLE_DEFAULT, bgColor); StyleSetForeground(wxSTC_STYLE_DEFAULT, frColor); StyleSetFont(wxSTC_STYLE_DEFAULT, fntSQLBox); SetSelBackground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); SetSelForeground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); SetCaretForeground(settings->GetSQLColourCaret()); SetMarginWidth(1, 0); SetTabWidth(settings->GetIndentSpaces()); SetUseTabs(!settings->GetSpacesForTabs()); // Setup the different highlight colurs for (int i = 0; i < 34; ++ i ) { if (i > 0 && i < 12) StyleSetForeground(i, settings->GetSQLBoxColour(i)); else StyleSetForeground(i, frColor); StyleSetBackground(i, bgColor); StyleSetFont(i, fntSQLBox); } // Keywords in uppercase? if (settings->GetSQLKeywordsInUppercase()) StyleSetCase(5, wxSTC_CASE_UPPER); // Margin style StyleSetBackground(wxSTC_STYLE_LINENUMBER, settings->GetSQLMarginBackgroundColour()); // Brace maching styles StyleSetBackground(34, wxColour(0x99, 0xF9, 0xFF)); StyleSetBackground(35, wxColour(0xFF, 0xCF, 0x27)); StyleSetFont(34, fntSQLBox); StyleSetFont(35, fntSQLBox); // SQL Lexer and keywords. if (sqlKeywords.IsEmpty()) FillKeywords(sqlKeywords); SetLexer(wxSTC_LEX_SQL); SetKeyWords(0, sqlKeywords + plpgsqlKeywords + ftsKeywords + pgscriptKeywords); // Enable folding SetMarginSensitive(2, true); SetMarginType(2, wxSTC_MARGIN_SYMBOL); // margin 2 for symbols SetMarginMask(2, wxSTC_MASK_FOLDERS); // set up mask for folding symbols SetMarginSensitive(2, true); // this one needs to be mouse-aware SetMarginWidth(2, 16); // set margin 2 16 px wide MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, *wxWHITE, *wxBLACK); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, *wxWHITE, *wxBLACK); SetProperty(wxT("fold"), wxT("1")); SetFoldFlags(16); // Setup accelerators wxAcceleratorEntry entries[2]; entries[0].Set(wxACCEL_CTRL, (int)'F', MNU_FIND); entries[1].Set(wxACCEL_CTRL, (int)' ', MNU_AUTOCOMPLETE); wxAcceleratorTable accel(2, entries); SetAcceleratorTable(accel); // Autocompletion configuration AutoCompSetSeparator('\t'); AutoCompSetChooseSingle(true); AutoCompSetIgnoreCase(true); AutoCompSetFillUps(wxT(" \t")); AutoCompSetDropRestOfWord(true); SetEOLMode(settings->GetLineEndingType()); }
CodeEditor::CodeEditor(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxScintilla (parent, id, pos, size, style) { mFileName = _T(""); //m_language = NULL; mLineNumID = 0; mLineNumMargin = TextWidth(wxSCI_STYLE_LINENUMBER, _T("99999")); mFoldingID = 1; mFoldingMargin = 16; mDividerID = 1; SetProperty(wxT("fold"), wxT("1")); SetFoldFlags(16); SetMarginType(mFoldingID, wxSCI_MARGIN_SYMBOL); SetMarginMask(mFoldingID, wxSCI_MASK_FOLDERS); SetMarginSensitive(mFoldingID, true); SetMarginWidth(mFoldingID, mFoldingMargin); MarkerDefine(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_BOXMINUS); MarkerSetForeground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDER, wxSCI_MARK_BOXPLUS); MarkerSetForeground(wxSCI_MARKNUM_FOLDER, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDER, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDERSUB, wxSCI_MARK_VLINE); MarkerSetForeground(wxSCI_MARKNUM_FOLDERSUB, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDERSUB, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDERTAIL, wxSCI_MARK_LCORNER); MarkerSetForeground(wxSCI_MARKNUM_FOLDERTAIL, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDERTAIL, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDEREND, wxSCI_MARK_BOXPLUSCONNECTED); MarkerSetForeground(wxSCI_MARKNUM_FOLDEREND, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDEREND, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDEROPENMID, wxSCI_MARK_BOXMINUSCONNECTED); MarkerSetForeground(wxSCI_MARKNUM_FOLDEROPENMID, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDEROPENMID, wxColour(0x80, 0x80, 0x80)); MarkerDefine(wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_TCORNER); MarkerSetForeground(wxSCI_MARKNUM_FOLDERMIDTAIL, wxColour(0xff, 0xff, 0xff)); MarkerSetBackground(wxSCI_MARKNUM_FOLDERMIDTAIL, wxColour(0x80, 0x80, 0x80)); // Set defaults, these should eventually be set via user prefs SetViewEOL(false); SetIndentationGuides(false); SetMarginWidth(mLineNumID, mLineNumMargin); //SetMarginWidth(mFoldingID, mFoldingMargin); //SetMarginSensitive(mFoldingID, true); SetEdgeMode(wxSCI_EDGE_LINE); //SetViewWhiteSpace(wxSCI_WS_VISIBLEALWAYS); SetOvertype(false); SetReadOnly(false); SetWrapMode(wxSCI_WRAP_NONE); wxFont font(10, wxTELETYPE, wxNORMAL, wxNORMAL); StyleSetFont(wxSCI_STYLE_DEFAULT, font); StyleSetForeground(wxSCI_STYLE_DEFAULT, wxColour(wxT("BLACK"))); StyleSetBackground(wxSCI_STYLE_DEFAULT, wxColour(wxT("WHITE"))); StyleSetForeground(wxSCI_STYLE_LINENUMBER, wxColour(wxT("DARK BLUE"))); StyleSetBackground(wxSCI_STYLE_LINENUMBER, wxColour(wxT("WHITE"))); StyleSetForeground(wxSCI_STYLE_INDENTGUIDE, wxColour(wxT("DARK GREY"))); StyleSetBold(wxSCI_STYLE_BRACELIGHT, true); //InitializePrefs(DEFAULT_LANGUAGE); SetTabWidth(4); SetUseTabs(false); SetTabIndents(true); SetBackSpaceUnIndents(true); SetIndent(4); // Set visibility SetVisiblePolicy(wxSCI_VISIBLE_STRICT | wxSCI_VISIBLE_SLOP, 1); SetXCaretPolicy(wxSCI_CARET_EVEN | wxSCI_VISIBLE_STRICT | wxSCI_CARET_SLOP, 1); SetYCaretPolicy(wxSCI_CARET_EVEN | wxSCI_VISIBLE_STRICT | wxSCI_CARET_SLOP, 1); SetCaretLineVisible(true); SetCaretLineBackground(wxColour(225, 235, 224)); // Markers //MarkerDefine(wxSCI_MARKNUM_FOLDER, wxSCI_MARK_BOXPLUS); //MarkerSetBackground(wxSCI_MARKNUM_FOLDER, wxColour(_T("BLACK"))); //MarkerSetForeground(wxSCI_MARKNUM_FOLDER, wxColour(_T("WHITE"))); //MarkerDefine(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_BOXMINUS); //MarkerSetBackground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(_T("BLACK"))); //MarkerSetForeground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(_T("WHITE"))); //MarkerDefine(wxSCI_MARKNUM_FOLDERSUB, wxSCI_MARK_EMPTY); //MarkerDefine(wxSCI_MARKNUM_FOLDEREND, wxSCI_MARK_SHORTARROW); //MarkerDefine(wxSCI_MARKNUM_FOLDEROPENMID, wxSCI_MARK_ARROWDOWN); //MarkerDefine(wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_EMPTY); //MarkerDefine(wxSCI_MARKNUM_FOLDERTAIL, wxSCI_MARK_EMPTY); // Clear wrong default keys #if !defined(__WXGTK__) //CmdKeyClear(wxSCI_KEY_TAB, 0); CmdKeyClear(wxSCI_KEY_TAB, wxSCI_SCMOD_SHIFT); #endif CmdKeyClear('A', wxSCI_SCMOD_CTRL); #if !defined(__WXGTK__) CmdKeyClear('C', wxSCI_SCMOD_CTRL); #endif CmdKeyClear('D', wxSCI_SCMOD_CTRL); CmdKeyClear('D', wxSCI_SCMOD_SHIFT | wxSCI_SCMOD_CTRL); CmdKeyClear('F', wxSCI_SCMOD_ALT | wxSCI_SCMOD_CTRL); CmdKeyClear('L', wxSCI_SCMOD_CTRL); CmdKeyClear('L', wxSCI_SCMOD_SHIFT | wxSCI_SCMOD_CTRL); CmdKeyClear('T', wxSCI_SCMOD_CTRL); CmdKeyClear('T', wxSCI_SCMOD_SHIFT | wxSCI_SCMOD_CTRL); CmdKeyClear('U', wxSCI_SCMOD_CTRL); CmdKeyClear('U', wxSCI_SCMOD_SHIFT | wxSCI_SCMOD_CTRL); #if !defined(__WXGTK__) CmdKeyClear('V', wxSCI_SCMOD_CTRL); CmdKeyClear('X', wxSCI_SCMOD_CTRL); #endif CmdKeyClear('Y', wxSCI_SCMOD_CTRL); #if !defined(__WXGTK__) CmdKeyClear('Z', wxSCI_SCMOD_CTRL); #endif UsePopUp(0); SetLayoutCache(wxSCI_CACHE_PAGE); SetBufferedDraw(1); }
Edit::Edit (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; m_FoldingID = 2; m_dlgFind = NULL; m_dlgReplace = NULL; // initialize language m_language = NULL; // Use all the bits in the style byte as styles, not indicators. SetStyleBits(8); // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (_("Objeck")); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, wxT("WHITE"), wxT("LIGHT GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, wxT("WHITE"), wxT("LIGHT GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, wxT("WHITE"), wxT("LIGHT BLUE")); MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, wxT("WHITE"), wxT("LIGHT GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, wxT("WHITE"), wxT("LIGHT GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, wxT("WHITE"), wxT("LIGHT BLUE")); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, wxT("WHITE"), wxT("LIGHT BLUE")); // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; CmdKeyClear (wxSTC_KEY_TAB, 0); // this is done by the menu accelerator key SetLayoutCache(wxSTC_CACHE_PAGE); }
Edit::Edit (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : wxStyledTextCtrl (parent, id, pos, size, style) { m_findReplace = NULL; m_filename = wxEmptyString; m_LineNrID = 0; m_DividerID = 1; m_FoldingID = 2; // initialize language m_language = NULL; // Use all the bits in the style byte as styles, not indicators. SetStyleBits(8); #ifdef __WXOSX_COCOA__ SetZoom(4); #endif m_modified = false; SetModEventMask(wxSTC_MOD_INSERTTEXT | wxSTC_MOD_DELETETEXT); // setup unicode support SetKeysUnicode(true); SetCodePage(wxSTC_CP_UTF8); wxConvCurrent = &wxConvUTF8; // default font for all styles SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeMode (g_CommonPrefs.longLineOnEnable? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (g_CommonPrefs.whiteSpaceEnable? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (g_CommonPrefs.overTypeInitial); SetReadOnly (g_CommonPrefs.readOnlyInitial); SetWrapMode (g_CommonPrefs.wrapModeInitial? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); wxFont font (10, wxMODERN, wxNORMAL, wxNORMAL); StyleSetFont (wxSTC_STYLE_DEFAULT, font); StyleSetForeground (wxSTC_STYLE_DEFAULT, *wxBLACK); StyleSetBackground (wxSTC_STYLE_DEFAULT, *wxWHITE); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); StyleSetForeground(wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); InitializePrefs (DEFAULT_LANGUAGE); // set visibility SetVisiblePolicy (wxSTC_VISIBLE_STRICT|wxSTC_VISIBLE_SLOP, 1); SetXCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); SetYCaretPolicy (wxSTC_CARET_EVEN|wxSTC_VISIBLE_STRICT|wxSTC_CARET_SLOP, 1); // markers // ---- Enable code folding SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL); SetMarginWidth(MARGIN_FOLD, 15); SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS); SetMarginSensitive(MARGIN_FOLD, true); // Properties found from http://www.scintilla.org/SciTEDoc.html SetProperty(wxT("fold"), wxT("1")); SetProperty(wxT("fold.comment"), wxT("1")); SetProperty(wxT("fold.compact"), wxT("1")); SetProperty(wxT("fold"), wxT("1")); SetProperty(wxT("fold.comment"), wxT("1")); SetProperty(wxT("fold.compact"), wxT("1")); SetProperty(wxT("fold.preprocessor"), wxT("1")); MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, wxT("WHITE"), wxT("GREY")); MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, wxT("WHITE"), wxT("GREY")); SetFoldFlags(wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_999999")); m_FoldingMargin = 16; SetLayoutCache (wxSTC_CACHE_PAGE); }
void SourceView::showFile(std::wstring path, int proclinenum, const std::vector<double> &linecounts) { currentfile = path; // Don't show error messages with CPP highlighting setPlainMode(); if (path == "[hint KiFastSystemCallRet]") { updateText( " Hint: KiFastSystemCallRet often means the thread was waiting for something else to finish.\n" " \n" " Possible causes might be disk I/O, waiting for an event, or maybe just calling Sleep().\n" ); return; } if (path == "" || path == "[unknown]") { updateText("[ No source file available for this location. ]"); return; } FILE *file = _wfopen(path.c_str(),L"r, ccs=UNICODE"); if(!file) { wchar_t *crtSub = L"\\crt\\src\\"; wchar_t *crt = wcsstr((wchar_t *)path.c_str(), crtSub); if(crt) { for(size_t i=0;i<msDevPaths.size();i++) { std::wstring newPath(msDevPaths[i]); newPath += crt+wcslen(crtSub); path = newPath; file = _wfopen(path.c_str(),L"r"); if(file) break; } } } if(!file) { updateText(std::wstring("[ Could not open file '" + path + "'. ]").c_str()); return; } std::wstring displaytext; wchar_t line[1024]; while(fgetws(line,countof(line),file)) { displaytext += line; } fclose(file); setCppMode(); updateText(displaytext); // Show line counts in margin for (int line=1,lineCount=linecounts.size(); line<lineCount; ++line) { if (linecounts[line]) { wchar_t currCount[32]; swprintf(currCount, countof(currCount), L"%0.2fs ", linecounts[line]); MarginSetText (line-1, currCount); MarginSetStyle(line-1, MARGIN_TEXT_STYLE); } } SetYCaretPolicy(wxSTC_CARET_STRICT|wxSTC_CARET_EVEN, 0); GotoLine(proclinenum); SetYCaretPolicy(wxSTC_CARET_EVEN, 0); MarkerDefine(1, wxSTC_MARK_BACKGROUND, wxNullColour, *wxYELLOW); MarkerAdd(proclinenum-1, 1); }