/* 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); }
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); }