Exemple #1
0
def init_accelerator(win, accellist, editoraccellist):
    ini = common.get_config_file_obj(onelevel=True)
    
    keylist = {}
    for mid, v in accellist.items():
        keys, func = v
        if not keys:
            continue
        if not keys in keylist:
            keylist[keys] = (mid, 'main')
        else:
            error.error('There is already %s defined! Please check.' % keys)

    for mid, v in editoraccellist.items():
        keys, func = v
        if not keys in keylist:
            keylist[keys] = (mid, 'editor')
        else:
            error.error('There is already %s defined! Please check.' % keys)
    
    #mid can be a mainframe menu ID or a mainframe function name
    #which should only has one parameter
    for mid, hotkey in ini.main_hotkey.items():
        _id, _t = keylist.get(hotkey, ('', ''))
        if _id:
            if _t == 'main':
                keys, func = accellist[_id]
                accellist[_id] = ('', func)
            else:
                keys, func = editoraccellist[_id]
                editoraccellist[_id] = ('', func)
            
        if mid in editoraccellist:
            keys, func = editoraccellist[mid]
            del editoraccellist[mid]
            accellist[mid] = (hotkey, func)
        elif mid in accellist:
            keys, func = accellist[mid]
            accellist[mid] = (hotkey, func)

    #mid can be a editor menu ID or a editor function name
    #which should only has one parameter
    for mid, hotkey in ini.editor_hotkey.items():
        _id, _t = keylist.get(hotkey, ('', ''))
        if _id:
            if _t == 'main':
                keys, func = accellist[_id]
                accellist[_id] = ('', func)
            else:
                keys, func = editoraccellist[_id]
                editoraccellist[_id] = ('', func)
            
        if accellist.has_key(mid):
            keys, func = accellist[mid]
            del accellist[mid]
            editoraccellist[mid] = (hotkey, func)
        elif editoraccellist.has_key(mid):
            keys, func = editoraccellist[mid]
            editoraccellist[mid] = (hotkey, func)
Exemple #2
0
def init_accelerator(win, accellist, editoraccellist):
    ini = common.get_config_file_obj(onelevel=True)

    keylist = {}
    for mid, v in accellist.items():
        keys, func = v
        if not keys:
            continue
        if not keys in keylist:
            keylist[keys] = (mid, 'main')
        else:
            error.error('There is already %s defined! Please check.' % keys)

    for mid, v in editoraccellist.items():
        keys, func = v
        if not keys in keylist:
            keylist[keys] = (mid, 'editor')
        else:
            error.error('There is already %s defined! Please check.' % keys)

    #mid can be a mainframe menu ID or a mainframe function name
    #which should only has one parameter
    for mid, hotkey in ini.main_hotkey.items():
        _id, _t = keylist.get(hotkey, ('', ''))
        if _id:
            if _t == 'main':
                keys, func = accellist[_id]
                accellist[_id] = ('', func)
            else:
                keys, func = editoraccellist[_id]
                editoraccellist[_id] = ('', func)

        if mid in editoraccellist:
            keys, func = editoraccellist[mid]
            del editoraccellist[mid]
            accellist[mid] = (hotkey, func)
        elif mid in accellist:
            keys, func = accellist[mid]
            accellist[mid] = (hotkey, func)

    #mid can be a editor menu ID or a editor function name
    #which should only has one parameter
    for mid, hotkey in ini.editor_hotkey.items():
        _id, _t = keylist.get(hotkey, ('', ''))
        if _id:
            if _t == 'main':
                keys, func = accellist[_id]
                accellist[_id] = ('', func)
            else:
                keys, func = editoraccellist[_id]
                editoraccellist[_id] = ('', func)

        if accellist.has_key(mid):
            keys, func = accellist[mid]
            del accellist[mid]
            editoraccellist[mid] = (hotkey, func)
        elif editoraccellist.has_key(mid):
            keys, func = editoraccellist[mid]
            editoraccellist[mid] = (hotkey, func)
    def __init__(self, parent, mainframe):
        self.initmixin()

        wx.stc.StyledTextCtrl.__init__(self, parent, -1)
        self.parent = parent
        self.mainframe = mainframe
        self.SetMarginWidth(0, 0)
        self.SetMarginWidth(1, 0)
        self.SetMarginWidth(2, 0)

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('message_font', font.GetFaceName())
        fontsize = x.default.get('message_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('message_font') and locale.getdefaultlocale()[0] == 'zh_CN':
            fontname = u'宋体'
        self.defaultfaces = {
            'name':fontname,
            'size':fontsize,
        }

        self.StyleSetSpec(wx.stc.STC_STYLE_DEFAULT, "face:%(name)s,size:%(size)d" % self.defaultfaces)
        self.StyleClearAll()
        
        self.SetScrollWidth(1)
        self.maxline = 'WWWW'

        #disable popup
        self.UsePopUp(0)

        for key in MessageWindow.imagelist.keys():
            f = MessageWindow.imagelist[key]
            MessageWindow.imagelist[key] = common.getpngimage(f)

        self.popmenu = makemenu.makepopmenu(self, self.popmenulist, self.imagelist)

        wx.stc.EVT_STC_MODIFIED(self, self.GetId(), self.OnModified)
        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)

        self.init_update_ui()

#        self.SetCaretForeground(')
        if x.default.has_key('message_caretlineback'):
            self.SetCaretLineBack(x.default.message_caretlineback)
        else:
            self.SetCaretLineBack('#FF8000')
        self.SetCaretLineVisible(True)
        if self.mainframe.pref.message_wrap:
            self.SetWrapMode(wx.stc.STC_WRAP_WORD)
        else:
            self.SetWrapMode(wx.stc.STC_WRAP_NONE)
        self.SetScrollWidth(5000)

        self.callplugin('init', self)
Exemple #4
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        self.parent = parent
        self.mainframe = mainframe
        self.pref = self.mainframe.pref
        self.app = self.mainframe.app
        self.mainframe.editctrl = self
        self.document = None
        self.lastfilename = None
        self.lastlanguagename = ''
        self.lastdocument = None

        if self.pref.notebook_direction == 0:
            style = 0
        else:
            style = FNB.FNB_BOTTOM
        FNB.FlatNotebook.__init__(self, parent, -1, 
            style=style|FNB.FNB_SMART_TABS|FNB.FNB_VC8|FNB.FNB_X_ON_TAB|
                FNB.FNB_NO_X_BUTTON|FNB.FNB_DROPDOWN_TABS_LIST|FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
        self.id = self.GetId()


        #make popup menu
        #@add_menu menulist
        self.callplugin_once('add_menu', EditorFactory.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', EditorFactory.imagelist)
        #@add_panel_list panellist
        self.callplugin_once('add_panel_list', EditorFactory.panellist)

        self.popmenu = makemenu.makepopmenu(self, EditorFactory.popmenulist, EditorFactory.imagelist)
#        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.id, self.OnChanged)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.id, self.OnClose)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
        FNB.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU(self, self.id, self.OnPopup)

        self.imageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.imageindex[name] = i
        self.pageimages = pageimages

#        self.AssignImageList(self.pageimages)
        self.SetImageList(self.pageimages)
        self.skip_closing = False
        self.skip_page_change = False
        self.full = False
        self.last_side_panel_status = None

        #set FlatNotebook style
        x = common.get_config_file_obj()
        tab_color = x.default.get('editor_tab_color', '#98FB98')
        self.SetActiveTabColour(tab_color)
def app_init(app, filenames):
#    print 'ddeflag', app.ddeflag
    if app.ddeflag:
        x = common.get_config_file_obj()
        port = x.server.get('port', 50000)
        if DDE.senddata('\r\n'.join(filenames), port=port):
            sys.exit(0)
        else:
            DDE.run(port=port)
Exemple #6
0
def OnToolMemo(win, event):
    if win.memo_win:
        win.memo_win.Close()
        win.memo_win = None
    else:
        import Pad
        from modules import Globals
        pad = Pad.PAD(win, os.path.join(Globals.userpath, common.get_config_file_obj().default.get('memo', 'memo.txt')), tr('Easy Memo'))
        pad.Show()
        win.memo_win = pad
Exemple #7
0
 def OnIgnoreThis(self, event):
     item = self.tree.GetSelection()
     if not self.is_ok(item): return
     filename = self.get_node_filename(item)
     if filename not in self.filter:
         self.filter.append(filename)
         ini = common.get_config_file_obj()
         ini.ignore.matches = self.filter
         ini.save()
         self.OnRefresh()
Exemple #8
0
 def OnIgnoreThis(self, event):
     item = self.tree.GetSelection()
     if not self.is_ok(item): return
     filename = self.get_node_filename(item)
     if filename not in self.filter:
         self.filter.append(filename)
         ini = common.get_config_file_obj()
         ini.ignore.matches = self.filter
         ini.save()
         self.OnRefresh()
Exemple #9
0
 def OnIgnoreThisType(self, event):
     item = self.tree.GetSelection()
     if not self.is_ok(item): return
     filename = self.get_node_filename(item)
     fname, ext = os.path.splitext(filename)
     if ext not in self.filter:
         self.filter.append(str('*' + ext))
         ini = common.get_config_file_obj()
         ini.ignore.matches = self.filter
         ini.save()
         self.OnRefresh()
Exemple #10
0
 def OnIgnoreThisType(self, event):
     item = self.tree.GetSelection()
     if not self.is_ok(item): return
     filename = self.get_node_filename(item)
     fname, ext = os.path.splitext(filename)
     if ext not in self.filter:
         self.filter.append(str('*' + ext))
         ini = common.get_config_file_obj()
         ini.ignore.matches = self.filter
         ini.save()
         self.OnRefresh()
    def __init__(self,
                 parent,
                 size=(850, 500),
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
        self.initmixin()

        #config.ini
        self.ini = common.get_config_file_obj()

        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           title=tr("Preferences"),
                           size=size,
                           style=style)

        self.value_set = []
        self.pages = {}
        self.pagenames = {}
        self.values = {}

        self.parent = parent
        self.pref = self.parent.pref
        self.default_pref = Preference.Preference()

        self.box = box = ui.VBox(namebinding='widget')
        self.treebook = TreeBookPanel(self, -1)
        self.addPages(self.treebook)

        box.add(self.treebook, proportion=1, flag=wx.EXPAND | wx.ALL)

        box.add(wx.StaticLine(self), flag=wx.EXPAND | wx.ALL)

        buttons = [(tr('OK'), wx.ID_OK, 'btnOk'),
                   (tr('Cancel'), wx.ID_CANCEL, 'btnCancel'),
                   (tr('Apply'), wx.ID_APPLY, 'btnApply')]
        box.add(ui.simple_buttons(buttons), flag=wx.ALIGN_CENTER | wx.BOTTOM)
        box.bind('btnOk', 'click', self.OnOk)
        box.bind('btnApply', 'click', self.OnApply)

        self.create_pages()

        self.callplugin('initpreference', self)
        ui.create(self, box, 0)
        self.btnOk.SetDefault()

        self.treebook.select()
        self.values = self.get_values()

        wx.EVT_UPDATE_UI(self, self.btnApply.GetId(), self.OnUpdateApply)

        self.callplugin('aftercreate', self)
Exemple #12
0
    def validate(self, path):
        import fnmatch
        flag = False

        self.filter = ['*/.*', '*.pyc', '*.bak', '.pyo']
        ini = common.get_config_file_obj()

        if ini.ignore.matches:
            self.filter = ini.ignore.matches

        for p in self.filter:
            flag |= fnmatch.fnmatch(path, p)

        return flag
Exemple #13
0
    def init(self):
        self._syntaxitems = {}
        self._syntaxnames = []

        self.callplugin('set_default_style', self)
        
        #add default font settings in config.ini
        x = common.get_config_file_obj()
#        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
#        font = wx.Font(10, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
#        fontname = x.default.get('editor_font', font.GetFaceName())
        fontname = x.default.get('editor_font', common.faces['mono'])
        fontsize = x.default.get('editor_fontsize', common.faces['size'])
        linesize = x.default.get('editor_linesize', common.faces['lnsize'])

        if isinstance(fontname, str):
            fontname = unicode(fontname, 'utf-8')
            
        #test is the fontname is ok
        if hasattr(wx.FontEnumerator, 'IsValidFacename') and not wx.FontEnumerator.IsValidFacename(fontname):
            font = wx.Font(fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
            fontname = font.FaceName
            
        common.faces.update({
            'mono':fontname,
            'size':fontsize,
            'lnsize':linesize,
        })
        
        #get default style
        self.get_default_style(x)
        
        self.__class__.STC_STYLE_DEFAULT = self.STC_STYLE_DEFAULT % common.faces
        self.__class__.STC_STYLE_LINENUMBER = self.STC_STYLE_LINENUMBER % common.faces
        
        self.font = wx.Font(fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL, face=fontname)
        
        self.addSyntaxItem('default',       tr('Style default'),            wx.stc.STC_STYLE_DEFAULT,       self.STC_STYLE_DEFAULT)
        self.addSyntaxItem('-caretfore',    tr('Caret fore colour'),        0,  self.STC_STYLE_CARET_FORE)
        self.addSyntaxItem('-caretback',    tr('CaretLine back colour'),    0,  self.STC_STYLE_CARETLINE_BACK)
        self.addSyntaxItem('-selback',      tr('Selection back colour'),    0,  self.STC_STYLE_SELECTION_BACK)
        self.addSyntaxItem('-foldercolor',  tr('Folder margin colour'),     0,  self.STC_STYLE_FOLDER)
        self.addSyntaxItem('-markercolor',  tr('Marker colour'),            0,  self.STC_STYLE_MARKER)
        self.addSyntaxItem('linenumber',    tr('Line numbers'),             wx.stc.STC_STYLE_LINENUMBER,    self.STC_STYLE_LINENUMBER)
        self.addSyntaxItem('controlchar',   tr('Control characters'),       wx.stc.STC_STYLE_CONTROLCHAR,   self.STC_STYLE_CONTROLCHAR)
        self.addSyntaxItem('bracelight',    tr('Matched braces'),           wx.stc.STC_STYLE_BRACELIGHT,    self.STC_STYLE_BRACELIGHT)
        self.addSyntaxItem('bracebad',      tr('Unmatched brace'),          wx.stc.STC_STYLE_BRACEBAD,      self.STC_STYLE_BRACEBAD)
#        self.initSyntaxItems()
        self.loadEasySyntaxItems()
        self.load()
Exemple #14
0
    def validate(self, path):
        import fnmatch
        flag = False

        self.filter = ['*/.*', '*.pyc', '*.bak', '.pyo']
        ini = common.get_config_file_obj()

        if ini.ignore.matches:
            self.filter = ini.ignore.matches

        for p in self.filter:
            flag |= fnmatch.fnmatch(path, p)

        return flag
Exemple #15
0
def OnOptionLanguageChange(win, event):
    eid = event.GetId()
    index = win.language_ids.index(eid)
    country = win.language_country[index]
    wx.MessageDialog(win, tr("Because you changed the language, \nit will be enabled at next startup."), tr("Change language"), wx.OK).ShowModal()
    ini = common.get_config_file_obj()
    ini.language.default = country
    ini.save()

    # change menu check status
    menu = makemenu.findmenu(win.menuitems, 'IDM_OPTION_LANGUAGE')
    for id in win.language_ids:
        if id == eid:
            menu.Check(id, True)
        else:
            menu.Check(id, False)
Exemple #16
0
def OnOptionLanguageChange(win, event):
    eid = event.GetId()
    index = win.language_ids.index(eid)
    country = win.language_country[index]
    wx.MessageDialog(win, tr("Because you changed the language, \nit will be enabled at next startup."), tr("Change language"), wx.OK).ShowModal()
    ini = common.get_config_file_obj()
    ini.language.default = country
    ini.save()

    # change menu check status
    menu = makemenu.findmenu(win.menuitems, 'IDM_OPTION_LANGUAGE')
    for id in win.language_ids:
        if id == eid:
            menu.Check(id, True)
        else:
            menu.Check(id, False)
    def __init__(self, parent, mainframe):
        self.initmixin()

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('shell_font', font.GetFaceName())
        fontsize = x.default.get('shell_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('shell_font') and locale.getdefaultlocale(
        )[0] == 'zh_CN':
            fontname = u'宋体'

        import wx.py.editwindow as edit
        edit.FACES['mono'] = fontname
        edit.FACES['size'] = fontsize

        wx.py.shell.Shell.__init__(self, parent, -1, InterpClass=NEInterpreter)

        #disable popup
        self.UsePopUp(0)

        self.parent = parent
        self.mainframe = mainframe
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)

        for key in ShellWindow.imagelist.keys():
            f = ShellWindow.imagelist[key]
            ShellWindow.imagelist[key] = common.getpngimage(f)

        self.popmenu = makemenu.makepopmenu(self, ShellWindow.popmenulist,
                                            ShellWindow.imagelist)

        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)

        wx.EVT_UPDATE_UI(self, self.IDPM_UNDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY_CLEAR, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE_RUN, self._OnUpdateUI)
def app_init(app, filenames):
    #    print 'ddeflag', app.ddeflag
    if app.ddeflag:
        x = common.get_config_file_obj()
        port = x.server.get('port', 50009)
        if DDE.senddata('\r\n'.join(filenames), port=port):
            print """Found previous instance of UliPad and the files will be 
opened in it, current instance will be quit. If you have not 
seen the UliPad started, please change the DDE support port at 
config.ini with :

    [server]
    port=50001 #or other port number

If it's alreay exit, contact ulipad author to get help."""
            sys.exit(0)
        else:
            DDE.run(port=port)
Exemple #19
0
def app_init(app, filenames):
#    print 'ddeflag', app.ddeflag
    if app.ddeflag:
        x = common.get_config_file_obj()
        port = x.server.get('port', 50009)
        if DDE.senddata('\r\n'.join(filenames), port=port):
            print """Found previous instance of UliPad and the files will be 
opened in it, current instance will be quit. If you have not 
seen the UliPad started, please change the DDE support port at 
config.ini with :

    [server]
    port=50001 #or other port number

If it's alreay exit, contact ulipad author to get help."""
            sys.exit(0)
        else:
            DDE.run(port=port)
Exemple #20
0
    def __init__(self, parent, size=(850, 500), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
        self.initmixin()

        #config.ini
        self.ini = common.get_config_file_obj()
        
        wx.Dialog.__init__(self, parent, -1, title=tr("Preferences"), size=size, style=style)

        self.value_set = []
        self.pages = {}
        self.pagenames = {}
        self.values = {}

        self.parent = parent
        self.pref = self.parent.pref
        self.default_pref = Preference.Preference()
        
        self.box = box = ui.VBox(namebinding='widget')
        self.treebook = TreeBookPanel(self, -1)
        self.addPages(self.treebook)
        
        box.add(self.treebook, proportion=1, flag=wx.EXPAND|wx.ALL)

        box.add(wx.StaticLine(self), flag=wx.EXPAND|wx.ALL)
        
        buttons = [(tr('OK'), wx.ID_OK, 'btnOk'), 
            (tr('Cancel'), wx.ID_CANCEL, 'btnCancel'),
            (tr('Apply'), wx.ID_APPLY, 'btnApply')]
        box.add(ui.simple_buttons(buttons), flag=wx.ALIGN_CENTER|wx.BOTTOM)
        box.bind('btnOk', 'click', self.OnOk)
        box.bind('btnApply', 'click', self.OnApply)
        
        self.create_pages()
        
        self.callplugin('initpreference', self)
        ui.create(self, box, 0)
        self.btnOk.SetDefault()
        
        self.treebook.select()
        self.values = self.get_values()
        
        wx.EVT_UPDATE_UI(self, self.btnApply.GetId(), self.OnUpdateApply)

        self.callplugin('aftercreate', self)
Exemple #21
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        fontname = x.default.get('shell_font', font.GetFaceName())
        fontsize = x.default.get('shell_fontsize', 10)
        #todo fontsize maybe changed for mac
        if wx.Platform == '__WXMAC__':
            fontsize = 13
        #add chinese simsong support, because I like this font
        if not x.default.has_key('shell_font') and locale.getdefaultlocale()[0] == 'zh_CN':
            fontname = u'宋体'

        import wx.py.editwindow as edit
        edit.FACES['mono'] = fontname
        edit.FACES['size'] = fontsize

        wx.py.shell.Shell.__init__(self, parent, -1, InterpClass=NEInterpreter)

        #disable popup
        self.UsePopUp(0)
        
        self.parent = parent
        self.mainframe = mainframe
        wx.EVT_KILL_FOCUS(self, self.OnKillFocus)
        
        for key in ShellWindow.imagelist.keys():
            f = ShellWindow.imagelist[key]
            ShellWindow.imagelist[key] = common.getpngimage(f)
        
        self.popmenu = makemenu.makepopmenu(self, ShellWindow.popmenulist, ShellWindow.imagelist)
        
        wx.EVT_RIGHT_DOWN(self, self.OnPopUp)
        
        wx.EVT_UPDATE_UI(self, self.IDPM_UNDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_REDO, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_CUT, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_COPY_CLEAR, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE, self._OnUpdateUI)
        wx.EVT_UPDATE_UI(self, self.IDPM_PASTE_RUN, self._OnUpdateUI)
Exemple #22
0
    def deal_file_images(self):
        self.fileimages = {}
        self.fileimages['.py'] = 'file_py.gif'
        self.fileimages['.pyw'] = 'file_py.gif'
        self.fileimages['.txt'] = 'file_txt.gif'
        self.fileimages['.html'] = 'file_html.gif'
        self.fileimages['.htm'] = 'file_html.gif'
        self.fileimages['.ini'] = 'file_txt.gif'
        self.fileimages['.bat'] = 'file_txt.gif'
        self.fileimages['.xml'] = 'file_xml.gif'
        ini = common.get_config_file_obj()
        self.fileimages.update(ini.fileimages)
        ini.fileimages = self.fileimages
        ini.save()

        self.fileimageindex = {}
        for image in self.fileimages.values():
            if not self.fileimageindex.has_key(image):
                obj = common.getpngimage(os.path.join(self.mainframe.userpath, 'images', image))
                self.fileimageindex[image] = self.add_image(obj)
Exemple #23
0
    def deal_file_images(self):
        self.fileimages = {}
        self.fileimages['.py'] = 'file_py.gif'
        self.fileimages['.pyw'] = 'file_py.gif'
        self.fileimages['.txt'] = 'file_txt.gif'
        self.fileimages['.html'] = 'file_html.gif'
        self.fileimages['.htm'] = 'file_html.gif'
        self.fileimages['.ini'] = 'file_txt.gif'
        self.fileimages['.bat'] = 'file_txt.gif'
        self.fileimages['.xml'] = 'file_xml.gif'
        ini = common.get_config_file_obj()
        self.fileimages.update(ini.fileimages)
        ini.fileimages = self.fileimages
        ini.save()

        self.fileimageindex = {}
        for image in self.fileimages.values():
            if not self.fileimageindex.has_key(image):
                obj = common.getpngimage(
                    os.path.join(self.mainframe.userpath, 'images', image))
                self.fileimageindex[image] = self.add_image(obj)
Exemple #24
0
    def loadData(self):
        self.tree.CollapseAndReset(self.root)

        self.items = {}
        self.ids = 1

        #check and create wizard path
        wizardpath = os.path.join(self.mainframe.app.workpath, 'wizard')
        if not os.path.exists(wizardpath):
            os.mkdir(wizardpath)

        self._loadPath(self.root, wizardpath)

        x = common.get_config_file_obj()
        if x.wizard.path:
            if isinstance(x.wizard.path, list):
                for p in x.wizard.path:
                    self._loadPath(self.root, p)
            else:
                self._loadPath(self.root, p)

        self.tree.Expand(self.root)
Exemple #25
0
    def loadData(self):
        self.tree.CollapseAndReset(self.root)

        self.items = {}
        self.ids = 1

        #check and create wizard path
        wizardpath = os.path.join(self.mainframe.app.workpath, 'wizard')
        if not os.path.exists(wizardpath):
            os.mkdir(wizardpath)

        self._loadPath(self.root, wizardpath)

        x = common.get_config_file_obj()
        if x.wizard.path:
            if isinstance(x.wizard.path, list):
                for p in x.wizard.path:
                    self._loadPath(self.root, p)
            else:
                self._loadPath(self.root, p)

        self.tree.Expand(self.root)
Exemple #26
0
def get_document_comment_chars(editor):
    chars = {
        'c': '//',
        'python': '#',
        'ruby': '#',
        'perl': '#',
        'java': '//',
        'js': '//',
        'html': '//',
        'css': '//',
        'default': '#',
    }
    lang = editor.languagename
    x = common.get_config_file_obj(values={'comment_chars': chars})
    cchar = ''
    if x.comment_chars.has_key(lang):
        cchar = x.comment_chars[lang]
    if not cchar:
        if x.comment_chars.has_key('default'):
            cchar = x.comment_chars.default
    if not cchar:
        cchar = Globals.pref.last_comment_chars
    return cchar
Exemple #27
0
def get_document_comment_chars(editor):
    chars = {
        'c':'//',
        'python':'#',
        'ruby':'#',
        'perl':'#',
        'java':'//',
        'js':'//',
        'html':'//',
        'css':'//',
        'default':'#',
    }
    lang = editor.languagename
    x = common.get_config_file_obj(values={'comment_chars':chars})
    cchar = ''
    if x.comment_chars.has_key(lang):
        cchar = x.comment_chars[lang]
    if not cchar:
        if x.comment_chars.has_key('default'):
            cchar = x.comment_chars.default
    if not cchar:
        cchar = Globals.pref.last_comment_chars
    return cchar
Exemple #28
0
from modules import Globals

DEBUG = True

workpath = os.path.dirname(os.path.realpath(sys.argv[0]))
confpath = os.path.join(workpath, 'conf')
sys.path.insert(0, workpath)
sys.path.insert(0, os.path.join(workpath, 'modules'))
sys.path.insert(0, os.path.join(workpath, 'plugins'))
sys.path.insert(0, os.path.join(workpath, 'packages'))
curpath = os.getcwd()
os.chdir(workpath)
Globals.workpath = workpath
Globals.confpath = confpath

ini = common.get_config_file_obj()
debugflag = ini.default.get('debug', False)

#add pythonpath settings
if ini.default.has_key('pythonpath'):
    pythonpath = ini.default.pythonpath
    if isinstance(pythonpath, list):
        sys.path = pythonpath + sys.path
    elif isinstance(pythonpath, (str, unicode)):
        sys.path.insert(0, pythonpath)
    else:
        print 'The pythonpath should be a string list or a string.'

common.print_time('begin...', DEBUG)

Debug.debug = Debug.Debug(os.path.join(workpath, 'debug.txt'), debugflag)
def read_todos(editor):
    lang = editor.languagename
    filename = editor.filename
    #set default pattern
    pl = todo_patten.get(lang, [])
    if not isinstance(pl, (list, tuple)):
        pl = [pl]
    #first check the config.ini
    ini = common.get_config_file_obj()
    if ini.todo_pattern.has_key(lang):
        pattern = ini.todo_pattern[lang]
        if isinstance(pattern, list):
            pl = []
            for i in pattern:
                try:
                    pl.append(re.compile(i))
                except:
                    error.traceback()
                    error.info('pattern=' + i)
        else:
            pl = []
            try:
                pl.append(re.compile(pattern))
            except:
                error.traceback()
                error.info('pattern=' + pattern)
    data = []
    if pl:
        buf = StringIO.StringIO(editor.GetText())
        for i, line in enumerate(buf):
            for r in pl:
                b = r.search(line)
                if b:
                    date = ''
                    result = filter(None, b.groups())
                    if not result:
                        message = ''
                        important = ''
                    else:
                        message = result[0].rstrip()
                        important = ''
                        for n in range(len(message) - 1, -1, -1):
                            if message[n] == '!':
                                important += '!'
                            else:
                                break
                        if n > 0:
                            message = message[:n + 1]
                        else:
                            message = ''
                        #find duedate
                        m = r_duedate.search(message)
                        if m:
                            message = message[:m.start()] + message[m.end():]
                            date = m.group(1)
                    data.append((important, i + 1, date, message, filename))

    def _cmp(x, y):
        if x[1] > y[1]:
            return -1
        elif x[1] < y[1]:
            return 1
        else:
            return cmp(x[2], y[2])

    data.sort(_cmp)
    return data
Exemple #30
0
from modules import Globals

DEBUG = True

workpath = os.path.dirname(os.path.realpath(sys.argv[0]))
confpath = os.path.join(workpath, 'conf')
sys.path.insert(0, workpath)
sys.path.insert(0, os.path.join(workpath, 'modules'))
sys.path.insert(0, os.path.join(workpath, 'plugins'))
sys.path.insert(0, os.path.join(workpath, 'packages'))
curpath = os.getcwd()
os.chdir(workpath)
Globals.workpath = workpath
Globals.confpath = confpath

ini = common.get_config_file_obj()
debugflag = ini.default.get('debug', False)

#add pythonpath settings
if ini.default.has_key('pythonpath'):
    pythonpath = ini.default.pythonpath
    if isinstance(pythonpath, list):
        sys.path = pythonpath + sys.path
    elif isinstance(pythonpath, (str, unicode)):
        sys.path.insert(0, pythonpath)
    else:
        print 'The pythonpath should be a string list or a string.'

common.print_time('begin...', DEBUG)

Debug.debug = Debug.Debug(os.path.join(workpath, 'debug.txt'), debugflag)
    def init(self):
        self._syntaxitems = {}
        self._syntaxnames = []

        self.callplugin('set_default_style', self)

        #add default font settings in config.ini
        x = common.get_config_file_obj()
        #        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        #        font = wx.Font(10, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
        #        fontname = x.default.get('editor_font', font.GetFaceName())
        fontname = x.default.get('editor_font', common.faces['mono'])
        fontsize = x.default.get('editor_fontsize', common.faces['size'])
        linesize = x.default.get('editor_linesize', common.faces['lnsize'])

        if isinstance(fontname, str):
            fontname = unicode(fontname, 'utf-8')

        #test is the fontname is ok
        if hasattr(wx.FontEnumerator, 'IsValidFacename'
                   ) and not wx.FontEnumerator.IsValidFacename(fontname):
            font = wx.Font(fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
            fontname = font.FaceName

        common.faces.update({
            'mono': fontname,
            'size': fontsize,
            'lnsize': linesize,
        })

        #get default style
        self.get_default_style(x)

        self.__class__.STC_STYLE_DEFAULT = self.STC_STYLE_DEFAULT % common.faces
        self.__class__.STC_STYLE_LINENUMBER = self.STC_STYLE_LINENUMBER % common.faces

        self.font = wx.Font(fontsize,
                            wx.TELETYPE,
                            wx.NORMAL,
                            wx.NORMAL,
                            face=fontname)

        self.addSyntaxItem('default', tr('Style default'),
                           wx.stc.STC_STYLE_DEFAULT, self.STC_STYLE_DEFAULT)
        self.addSyntaxItem('-caretfore', tr('Caret fore colour'), 0,
                           self.STC_STYLE_CARET_FORE)
        self.addSyntaxItem('-caretback', tr('CaretLine back colour'), 0,
                           self.STC_STYLE_CARETLINE_BACK)
        self.addSyntaxItem('-selback', tr('Selection back colour'), 0,
                           self.STC_STYLE_SELECTION_BACK)
        self.addSyntaxItem('-foldercolor', tr('Folder margin colour'), 0,
                           self.STC_STYLE_FOLDER)
        self.addSyntaxItem('-markercolor', tr('Marker colour'), 0,
                           self.STC_STYLE_MARKER)
        self.addSyntaxItem('linenumber', tr('Line numbers'),
                           wx.stc.STC_STYLE_LINENUMBER,
                           self.STC_STYLE_LINENUMBER)
        self.addSyntaxItem('controlchar', tr('Control characters'),
                           wx.stc.STC_STYLE_CONTROLCHAR,
                           self.STC_STYLE_CONTROLCHAR)
        self.addSyntaxItem('bracelight', tr('Matched braces'),
                           wx.stc.STC_STYLE_BRACELIGHT,
                           self.STC_STYLE_BRACELIGHT)
        self.addSyntaxItem('bracebad', tr('Unmatched brace'),
                           wx.stc.STC_STYLE_BRACEBAD, self.STC_STYLE_BRACEBAD)
        #        self.initSyntaxItems()
        self.loadEasySyntaxItems()
        self.load()
Exemple #32
0
def read_todos(editor):
    lang = editor.languagename
    filename = editor.filename
    #set default pattern
    pl = todo_patten.get(lang, [])
    if not isinstance(pl, (list, tuple)):
        pl = [pl]
    #first check the config.ini
    ini = common.get_config_file_obj()
    if ini.todo_pattern.has_key(lang):
        pattern = ini.todo_pattern[lang]
        if isinstance(pattern, list):
            pl = []
            for i in pattern:
                try:
                    pl.append(re.compile(i))
                except:
                    error.traceback()
                    error.info('pattern=' + i)
        else:
            pl = []
            try:
                pl.append(re.compile(pattern))
            except:
                error.traceback()
                error.info('pattern=' + pattern)
    data = []
    if pl:
        buf = StringIO.StringIO(editor.GetText())
        for i, line in enumerate(buf):
            for r in pl:
                b = r.search(line)
                if b:
                    date = ''
                    result = filter(None, b.groups())
                    if not result:
                        message = ''
                        important = ''
                    else:
                        message = result[0].rstrip()
                        important = ''
                        for n in range(len(message)-1, -1, -1):
                            if message[n] == '!':
                                important += '!'
                            else:
                                break
                        if n > 0:
                            message = message[:n+1]
                        else:
                            message = ''
                        #find duedate
                        m = r_duedate.search(message)
                        if m:
                            message = message[:m.start()] + message[m.end():]
                            date = m.group(1)
                    data.append((important, i+1, date, message, filename))
    def _cmp(x, y):
        if x[1] > y[1]:
            return -1
        elif x[1] < y[1]:
            return 1
        else:
            return cmp(x[2], y[2])
        
    data.sort(_cmp)
    return data
Exemple #33
0
    def __init__(self, parent, mainframe):
        self.initmixin()

        self.parent = parent
        self.mainframe = mainframe
        self.pref = self.mainframe.pref
        self.app = self.mainframe.app
        self.mainframe.editctrl = self
        self.document = None
        self.lastfilename = None
        self.lastlanguagename = ''
        self.lastdocument = None

        if self.pref.notebook_direction == 0:
            style = 0
        else:
            style = FNB.FNB_BOTTOM
        FNB.FlatNotebook.__init__(
            self,
            parent,
            -1,
            style=style | FNB.FNB_SMART_TABS | FNB.FNB_VC8 | FNB.FNB_X_ON_TAB
            | FNB.FNB_NO_X_BUTTON | FNB.FNB_DROPDOWN_TABS_LIST
            | FNB.FNB_MOUSE_MIDDLE_CLOSES_TABS)
        self.id = self.GetId()

        #make popup menu
        #@add_menu menulist
        self.callplugin_once('add_menu', EditorFactory.popmenulist)
        #@add_menu_image_list imagelist
        self.callplugin_once('add_menu_image_list', EditorFactory.imagelist)
        #@add_panel_list panellist
        self.callplugin_once('add_panel_list', EditorFactory.panellist)

        self.popmenu = makemenu.makepopmenu(self, EditorFactory.popmenulist,
                                            EditorFactory.imagelist)
        #        self.SetRightClickMenu(self.popmenu)
        FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED(self, self.id, self.OnChanged)
        FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING(self, self.id, self.OnClose)
        wx.EVT_LEFT_DCLICK(self._pages, self.OnDClick)
        FNB.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU(self, self.id, self.OnPopup)

        self.imageindex = {}
        pageimages = wx.ImageList(16, 16)
        for i, v in enumerate(self.pageimagelist.items()):
            name, imagefilename = v
            image = common.getpngimage(imagefilename)
            pageimages.Add(image)
            self.imageindex[name] = i
        self.pageimages = pageimages

        #        self.AssignImageList(self.pageimages)
        self.SetImageList(self.pageimages)
        self.skip_closing = False
        self.skip_page_change = False
        self.full = False
        self.last_side_panel_status = None

        #set FlatNotebook style
        x = common.get_config_file_obj()
        tab_color = x.default.get('editor_tab_color', '#98FB98')
        self.SetActiveTabColour(tab_color)