/*---------------------------------------------------------------------------*/ void wxSQLEditorBase::Init() { m_FontName = _T("Courier New"); m_FontSize = 10; SetWrapMode(wxSTC_WRAP_NONE); // wxSTC_WRAP_WORD wxSTC_WRAP_NONE SetLexer(wxSTC_LEX_SQL); SetTabWidth(2); SetUseTabs(false); SetTabIndents (true); SetBackSpaceUnIndents (true); SetIndent(2); SetViewEOL(false); SetIndentationGuides(true); SetEOLMode(wxSTC_EOL_LF); SetEdgeColumn(200); SetEdgeMode(wxSTC_EDGE_LINE); // wxSTC_EDGE_NONE wxSTC_EDGE_LINE SetViewWhiteSpace(wxSTC_WS_INVISIBLE); // wxSTC_WS_VISIBLEALWAYS SetMarginType(1, wxSTC_MARGIN_SYMBOL); SetMarginWidth(1, 0); SetKeyWords(0, SQLWordlist1); SetKeyWords(1, SQLWordlist2); SetKeyWords(4, SQLWordlist3); SetKeyWords(5, SQLWordlist4); ReInitAllStyle(); }
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); }
/* 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); }
TextControl::TextControl(wxWindow *parent, wxWindowID id) : wxStyledTextCtrl(parent, id, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME) { SetWrapMode(wxSTC_WRAP_WORD); // wxStyledTextCtrl uses black on white initially -> use system defaults resetStyles(); // Hide margin area for line numbers and fold markers SetMarginWidth(1, 0); SetMarginWidth(0, 0); }
fbtTextFile::fbtTextFile(fbtMainFrame* parent, fbtText* fp, int id) : wxStyledTextCtrl(parent, FBT_WINDOW_TXT), m_file(fp), m_parent(parent) { SetViewEOL(false); SetIndentationGuides(false); SetEdgeMode(wxSTC_EDGE_NONE); SetViewWhiteSpace(wxSTC_WS_INVISIBLE); SetReadOnly(false); SetTabWidth(4); SetWrapMode(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"))); SetMarginType(0, wxSTC_MARGIN_NUMBER); SetMarginWidth(0, TextWidth (wxSTC_STYLE_LINENUMBER, wxT("_99999"))); 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); SetLexer(wxSTC_LEX_CPP); StyleSetForeground(wxSTC_C_COMMENT, COMMENT_COLOR); StyleSetForeground(wxSTC_C_COMMENTLINEDOC, COMMENT_COLOR); StyleSetForeground(wxSTC_C_COMMENTLINE, COMMENT_COLOR); StyleSetForeground(wxSTC_C_COMMENTDOC, COMMENT_COLOR); StyleSetForeground(wxSTC_C_NUMBER, NUMBER_COLOR); StyleSetForeground(wxSTC_C_OPERATOR, OPERATOR_COLOR); StyleSetForeground(wxSTC_C_WORD, WORD_COLOR); StyleSetForeground(wxSTC_C_PREPROCESSOR, WORD_COLOR); SetKeyWords(0, WORDS); SetSelBackground(true, wxColor(51, 94, 168)); SetSelForeground(true, wxColor(255, 255, 255)); m_file->m_textFile = this; m_file->m_flag |= fbtText::FILE_IS_OPEN; }
//---------------------------------------------------------- // Constructor, taking in filename to load //---------------------------------------------------------- Texture::Texture(const std::string& p_strFile) : m_eFilterMin(Texture::FM_Invalid), m_eFilterMag(Texture::FM_Invalid), m_eWrapU(Texture::WM_Invalid), m_eWrapV(Texture::WM_Invalid), m_uiWidth(0), m_uiHeight(0), m_uiTex(0) { if( p_strFile.find(".dds") != std::string::npos ) LoadFromDDS(p_strFile); else if( p_strFile.find(".tga") != std::string::npos ) LoadFromTGA(p_strFile); else { printf("ERROR: No idea how to load this file - %s!", p_strFile.c_str()); } SetWrapMode(WM_Clamp); }
bool Texture::Load(const void* wrapper) { std::string str; if (!IsObject(wrapper)) return false; if (!LoadMemberValue(wrapper, "format", str)) { FURYE << "Texture param 'format' not found!"; return false; } auto format = EnumUtil::TextureFormatFromString(str); if (!LoadMemberValue(wrapper, "type", str)) str = EnumUtil::TextureTypeToString(TextureType::TEXTURE_2D); auto type = EnumUtil::TextureTypeFromString(str); int width, height; if (!LoadMemberValue(wrapper, "width", width) || !LoadMemberValue(wrapper, "height", height)) { FURYE << "Texture param 'width/height' not found!"; return false; } auto filterMode = FilterMode::LINEAR; if (LoadMemberValue(wrapper, "filter", str)) filterMode = EnumUtil::FilterModeFromString(str); auto wrapMode = WrapMode::REPEAT; if (LoadMemberValue(wrapper, "wrap", str)) wrapMode = EnumUtil::WrapModeFromString(str); auto color = Color::Black; LoadMemberValue(wrapper, "borderColor", color); SetBorderColor(color); bool mipmap = false; LoadMemberValue(wrapper, "mipmap", mipmap); SetFilterMode(filterMode); SetWrapMode(wrapMode); CreateEmpty(width, height, format, type, mipmap); return true; }
//---------------------------------------------------------- // Constructor taking in data already in ram //---------------------------------------------------------- Texture::Texture(void* p_pData, unsigned int p_uiWidth, unsigned int p_uiHeight, Format p_eFormat) : m_eFilterMin(Texture::FM_Invalid), m_eFilterMag(Texture::FM_Invalid), m_eWrapU(Texture::WM_Invalid), m_eWrapV(Texture::WM_Invalid), m_uiWidth(0), m_uiHeight(0), m_uiTex(0) { glGenTextures(1,&m_uiTex); glBindTexture(GL_TEXTURE_2D, m_uiTex); glTexImage2D(GL_TEXTURE_2D, 0, gs_aFormatMap[p_eFormat], p_uiWidth, p_uiHeight, 0, gs_aFormatMap[p_eFormat], gs_aTypeMap[p_eFormat], p_pData); m_uiWidth = p_uiWidth; m_uiHeight = p_uiHeight; SetWrapMode(WM_Clamp); glGenerateMipmap(GL_TEXTURE_2D); SetFilterMode(FM_TrilinearMipmap, FM_Linear); }
//-------------------------------------------------- //-------------------------------------------------- void Texture::Restore() { CS_ASSERT(GetStorageLocation() == CSCore::StorageLocation::k_none, "Cannot restore texture that was loaded from file. This should be handled using RefreshResource()."); Texture::Descriptor desc; desc.m_width = m_width; desc.m_height = m_height; desc.m_format = m_format; desc.m_compression = m_compression; desc.m_dataSize = m_restorationDataSize; WrapMode sWrap = m_sWrapMode; WrapMode tWrap = m_tWrapMode; FilterMode filterMode = m_filterMode; Build(desc, std::move(m_restorationData), m_hasMipMaps, m_restoreTextureDataEnabled); SetWrapMode(sWrap, tWrap); SetFilterMode(filterMode); }
void AsmEditor::InitializePrefs() { SetMarginWidth (MARGIN_LINE_NUMBERS, 40); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (75, 75, 75) ); StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (220, 220, 220)); SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER); SetWrapMode (wxSTC_WRAP_NONE); //wxSTC_WRAP_WORD); // other choice is wxSCI_WRAP_NONE StyleClearAll(); SetLexer(wxSTC_LEX_CPP); // we want to use CPP format -- not ASM wxFont f(10, wxFONTFAMILY_DEFAULT, wxNORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Consolas")); for( int i=0; i < wxSTC_STYLE_LASTPREDEFINED; ++i ) StyleSetFont( i, f ); StyleSetForeground( mySTC_C_DEFAULT, wxColour(0,0,0) ); StyleSetForeground( mySTC_C_COMMENT, wxColour(0,0,0) ); // /* */ comment StyleSetForeground( mySTC_C_COMMENTLINE, wxColour(0,128,0) ); // // comment StyleSetForeground( mySTC_C_COMMENTDOC, wxColour(0,0,0) ); // /** */ comment StyleSetForeground( mySTC_C_NUMBER, wxColour(90,90,90) ); StyleSetForeground( mySTC_C_WORD, wxColour(40,86,165) ); // custom 0 StyleSetForeground( mySTC_C_STRING, wxColour(163,21,21) ); StyleSetForeground( mySTC_C_CHARACTER, wxColour(163,21,21) ); StyleSetForeground( mySTC_C_UUID, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_PREPROCESSOR, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_OPERATOR, wxColour(150,0,0) ); StyleSetForeground( mySTC_C_IDENTIFIER, wxColour(0,0,0) ); StyleSetForeground( mySTC_C_STRINGEOL, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_VERBATIM, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_REGEX, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_COMMENTLINEDOC, wxColour(0,128,0) ); StyleSetForeground( mySTC_C_WORD2, wxColour(150,0,150) ); // custom 1 StyleSetForeground( mySTC_C_COMMENTDOCKEYWORD, wxColour(0,0,0) ); // needs color StyleSetForeground( mySTC_C_COMMENTDOCKEYWORDERROR, wxColour(0,0,0) ); StyleSetForeground( mySTC_C_GLOBALCLASS, wxColour(0,0,0) ); // custom 3 StyleSetBold( mySTC_C_NUMBER, true ); StyleSetBold( mySTC_C_WORD2, true ); StyleSetBold( mySTC_C_WORD, true ); StyleSetFont( mySTC_C_COMMENT, f ); StyleSetFont( mySTC_C_COMMENTDOC, f ); }
void IWnd_stc::_DoUpdateStyle() { BitFlags& flags(param.flags); SetTabWidth (param.wdtab); SetUseTabs (true); SetTabIndents (true); SetBackSpaceUnIndents (true); SetIndent (flags.get(FLAG_INDENT)? param.wdtab: 0); SetViewEOL (flags.get(FLAG_SHOWEOL)); SetIndentationGuides (flags.get(FLAG_INDENTGUIDE)); SetEdgeColumn (80); SetEdgeMode (flags.get(FLAG_LONGLINE)?wxSTC_EDGE_LINE: wxSTC_EDGE_NONE); SetViewWhiteSpace (flags.get(FLAG_WHITESPACE)?wxSTC_WS_VISIBLEALWAYS: wxSTC_WS_INVISIBLE); SetOvertype (flags.get(FLAG_OVERTYPE)); SetReadOnly (flags.get(FLAG_READONLY)); SetWrapMode (flags.get(FLAG_WRAPMODE)?wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); UpdateMarginLineNumWidth(true); }
void Texture::Init(WrapMode wm, MipMap mmMin, MipMap mmMag) { GBLTexture(); SetWrapMode(wm); SetFilter(mmMin, mmMag); }
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); }
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); }
void CodeEditor::OnWrapModeOn(wxCommandEvent &WXUNUSED(event)) { SetWrapMode(GetWrapMode() == 0 ? wxSCI_WRAP_WORD : wxSCI_WRAP_NONE); }
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 Edit::OnWrapmodeOn (wxCommandEvent &WXUNUSED(event)) { SetWrapMode (GetWrapMode() == 0? wxSTC_WRAP_WORD: wxSTC_WRAP_NONE); }
void Texture::SetWrapMode( GLint uv ) { SetWrapMode( uv, uv ); }
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); }
void ScriptEditCtrl::Impl::PreSubclassWindow() { self_->m_hWnd = m_hWnd; // expose HWND SetupDirectAccess(); // If we are running as Unicode, then use the UTF8 codepage #ifdef _UNICODE SetCodePage(SC_CP_UTF8); #endif SetLexer(SCLEX_LUA); StyleSetFont(STYLE_DEFAULT, "Lucida Console"); StyleSetSize(STYLE_DEFAULT, 10); SetKeyWords(0, LuaKeywords); SetKeyWords(1, LuaFunctions); if (enable_input_attribs_) SetKeyWords(2, LuaUser); SetKeyWords(3, ConcatAttributes().c_str()); COLORREF comment= RGB(0,128,128); COLORREF string= RGB(128,128,0); StyleSetFore(SCE_LUA_COMMENT, comment); StyleSetFore(SCE_LUA_COMMENTLINE, comment); StyleSetFore(SCE_LUA_COMMENTDOC, comment); StyleSetFore(SCE_LUA_NUMBER, RGB(0,0,255)); StyleSetFore(SCE_LUA_WORD, RGB(34,78,160)); // keywords StyleSetFore(SCE_LUA_STRING, string); StyleSetFore(SCE_LUA_CHARACTER, string); StyleSetFore(SCE_LUA_LITERALSTRING, string); StyleSetFore(SCE_LUA_WORD2, RGB(53,113,202)); // functions StyleSetFore(SCE_LUA_WORD3, RGB(124,37,203)); // test & number StyleSetBack(SCE_LUA_WORD3, CalcColor(::GetSysColor(COLOR_WINDOW), RGB(0,0,255), 0.95f)); StyleSetFore(SCE_LUA_WORD4, RGB(164,97,49)); // todo: attributes StyleSetFont(SCE_LUA_WORD, "Lucida Console"); StyleSetSize(SCE_LUA_WORD, 10); StyleSetBold(SCE_LUA_WORD, true); //#define SCE_LUA_PREPROCESSOR 9 //#define SCE_LUA_OPERATOR 10 //#define SCE_LUA_IDENTIFIER 11 //#define SCE_LUA_STRINGEOL 12 //#define SCE_LUA_WORD2 13 //#define SCE_LUA_WORD3 14 //#define SCE_LUA_WORD4 15 //#define SCE_LUA_WORD5 16 //#define SCE_LUA_WORD6 17 //#define SCE_LUA_WORD7 18 //#define SCE_LUA_WORD8 19 Colorize(0, -1); //MarkerDefine(MARKER_POINTER, SC_MARK_ARROW); //MarkerSetBack(MARKER_POINTER, RGB(255,255,0)); //MarkerDefine(MARKER_BREAKPOINT, SC_MARK_ROUNDRECT); //MarkerSetBack(MARKER_BREAKPOINT, RGB(0,0,255)); //MarkerDefine(MARKER_ERROR, SC_MARK_ARROW); //MarkerSetBack(MARKER_ERROR, RGB(255,0,0)); int width= 0; SetMarginWidthN(1, width); SetScrollWidthTracking(true); SetScrollWidth(1); SetWrapMode(SC_WRAP_WORD); SetWrapVisualFlags(SC_WRAPVISUALFLAG_END); SetSelBack(true, CalcShade(::GetSysColor(COLOR_HIGHLIGHT), 50.0f)); SetTabWidth(4); SetIndent(4); DWORD pixels= 1; ::SystemParametersInfo(SPI_GETCARETWIDTH, 0, &pixels, 0); SetCaretWidth(pixels); // hwnd is attached, but message processing is not working yet, we are not yet subclassed, // so postpone this WM_NCCALCSIZE call: PostMessage(WM_APP+1234); }
bool Edit::InitializePrefs (const wxString &name) { // initialize styles StyleClearAll(); LanguageInfo const* curInfo = NULL; // determine language bool found = false; int languageNr; for (languageNr = 0; languageNr < g_LanguagePrefsSize; languageNr++) { curInfo = &g_LanguagePrefs [languageNr]; if (curInfo->name == name) { found = true; break; } } if (!found) return false; // set lexer and language SetLexer (curInfo->lexer); m_language = curInfo; // set margin for line numbers SetMarginType (m_LineNrID, wxSTC_MARGIN_NUMBER); StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (wxT("DARK GREY"))); StyleSetBackground (wxSTC_STYLE_LINENUMBER, *wxWHITE); SetMarginWidth (m_LineNrID, 0); // start out not visible // annotations style StyleSetBackground(ANNOTATION_STYLE, wxColour(244, 220, 220)); StyleSetForeground(ANNOTATION_STYLE, *wxBLACK); StyleSetSizeFractional(ANNOTATION_STYLE, (StyleGetSizeFractional(wxSTC_STYLE_DEFAULT)*4)/5); // default fonts for all styles! int Nr; for (Nr = 0; Nr < wxSTC_STYLE_LASTPREDEFINED; Nr++) { wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_MODERN)); StyleSetFont (Nr, font); } // set common styles StyleSetForeground (wxSTC_STYLE_DEFAULT, wxColour (wxT("DARK GREY"))); StyleSetForeground (wxSTC_STYLE_INDENTGUIDE, wxColour (wxT("DARK GREY"))); // initialize settings if (g_CommonPrefs.syntaxEnable) { int keywordnr = 0; for (Nr = 0; Nr < STYLE_TYPES_COUNT; Nr++) { if (curInfo->styles[Nr].type == -1) continue; const StyleInfo &curType = g_StylePrefs [curInfo->styles[Nr].type]; wxFont font(wxFontInfo(curType.fontsize) .Family(wxFONTFAMILY_MODERN) .FaceName(curType.fontname)); StyleSetFont (Nr, font); if (curType.foreground) { StyleSetForeground (Nr, wxColour (curType.foreground)); } if (curType.background) { StyleSetBackground (Nr, wxColour (curType.background)); } StyleSetBold (Nr, (curType.fontstyle & mySTC_STYLE_BOLD) > 0); StyleSetItalic (Nr, (curType.fontstyle & mySTC_STYLE_ITALIC) > 0); StyleSetUnderline (Nr, (curType.fontstyle & mySTC_STYLE_UNDERL) > 0); StyleSetVisible (Nr, (curType.fontstyle & mySTC_STYLE_HIDDEN) == 0); StyleSetCase (Nr, curType.lettercase); const char *pwords = curInfo->styles[Nr].words; if (pwords) { SetKeyWords (keywordnr, pwords); keywordnr += 1; } } } // set margin as unused SetMarginType (m_DividerID, wxSTC_MARGIN_SYMBOL); SetMarginWidth (m_DividerID, 0); SetMarginSensitive (m_DividerID, false); // folding SetMarginType (m_FoldingID, wxSTC_MARGIN_SYMBOL); SetMarginMask (m_FoldingID, wxSTC_MASK_FOLDERS); StyleSetBackground (m_FoldingID, *wxWHITE); SetMarginWidth (m_FoldingID, 0); SetMarginSensitive (m_FoldingID, false); if (g_CommonPrefs.foldEnable) { SetMarginWidth (m_FoldingID, curInfo->folds != 0? m_FoldingMargin: 0); SetMarginSensitive (m_FoldingID, curInfo->folds != 0); SetProperty (wxT("fold"), curInfo->folds != 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.comment"), (curInfo->folds & mySTC_FOLD_COMMENT) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.compact"), (curInfo->folds & mySTC_FOLD_COMPACT) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.preprocessor"), (curInfo->folds & mySTC_FOLD_PREPROC) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.html"), (curInfo->folds & mySTC_FOLD_HTML) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.html.preprocessor"), (curInfo->folds & mySTC_FOLD_HTMLPREP) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.comment.python"), (curInfo->folds & mySTC_FOLD_COMMENTPY) > 0? wxT("1"): wxT("0")); SetProperty (wxT("fold.quotes.python"), (curInfo->folds & mySTC_FOLD_QUOTESPY) > 0? wxT("1"): wxT("0")); } SetFoldFlags (wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED | wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED); // set spaces and indentation SetTabWidth (4); SetUseTabs (false); SetTabIndents (true); SetBackSpaceUnIndents (true); SetIndent (g_CommonPrefs.indentEnable? 4: 0); // others SetViewEOL (g_CommonPrefs.displayEOLEnable); SetIndentationGuides (g_CommonPrefs.indentGuideEnable); SetEdgeColumn (80); 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); return true; }
OutputCtrl::OutputCtrl( wxWindow* parent, wxWindowID id, const wxString& name, const wxPoint& pos, const wxSize& size, long style ) : wxStyledTextCtrl(), m_Selected( -1 ) { wxStyledTextCtrl::Create( parent, id, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxSTATIC_BORDER ); UsePopUp(false); // initialize styles StyleClearAll(); // Set the lexer language SetLexer( wxSTC_LEX_TEX ); // Clear the zoom keys and mouse mapping. CmdKeyClear( wxSTC_KEY_ADD, wxSTC_SCMOD_CTRL ); CmdKeyClear( wxSTC_KEY_SUBTRACT, wxSTC_SCMOD_CTRL ); CmdKeyClear( wxSTC_KEY_DIVIDE, wxSTC_SCMOD_CTRL ); StyleClearAll(); // TODO: Make the font style a configuration option or use some OS default! wxFont* font = wxTheFontList->FindOrCreateFont( 8, wxDEFAULT, wxNORMAL, wxNORMAL, false, "Courier New" ); for ( int i = 0; i < wxSTC_STYLE_LASTPREDEFINED; i++ ) StyleSetFont( i, *font ); StyleSetBackground( 1, wxColour( 255, 0, 0 ) ); StyleSetForeground( 1, wxColour( 255, 255, 255 ) ); StyleSetBackground( 2, wxColour( 255, 255, 255 ) ); StyleSetForeground( 2, wxColour( 255, 0, 0 ) ); /* 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() ); */ IndicatorSetForeground( 0, wxColour( 255, 0, 0 ) ); //SetTabWidth( tsGetPrefs().GetTabWidth() ); // setup the caret. SetCaretWidth( 2 ); 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 ); // Set the margin. SetMarginLeft( 0 ); SetMarginType( 0, wxSTC_MARGIN_SYMBOL ); SetMarginWidth( 0, 12 ); SetMarginWidth( 1, 0 ); SetMarginWidth( 2, 0 ); SetMarginSensitive( 0, false ); //StyleSetBackground( wxSTC_STYLE_LINENUMBER, tsGetPrefs().GetBgColor() ); SetWrapMode( wxSTC_WRAP_NONE ); SetLayoutCache( wxSTC_CACHE_PAGE ); SetReadOnly( true ); UpdatePrefs(); // Create the regular expression here once. // TODO: This possibly needs fixing for non Win32 platforms. m_ErrorExpr.Compile( "([^*?:<>|]*)[ \t]Line:[ \t]([0-9]*)[ \t]-[ \t](.*)", wxRE_ADVANCED | wxRE_ICASE ); wxASSERT( m_ErrorExpr.IsValid() ); m_WarnExpr.Compile( "([^*?:<>|]*)[ \t][(]([0-9]*)[)]:[ \t](.*)", wxRE_ADVANCED | wxRE_ICASE ); wxASSERT( m_WarnExpr.IsValid() ); }