void FB_STC::LoadSettings ( ) { FB_Config * Prefs = m_Ide->GetConfig(); Style_STC_FB * Style = &Prefs->Style_FB; // Clear all styles there might be defined StyleClearAll( ); SetLexer( 0 ); // Tab and indenting SetTabWidth ( Prefs->TabSize ); SetUseTabs ( false ); SetTabIndents ( true ); SetBackSpaceUnIndents ( true ); SetIndent ( Prefs->TabSize ); SetIndentationGuides ( Prefs->IndentGuide ); // Right margin SetEdgeMode ( Prefs->RightMargin ? wxSTC_EDGE_LINE: wxSTC_EDGE_NONE ); SetEdgeColumn ( Prefs->EdgeColumn ); // Line and line ending SetEOLMode ( 0 ); SetViewEOL ( Prefs->DisplayEOL ); SetViewWhiteSpace ( Prefs->WhiteSpace ? wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE ); // Misc CmdKeyClear (wxSTC_KEY_TAB, 0); #define _STYLE(nr) Style->Style[nr] wxFont font ( _STYLE(0).Size, wxMODERN, wxNORMAL, wxNORMAL, false, _STYLE(0).Font ); StyleSetForeground (wxSTC_STYLE_DEFAULT, Prefs->GetClr(_STYLE(0).Face)); StyleSetBackground (wxSTC_STYLE_DEFAULT, Prefs->GetClr(_STYLE(0).Back)); StyleSetFont( wxSTC_STYLE_DEFAULT, font ); StyleSetForeground (0, Prefs->GetClr(_STYLE(0).Face)); StyleSetBackground (0, Prefs->GetClr(_STYLE(0).Back)); StyleSetFont( 0, font ); StyleSetForeground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberFace)); StyleSetBackground (wxSTC_STYLE_LINENUMBER, Prefs->GetClr(Style->LineNumberBack)); StyleSetFont( wxSTC_STYLE_LINENUMBER, font ); SetCaretForeground (Prefs->GetClr(Style->CaretFace)); SetSelForeground(true, Prefs->GetClr(Style->SelectFace)); SetSelBackground(true, Prefs->GetClr(Style->SelectBack)); #undef STYLE int LineNrMargin = TextWidth(wxSTC_STYLE_LINENUMBER, _T("0001")); SetMarginWidth (0, Prefs->LineNumber ? LineNrMargin : 0); SetMarginWidth (1,0); if ( Prefs->CurrentLine ) { SetCaretLineVisible( true ); SetCaretLineBack( Prefs->GetClr( Style->CaretLine ) ); } }
void OutputCtrl::UpdatePrefs() { StyleSetBackground( wxSTC_STYLE_DEFAULT, tsGetPrefs().GetBgColor() ); SetCaretForeground( tsGetPrefs().GetDefaultColor() ); StyleSetForeground( wxSTC_TCS_DEFAULT, tsGetPrefs().GetDefaultColor() ); StyleSetBackground( wxSTC_TCS_DEFAULT, tsGetPrefs().GetBgColor() ); SetSelBackground( 1, tsGetPrefs().GetSelBgColor() ); SetSelForeground( 1, tsGetPrefs().GetSelColor() ); SetTabWidth( tsGetPrefs().GetTabWidth() ); StyleSetBackground( wxSTC_STYLE_LINENUMBER, tsGetPrefs().GetBgColor() ); }
PythonCodeCtrl::PythonCodeCtrl(wxWindow *parent, PythonInterpCtrl *py) : cbStyledTextCtrl(parent, wxID_ANY) { m_pyctrl = py; EditorManager *em = Manager::Get()->GetEditorManager(); // Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(PythonCodeCtrl::OnUserInput)); ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor")); //MOST OF THIS STUFF IS TAKEN FROM CB EDITOR wxFont font(10, wxMODERN, wxNORMAL, wxNORMAL); wxString fontstring = mgr->Read(_T("/font"), wxEmptyString); if (!fontstring.IsEmpty()) { wxNativeFontInfo nfi; nfi.FromString(fontstring); font.SetNativeFontInfo(nfi); } SetMouseDwellTime(1000); SetScrollWidthTracking(true); SetScrollWidth(5); //Hides horizontal scrollbar if text doesn't exceed the window width int caretStyle = mgr->ReadInt(_T("/caret/style"), wxSCI_CARETSTYLE_LINE); SetCaretStyle(caretStyle); if (caretStyle == wxSCI_CARETSTYLE_LINE) SetCaretWidth(mgr->ReadInt(_T("/caret/width"), 1)); else SetCaretWidth(1); ColourManager *colours = Manager::Get()->GetColourManager(); SetCaretForeground(colours->GetColour(wxT("editor_caret"))); SetCaretPeriod(mgr->ReadInt(_T("/caret/period"), 500)); SetCaretLineVisible(mgr->ReadBool(_T("/highlight_caret_line"), false)); SetCaretLineBackground( Manager::Get()->GetConfigManager(_T("editor"))->ReadColour(_T("/highlight_caret_line_colour"), wxColour(0xFF, 0xFF, 0x00))); SetFoldMarginColour(true, colours->GetColour(wxT("editor_margin_chrome"))); SetFoldMarginHiColour(true, colours->GetColour(wxT("editor_margin_chrome_highlight"))); // setup for "CamelCase selection" if (mgr->ReadBool(_T("/camel_case"), false)) { // consider CamelCase for both: cursor movement with CTRL and selection with CTRL+SHIFT: CmdKeyAssign(wxSCI_KEY_LEFT, wxSCI_SCMOD_CTRL, wxSCI_CMD_WORDPARTLEFT); CmdKeyAssign(wxSCI_KEY_RIGHT, wxSCI_SCMOD_CTRL, wxSCI_CMD_WORDPARTRIGHT); CmdKeyAssign(wxSCI_KEY_LEFT, wxSCI_SCMOD_CTRL|wxSCI_SCMOD_SHIFT, wxSCI_CMD_WORDPARTLEFTEXTEND); CmdKeyAssign(wxSCI_KEY_RIGHT, wxSCI_SCMOD_CTRL|wxSCI_SCMOD_SHIFT, wxSCI_CMD_WORDPARTRIGHTEXTEND); } else // else set default "none CamelCase" key behavior (also default scintilla behaviour, see scintilla docs) { CmdKeyAssign(wxSCI_KEY_LEFT, wxSCI_SCMOD_CTRL, wxSCI_CMD_WORDLEFT); CmdKeyAssign(wxSCI_KEY_RIGHT, wxSCI_SCMOD_CTRL, wxSCI_CMD_WORDRIGHT); CmdKeyAssign(wxSCI_KEY_LEFT, wxSCI_SCMOD_CTRL|wxSCI_SCMOD_SHIFT, wxSCI_CMD_WORDLEFTEXTEND); CmdKeyAssign(wxSCI_KEY_RIGHT, wxSCI_SCMOD_CTRL|wxSCI_SCMOD_SHIFT, wxSCI_CMD_WORDRIGHTEXTEND); } SetUseTabs(mgr->ReadBool(_T("/use_tab"), false)); SetIndentationGuides(mgr->ReadBool(_T("/show_indent_guides"), false)?wxSCI_IV_LOOKBOTH:wxSCI_IV_NONE); SetTabIndents(mgr->ReadBool(_T("/tab_indents"), true)); SetBackSpaceUnIndents(mgr->ReadBool(_T("/backspace_unindents"), true)); SetWrapMode(mgr->ReadBool(_T("/word_wrap"), false)); if (mgr->ReadBool(_T("/word_wrap_style_home_end"), true)) { // in word wrap mode, home/end keys goto the wrap point if not already there, // otherwise to the start/end of the entire line. // alt+home/end go to start/end of the entire line. // in unwrapped mode, there is no difference between home/end and alt+home/end CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_NORM, wxSCI_CMD_LINEENDWRAP); CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_ALT, wxSCI_CMD_LINEEND); CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_SHIFT, wxSCI_CMD_LINEENDWRAPEXTEND); CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT, wxSCI_CMD_LINEENDEXTEND); // if user wants "Home" key to set cursor to the very beginning of line if (mgr->ReadBool(_T("/simplified_home"), false)) { CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_NORM,wxSCI_CMD_HOMEWRAP); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_ALT,wxSCI_CMD_HOME); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT,wxSCI_CMD_HOMEWRAPEXTEND); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT,wxSCI_CMD_HOMEEXTEND); } else // else set default "Home" key behavior { CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_NORM,wxSCI_CMD_VCHOMEWRAP); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_ALT,wxSCI_CMD_VCHOME); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT,wxSCI_CMD_VCHOMEWRAPEXTEND); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT,wxSCI_CMD_VCHOMEEXTEND); } } else { // in word wrap mode, home/end keys goto start/end of the entire line. alt+home/end goes to wrap points CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_ALT, wxSCI_CMD_LINEENDWRAP); CmdKeyAssign(wxSCI_KEY_END, wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT, wxSCI_CMD_LINEENDWRAPEXTEND); // if user wants "Home" key to set cursor to the very beginning of line if (mgr->ReadBool(_T("/simplified_home"), false)) { CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_ALT,wxSCI_CMD_HOMEWRAP); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT,wxSCI_CMD_HOMEWRAPEXTEND); } else // else set default "Home" key behavior { CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_ALT,wxSCI_CMD_VCHOMEWRAP); CmdKeyAssign(wxSCI_KEY_HOME,wxSCI_SCMOD_SHIFT|wxSCI_SCMOD_ALT,wxSCI_CMD_VCHOMEWRAPEXTEND); } } SetViewEOL(mgr->ReadBool(_T("/show_eol"), false)); SetViewWhiteSpace(mgr->ReadInt(_T("/view_whitespace"), 0)); // gutter SetEdgeMode(mgr->ReadInt(_T("/gutter/mode"), 0)); SetEdgeColour(Manager::Get()->GetColourManager()->GetColour(wxT("editor_gutter"))); SetEdgeColumn(mgr->ReadInt(_T("/gutter/column"), 80)); StyleSetFont(wxSCI_STYLE_DEFAULT, font); StyleClearAll(); SetTabWidth(mgr->ReadInt(_T("/tab_size"), 4)); SetIndent(mgr->ReadInt(_T("/tab_size"), 4)); //NEEDED FOR AUTO INDENTATION (NOT IN CB EDITOR) em->GetColourSet()->Apply(_("Python"),this); }
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()); }
void cbStyledTextCtrl::HighlightRightBrace() { if (m_bracePosition == wxSCI_INVALID_POSITION) return; int pos = GetCurrentPos(); if (pos == wxSCI_INVALID_POSITION) return; const static wxColour caretForeground = GetCaretForeground(); const static int caretWidth = GetCaretWidth(); const int curLine = GetCurrentLine(); const int len = GetLength(); if (m_tabSmartJump && (curLine == LineFromPosition(m_bracePosition))) { SetIndicatorCurrent(s_indicHighlight); const int indPos = GetLineIndentPosition(curLine); IndicatorClearRange(indPos, GetLineEndPosition(curLine)-indPos); do { if (pos >= len) break; wxString cur((wxChar)GetCharAt(pos)); if (cur == _T("\n")) break; int style = GetStyleAt(pos); if (IsComment(style)) continue; if (IsString(style) || IsCharacter(style)) { const int nextOne = (pos == len) ? GetStyleAt(pos) : GetStyleAt(pos + 1); if (IsCharacter(nextOne) || IsString(nextOne)) continue; } if (s_rightBrace.Contains(cur)) { SetCaretForeground(wxColour(255, 0, 0)); SetCaretWidth(caretWidth + 1); IndicatorSetForeground(s_indicHighlight, wxColour(80, 236, 120)); IndicatorSetStyle(s_indicHighlight, wxSCI_INDIC_HIGHLIGHT); #ifndef wxHAVE_RAW_BITMAP IndicatorSetUnder(s_indicHighlight, true); #endif SetIndicatorCurrent(s_indicHighlight); IndicatorFillRange(pos, 1); m_bracePosition = pos + 1; return; } } while (++pos); } m_bracePosition = wxSCI_INVALID_POSITION; m_lastPosition = wxSCI_INVALID_POSITION; m_tabSmartJump = false; SetIndicatorCurrent(s_indicHighlight); IndicatorClearRange(0, len); SetCaretForeground(caretForeground); SetCaretWidth(caretWidth); }
void CodeEdit::SetFontColorSettings(const FontColorSettings& settings) { // For some reason StyleSetFont takes a (non-const) reference, so we need to make // a copy before passing it in. wxFont font = settings.GetFont(); SetSelForeground(true, settings.GetColors(FontColorSettings::DisplayItem_Selection).foreColor); SetSelBackground(true, settings.GetColors(FontColorSettings::DisplayItem_Selection).backColor); StyleSetFont(wxSTC_STYLE_DEFAULT, font); StyleClearAll(); font = settings.GetFont(FontColorSettings::DisplayItem_Default); StyleSetFont(wxSTC_LUA_DEFAULT, font); StyleSetFont(wxSTC_LUA_IDENTIFIER, font); StyleSetForeground(wxSTC_LUA_DEFAULT, settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor); StyleSetBackground(wxSTC_LUA_DEFAULT, settings.GetColors(FontColorSettings::DisplayItem_Default).backColor); StyleSetForeground(wxSTC_STYLE_DEFAULT, settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor); StyleSetBackground(wxSTC_STYLE_DEFAULT, settings.GetColors(FontColorSettings::DisplayItem_Default).backColor); StyleSetForeground(wxSTC_LUA_IDENTIFIER, settings.GetColors(FontColorSettings::DisplayItem_Default).foreColor); StyleSetBackground(wxSTC_LUA_IDENTIFIER, settings.GetColors(FontColorSettings::DisplayItem_Default).backColor); font = settings.GetFont(FontColorSettings::DisplayItem_Comment); StyleSetFont(wxSTC_LUA_COMMENT, font); StyleSetFont(wxSTC_LUA_COMMENTLINE, font); StyleSetFont(wxSTC_LUA_COMMENTDOC, font); StyleSetForeground(wxSTC_LUA_COMMENT, settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor); StyleSetBackground(wxSTC_LUA_COMMENT, settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor); StyleSetForeground(wxSTC_LUA_COMMENTLINE, settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor); StyleSetBackground(wxSTC_LUA_COMMENTLINE, settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor); StyleSetForeground(wxSTC_LUA_COMMENTDOC, settings.GetColors(FontColorSettings::DisplayItem_Comment).foreColor); StyleSetBackground(wxSTC_LUA_COMMENTDOC, settings.GetColors(FontColorSettings::DisplayItem_Comment).backColor); font = settings.GetFont(FontColorSettings::DisplayItem_Keyword); StyleSetFont(wxSTC_LUA_WORD2, font); StyleSetForeground(wxSTC_LUA_WORD2, settings.GetColors(FontColorSettings::DisplayItem_Keyword).foreColor); StyleSetBackground(wxSTC_LUA_WORD2, settings.GetColors(FontColorSettings::DisplayItem_Keyword).backColor); font = settings.GetFont(FontColorSettings::DisplayItem_Operator); StyleSetFont(wxSTC_LUA_OPERATOR, font); StyleSetForeground(wxSTC_LUA_OPERATOR, settings.GetColors(FontColorSettings::DisplayItem_Operator).foreColor); StyleSetBackground(wxSTC_LUA_OPERATOR, settings.GetColors(FontColorSettings::DisplayItem_Operator).backColor); font = settings.GetFont(FontColorSettings::DisplayItem_String); StyleSetFont(wxSTC_LUA_STRING, font); StyleSetForeground(wxSTC_LUA_STRING, settings.GetColors(FontColorSettings::DisplayItem_String).foreColor); StyleSetBackground(wxSTC_LUA_STRING, settings.GetColors(FontColorSettings::DisplayItem_String).backColor); StyleSetFont(wxSTC_LUA_STRINGEOL, font); StyleSetForeground(wxSTC_LUA_STRINGEOL, settings.GetColors(FontColorSettings::DisplayItem_String).foreColor); StyleSetBackground(wxSTC_LUA_STRINGEOL, settings.GetColors(FontColorSettings::DisplayItem_String).backColor); StyleSetFont(wxSTC_LUA_LITERALSTRING, font); StyleSetForeground(wxSTC_LUA_LITERALSTRING, settings.GetColors(FontColorSettings::DisplayItem_String).foreColor); StyleSetBackground(wxSTC_LUA_LITERALSTRING, settings.GetColors(FontColorSettings::DisplayItem_String).backColor); StyleSetFont(wxSTC_LUA_CHARACTER, font); StyleSetForeground(wxSTC_LUA_CHARACTER, settings.GetColors(FontColorSettings::DisplayItem_String).foreColor); StyleSetBackground(wxSTC_LUA_CHARACTER, settings.GetColors(FontColorSettings::DisplayItem_String).backColor); font = settings.GetFont(FontColorSettings::DisplayItem_Number); StyleSetFont(wxSTC_LUA_NUMBER, font); StyleSetForeground(wxSTC_LUA_NUMBER, settings.GetColors(FontColorSettings::DisplayItem_Number).foreColor); StyleSetBackground(wxSTC_LUA_NUMBER, settings.GetColors(FontColorSettings::DisplayItem_Number).backColor); StyleSetSize(wxSTC_STYLE_LINENUMBER, font.GetPointSize()); // Set the caret color as the inverse of the background color so it's always visible. SetCaretForeground( GetInverse(settings.GetColors(FontColorSettings::DisplayItem_Default).backColor) ); StyleSetBackground(wxSTC_STYLE_LINENUMBER, settings.GetColors(FontColorSettings::DisplayItem_WindowMargin).backColor); StyleSetForeground(wxSTC_STYLE_LINENUMBER, settings.GetColors(FontColorSettings::DisplayItem_WindowMargin).foreColor); //SetFoldMarginHiColour(true, settings.GetColors(FontColorSettings::DisplayItem_Window).backColor); }