def initData(self, argv): '''init configurations''' Application.getSettings().load() '''init document manager''' '''init plugin manager'''
def __createToolbar(self, toolbarInfo, id): if toolbarInfo is None: return toolbar = wx.ToolBar(self._window, id, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TB_FLAT | wx.TB_NODIVIDER) index = 0 for itemInfo in toolbarInfo.values(): itemId = id * 100 + index if itemInfo.getImage() is None or '' == itemInfo.getImage().strip(): continue imagePath = Application.getSettings().getWorkPath() + os.path.sep + itemInfo.getImage() bmp = wx.Bitmap(imagePath, wx.BITMAP_TYPE_PNG) toolbar.AddLabelTool(itemId, itemInfo.getName(), bmp, longHelp=itemInfo.getTip()) action = Application.getActionManager().getAction(itemInfo.getAction()) if action is not None: toolbar.Bind(wx.EVT_TOOL, action.execute, id=itemId) index += 1 if 0 == index: return None toolbar.Realize() return toolbar
def __setEdgeStyle(self): editorStyle = Application.getSettings().getEditorStyle() edge = editorStyle.getEdge() if edge.getVisible(): self._editView.SetEdgeMode(stc.STC_EDGE_LINE) self._editView.SetEdgeColumn(edge.getMaxColumns()) else: self._editView.SetEdgeMode(stc.STC_EDGE_NONE)
def __setDefaultFont(self, lexer): editorStyle = Application.getSettings().getEditorStyle() font = editorStyle.getFont() if highlightSymbols.SYMBOLS.has_key(lexer): symbols = highlightSymbols.SYMBOLS[lexer] if symbols is None: symbols = highlightSymbols.NULL_SYMBOLS for symbol in symbols.values(): self._editView.StyleSetSpec(symbol, font.getSettings())
def __setIndentStyle(self): editorStyle = Application.getSettings().getEditorStyle() indent = editorStyle.getIndent() self._editView.SetIndent(indent.getSize()) self._editView.SetIndentationGuides(indent.getShowIndentGuide()) self._editView.SetBackSpaceUnIndents(indent.getBackspaceUnindents()) self._editView.SetTabIndents(indent.getTabIndes()) self._editView.SetTabWidth(indent.getTabWidth()) self._editView.SetUseTabs(indent.getUseTabs()) self._editView.SetViewWhiteSpace(indent.getViewWhitespace())
def __getFileEditor(self, filename): editorClass = '' filePatterns = Application.getSettings().getFileAssociations().keys() for filePattern in filePatterns: if fnmatch(filename, filePattern): editorClass = Application.getSettings().getFileAssociations()[filePattern] if editorClass is None or '' == editorClass: editorClass = Application.getSettings().getDefaultEditor() if editorClass is None or '' == editorClass: return None editorClsObj = createClassInstance(editorClass) if editorClsObj is None: return None editor = editorClsObj(self) if editor is None: return None return editor
def __setMarkerStyle(self): editorStyle = Application.getSettings().getEditorStyle() marker = editorStyle.getMarker() style = EditorStyle.MARKER_STYLES[marker.getStyle()] fgColor = marker.getFgColor() bgColor = marker.getBgColor() for key, value in style.items(): try: self._editView.MarkerDefine(key, value, fgColor, bgColor) except: continue self.Bind(stc.EVT_STC_MARGINCLICK, self.__onMarginClick) self.Bind(stc.EVT_STC_UPDATEUI, self._onUpdateUI)
def __loadFileWithEncoding(self, filename): import codecs encodings=Application.getSettings().getEncodings() if encodings is None: encodings = ['utf-8'] for encoding in encodings: try: file = codecs.open(filename, 'r', encoding=encoding) context = file.read() self._encoding = encoding file.close() return context except UnicodeDecodeError: file.close() except LookupError: pass # invalid encoding return None
def __setHighlightStyle(self, lexer): if not highlightSymbols.SYMBOLS.has_key(lexer) or stc.STC_LEX_NULL == lexer: return editorStyle = Application.getSettings().getEditorStyle() highlightStyles = editorStyle.getHighlightStyles() if not highlightStyles.has_key(lexer): return highlight = highlightStyles[lexer] self._editView.SetKeyWords(0, highlight.getKeywords()) styles = highlight.getHighlightStyles() symbols = highlightSymbols.SYMBOLS[lexer] for key, value in styles.items(): if symbols.has_key(key): self._editView.StyleSetSpec(symbols[key], value.getSettings())
def __init__(self, workPath): wx.App.__init__(self) Application.getSettings().setWorkPath(workPath)
def initializes(self): toolbarInfos = Application.getSettings().getToolbars() self.__createToolbars(toolbarInfos);
def __setCaretStyle(self): editorStyle = Application.getSettings().getEditorStyle() caret = editorStyle.getCaret() self._editView.SetCaretForeground(caret.getColor())
def __setEOLStyle(self): editorStyle = Application.getSettings().getEditorStyle() eol = editorStyle.getEOL() self._editView.SetEOLMode(stc.STC_EOL_LF) self._editView.SetViewEOL(eol.getShowEOL())
def initialize(self): menuInfos = Application.getSettings().getMenus() self.__createMenus(menuInfos) self._window.SetMenuBar(self.__getMenubar())