/* TextEditor::setup * Sets up text editor properties depending on cvars and the current * text styleset/style *******************************************************************/ void TextEditor::setup() { // General settings SetBufferedDraw(true); SetUseAntiAliasing(true); SetMouseDwellTime(500); AutoCompSetIgnoreCase(true); SetIndentationGuides(txed_indent_guides); StyleSetBackground(wxSTC_STYLE_INDENTGUIDE, WXCOL(col_edge_line)); // Right margin line SetEdgeColour(WXCOL(col_edge_line)); SetEdgeColumn(txed_edge_column); if (txed_edge_column == 0) SetEdgeMode(wxSTC_EDGE_NONE); else SetEdgeMode(wxSTC_EDGE_LINE); // Apply default style StyleSet::applyCurrent(this); CallTipUseStyle(10); StyleSetChangeable(wxSTC_STYLE_CALLTIP, true); wxFont font_ct(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); StyleSetFont(wxSTC_STYLE_CALLTIP, font_ct); CallTipSetForegroundHighlight(WXCOL(StyleSet::currentSet()->getStyle("calltip_hl")->getForeground())); // Set lexer if (txed_syntax_hilight) SetLexer(wxSTC_LEX_CPPNOCASE); else SetLexer(wxSTC_LEX_NULL); // Re-colour text Colourise(0, GetTextLength()); }
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(); }
/* TextEditor::setup * Sets up text editor properties depending on cvars and the current * text styleset/style *******************************************************************/ void TextEditor::setup() { // General settings SetBufferedDraw(true); SetUseAntiAliasing(true); SetMouseDwellTime(500); AutoCompSetIgnoreCase(true); SetIndentationGuides(txed_indent_guides); // Right margin line SetEdgeColumn(txed_edge_column); if (txed_edge_column == 0) SetEdgeMode(wxSTC_EDGE_NONE); else SetEdgeMode(wxSTC_EDGE_LINE); // Apply default style StyleSet::applyCurrent(this); CallTipUseStyle(10); StyleSetChangeable(wxSTC_STYLE_CALLTIP, true); wxFont font_ct(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); StyleSetFont(wxSTC_STYLE_CALLTIP, font_ct); CallTipSetForegroundHighlight(WXCOL(StyleSet::currentSet()->getStyle("calltip_hl")->getForeground())); // Set folding options setupFolding(); // Re-colour text Colourise(0, GetTextLength()); // Set word wrapping if (txed_word_wrap) SetWrapMode(wxSTC_WRAP_WORD); else SetWrapMode(wxSTC_WRAP_NONE); // Set word match indicator style SetIndicatorCurrent(8); IndicatorSetStyle(8, wxSTC_INDIC_ROUNDBOX); IndicatorSetUnder(8, true); IndicatorSetOutlineAlpha(8, 60); IndicatorSetAlpha(8, 40); }
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); }
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); }