示例#1
0
    def setup(self):
        self.SetLexer(stc.STC_LEX_CONTAINER)
        self.SetStyleBits(7)
        self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyling)

        #self.SetProperty("asp.default.language", "1")
        #self.SetProperty("fold", "0")
        from styles.html import style_control, keywords
        from styles import py

        style_control(self, faces)
        py.style_control(self, faces, self.OFFSET_CURLY)

        # === Dummy controls as lexers ===
        self.dummyHtml = wx.stc.StyledTextCtrl(self)
        self.dummyHtml.SetLayoutCache(wx.stc.STC_CACHE_DOCUMENT)
        self.dummyHtml.Show(False)
        self.dummyHtml.SetLexer(wx.stc.STC_LEX_HTML)
        self.dummyHtml.SetKeyWords(0, keywords())

        self.dummyW2Pt = wx.stc.StyledTextCtrl(self)
        self.dummyW2Pt.SetLayoutCache(wx.stc.STC_CACHE_DOCUMENT)
        self.dummyW2Pt.Show(False)
        self.dummyW2Pt.SetLexer(wx.stc.STC_LEX_PYTHON)
        self.dummyW2Pt.SetKeyWords(0, py.keywords())
示例#2
0
    def openfile(self, filename, lineno=0):
        _, extension = os.path.splitext(filename)
        if extension == '.py':
            self._ctrl = Python(self)

        elif extension in ('.html', '.js'):
            self._ctrl = HTML(self)

        elif extension in ('.css'):
            self._ctrl = Simple(self)
            self._ctrl.SetLexer(stc.STC_LEX_CSS)
            self._ctrl.SetProperty("fold", "1")
            self._ctrl.SetProperty("tab.timmy.whinge.level", "1")
            from styles.css import style_control, keywords
            style_control(self._ctrl, faces)

        else:
            self._ctrl = Simple(self)

        self._sizer.Add(self._ctrl, 1, wx.EXPAND, 0)
        self._ctrl.setup()

        if lineno > 0:
            self.goto_line(lineno)

        self._ctrl.SetIndent(4)               # Proscribed indent size for wx
        self._ctrl.SetIndentationGuides(False) # Show indent guides
        self._ctrl.SetBackSpaceUnIndents(True)# Backspace unindents rather than delete 1 space
        self._ctrl.SetTabIndents(True)        # Tab key indents
        self._ctrl.SetTabWidth(4)             # Proscribed tab size for wx
        self._ctrl.SetUseTabs(False)          # Use spaces rather than tabs, or
                                            # TabTimmy will complain!    
        f = open(filename)
        t = f.read()
        f.close()

        try:
            t = t.decode('utf-8')
        except UnicodeDecodeError:
            t = t.decode('latin-1')

        self._ctrl.SetText(t)
        self._ctrl.EmptyUndoBuffer()
	# FIXME: Ugly hack to mark the buffer as not dirty
	# must be a better way
        wx.FutureCall(250, self._ctrl.SetSavePoint)

        self.Layout()

        return 0
示例#3
0
    def setup(self):
        self.SetLexer(stc.STC_LEX_PYTHON)
        self.SetProperty("fold", "1")
        self.SetProperty("tab.timmy.whinge.level", "1")
        from styles.py import style_control, keywords
        style_control(self, faces)

        self.SetKeyWords(0, keywords())

        self.SetIndent(4)               # Proscribed indent size for wx
        self.SetIndentationGuides(False) # Show indent guides
        self.SetBackSpaceUnIndents(True)# Backspace unindents rather than delete 1 space
        self.SetTabIndents(True)        # Tab key indents
        self.SetTabWidth(4)             # Proscribed tab size for wx
        self.SetUseTabs(False)          # Use spaces rather than tabs, or
                                        # TabTimmy will complain!    
        self.SetWordChars('abcdefghijklmnopqrstuvwxyz'
                            'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                            '0123456789._')