Пример #1
0
    def getCurrentProjectName(self):
        item = self.tree.GetSelection()
        if not self.is_ok(item):
            projectname = ''
        else:
            projectname = common.getProjectName(self.get_node_filename(item))

        return projectname
Пример #2
0
    def getCurrentProjectName(self):
        item = self.tree.GetSelection()
        if not self.is_ok(item):
            projectname = ''
        else:
            projectname = common.getProjectName(self.get_node_filename(item))

        return projectname
Пример #3
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'xml' and 'docbook' in common.getProjectName(editor.filename):
        menus.extend([(None, #parent menu id
            [
                (50, 'IDPM_DOCBOOK_PROJECT', 'DocBook', wx.ITEM_NORMAL, '', ''),
                (51, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
            ('IDPM_DOCBOOK_PROJECT',
            [
                (100, 'IDPM_DOCBOOK_PROJECT_ENCLOSE', tr('Add/Enclose With DocBook Element...'), wx.ITEM_NORMAL, 'OnDocbookProjectFunc', tr('Add or enclose selected text with docbook element.')),
            ]),
        ])
Пример #4
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'python' and 'django' in common.getProjectName(editor.filename):
        menus.extend([(None, #parent menu id
            [
                (30, 'IDPM_DJANGO_PROJECT', tr('&Django'), wx.ITEM_NORMAL, '', ''),
                (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
            ('IDPM_DJANGO_PROJECT',
            [
                (100, 'IDPM_DJANGO_PROJECT_NEW_MODEL', tr('&New Model'), wx.ITEM_NORMAL, 'OnDjangoProjectFunc', tr('Create a new model.')),
                (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
        ])
Пример #5
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'js' and 'jquery' in common.getProjectName(editor.filename):
        menus.extend([(None, #parent menu id
            [
                (30, 'IDPM_JQUERY_PROJECT', tr('jQuery'), wx.ITEM_NORMAL, '', ''),
#                (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
            ('IDPM_JQUERY_PROJECT',
            [
                (100, 'IDPM_JQUERY_PROJECT_CREATE_COMMENT', tr('Create Comment for Function'), wx.ITEM_NORMAL, 'OnJQueryProjectFunc', tr('Creates comment for a function.')),
#                (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
        ])
Пример #6
0
    def OnPopUp(self, event):
        other_menus = []
        if self.popmenu:
            self.popmenu.Destroy()
            self.popmenu = None
        self.callplugin('other_popup_menu', self, common.getProjectName(self.filename), other_menus)
        import copy
        if other_menus:
            pop_menus = copy.deepcopy(TextEditor.popmenulist + other_menus)
        else:
            pop_menus = copy.deepcopy(TextEditor.popmenulist)
        self.popmenu = pop_menus = makemenu.makepopmenu(self, pop_menus, TextEditor.imagelist)

        self.PopupMenu(self.popmenu, event.GetPosition())
Пример #7
0
    def OnPopUp(self, event):
        other_menus = []
        if self.popmenu:
            self.popmenu.Destroy()
            self.popmenu = None
        self.callplugin('other_popup_menu', self,
                        common.getProjectName(self.filename), other_menus)
        import copy
        if other_menus:
            pop_menus = copy.deepcopy(TextEditor.popmenulist + other_menus)
        else:
            pop_menus = copy.deepcopy(TextEditor.popmenulist)
        self.popmenu = pop_menus = makemenu.makepopmenu(
            self, pop_menus, TextEditor.imagelist)

        self.PopupMenu(self.popmenu, event.GetPosition())
Пример #8
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'xml' and 'docbook' in common.getProjectName(
            editor.filename):
        menus.extend([
            (
                None,  #parent menu id
                [
                    (50, 'IDPM_DOCBOOK_PROJECT', 'DocBook', wx.ITEM_NORMAL, '',
                     ''),
                    (51, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
            ('IDPM_DOCBOOK_PROJECT', [
                (100, 'IDPM_DOCBOOK_PROJECT_ENCLOSE',
                 tr('Add/Enclose With DocBook Element...'), wx.ITEM_NORMAL,
                 'OnDocbookProjectFunc',
                 tr('Add or enclose selected text with docbook element.')),
            ]),
        ])
Пример #9
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'python' and 'django' in common.getProjectName(
            editor.filename):
        menus.extend([
            (
                None,  #parent menu id
                [
                    (30, 'IDPM_DJANGO_PROJECT', tr('&Django'), wx.ITEM_NORMAL,
                     '', ''),
                    (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
            ('IDPM_DJANGO_PROJECT', [
                (100, 'IDPM_DJANGO_PROJECT_NEW_MODEL', tr('&New Model'),
                 wx.ITEM_NORMAL, 'OnDjangoProjectFunc',
                 tr('Create a new model.')),
                (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
        ])
Пример #10
0
def other_popup_menu(editor, projectname, menus):
    if editor.languagename == 'js' and 'jquery' in common.getProjectName(
            editor.filename):
        menus.extend([
            (
                None,  #parent menu id
                [
                    (30, 'IDPM_JQUERY_PROJECT', tr('jQuery'), wx.ITEM_NORMAL,
                     '', ''),
                    #                (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
            (
                'IDPM_JQUERY_PROJECT',
                [
                    (100, 'IDPM_JQUERY_PROJECT_CREATE_COMMENT',
                     tr('Create Comment for Function'), wx.ITEM_NORMAL,
                     'OnJQueryProjectFunc',
                     tr('Creates comment for a function.')),
                    #                (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
        ])
Пример #11
0
def other_popup_menu(editor, projectname, menus):
    if 'web2py' in common.getProjectName(editor.filename):
        path = common.getProjectHome(editor.filename)
        if not os.path.exists(os.path.join(path, "web2py.py")):
            common.showerror(
                win,
                tr("setting web2py project is not correctly, you must setting project on web2py folder"
                   ))
            return
        if editor.filename.count(root) > 1:
            common.showerror(
                win,
                tr(" '%s' occur twice, we can't handle this situation" % root))
            return
        if dynamic_menu(editor):
            menus.extend([
                (
                    None,  #parent menu id
                    [
                        (30, 'IDPM_WEB2PY_PROJECT', tr('&Web2py'),
                         wx.ITEM_NORMAL, '', ''),
                        (35, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW',
                         dynamic_menu(editor), wx.ITEM_NORMAL,
                         'OnWeb2pyProjectFunc',
                         tr('Create a view or open view.')),
                        (38, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_WEB',
                         dynamic_menu(editor, 'web'), wx.ITEM_NORMAL,
                         'OnWeb2pyProjectFunc', tr('visit web site')),
                        (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
                    ]),
                (
                    'IDPM_WEB2PY_PROJECT',
                    [
                        ##                    (100, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW', dynamic_menu(editor), wx.ITEM_NORMAL, 'OnWeb2pyProjectFunc', tr('Create a view or open view.')),
                        (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
                    ]),
            ])
Пример #12
0
def other_popup_menu(editor, projectname, menus):
    if 'web2py' in common.getProjectName(editor.filename):
        path = common.getProjectHome(editor.filename)
        if not os.path.exists(os.path.join(path, "web2py.py")):
            common.showerror(win, tr("setting web2py project is not correctly, you must setting project on web2py folder"))
            return
        if  editor.filename.count(root)>1:
            common.showerror(win, tr(" '%s' occur twice, we can't handle this situation" % root))
            return 
        if dynamic_menu(editor):
            menus.extend([(None, #parent menu id
                [
                    (30, 'IDPM_WEB2PY_PROJECT', tr('&Web2py'), wx.ITEM_NORMAL, '', ''),
                    (35, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW', dynamic_menu(editor), wx.ITEM_NORMAL, 'OnWeb2pyProjectFunc', tr('Create a view or open view.')),
                    (38, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_WEB', dynamic_menu(editor, 'web'), wx.ITEM_NORMAL, 'OnWeb2pyProjectFunc', tr('visit web site')),
                    
                    (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
                ('IDPM_WEB2PY_PROJECT',
                [
##                    (100, 'IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW', dynamic_menu(editor), wx.ITEM_NORMAL, 'OnWeb2pyProjectFunc', tr('Create a view or open view.')),
                    (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
                ]),
            ])
Пример #13
0
    def _run(self):
        if not self.syncvar.empty:
            return True
        win = self.editor
        objs = self.get_all_acps()
        if not objs:
            return False
        else:
            #matching
            for obj in objs:
                if not self.syncvar.empty:
                    return True
                if obj.projectname and obj.projectname not in common.getProjectName(win.filename):
                    continue
                #autostring
                if obj.autostring.has_key(self.key):
                    s = obj.autostring[self.key]
                    for k, text in s:
                        if not self.syncvar.empty:
                            return True
                        word, start, end = self.getWord(k)
                        if k == word:
                            if self.parse_result(obj, text, start, end, self.key, matchtext=None):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                def f():
                                    win.BeginUndoAction()
                                    win.SetTargetStart(start)
                                    win.SetTargetEnd(end)
                                    win.ReplaceTarget('')
                                    win.GotoPos(start)
                                    self.settext(text)
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                            else:
                                def f():
                                    win.BeginUndoAction()
#                                    win.inputassistant_obj = obj
                                    win.word_len = start, end + 1
                                    win.replace_strings = None
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                #autostring_append
                if obj.autostring_append.has_key(self.key):
                    s = obj.autostring_append[self.key]
                    for k, text in s:
                        word, start, end = self.getWord(k)
                        if k == word:
                            if self.parse_result(obj, text, start, end, self.key):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                def f():
                                    win.BeginUndoAction()
                                    self.settext(text)
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                            else:
                                def f():
                                    win.BeginUndoAction()
#                                    win.inputassistant_obj = obj
                                    win.replace_strings = None
                                    win.word_len = win.GetCurrentPos(), -1
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                #autore
                if obj.autore.has_key(self.key):
                    line = win.GetCurrentLine()
                    txt = win.GetTextRange(win.PositionFromLine(line), win.GetCurrentPos())
                    txt = txt.encode('utf-8')
                    s = obj.autore[self.key]
                    length = len(txt)
                    flag = False
                    for k, text in s:
                        pos = 0
                        b = k.search(txt, pos)
                        while b:
                            if b.end() == length: #find
                                flag = True
                                break
                            else:
                                pos += 1
                                b = k.search(txt, pos)
                        if flag:
                            r = []
                            r.append(unicode(b.group(), 'utf-8'))
                            r.extend([unicode(x, 'utf-8') for x in b.groups()])
                            if self.parse_result(obj, text, 0, 0, self.key, matchtext=r, line=line, matchobj=b):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                m = []
                                for p in text:
                                    for i in range(len(r)):
                                        p = p.replace('\\' + str(i), r[i])
                                    m.append(p)
                                def f():
                                    win.BeginUndoAction()
                                    pos = win.PositionFromLine(line)
                                    win.SetTargetStart(pos + b.start())
                                    win.SetTargetEnd(pos + b.end())
                                    win.ReplaceTarget('')
                                    win.GotoPos(pos + b.start())
                                    self.settext(m)
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                            else:
                                def f():
                                    win.BeginUndoAction()
#                                    win.inputassistant_obj = obj
                                    pos = win.PositionFromLine(line)
                                    win.replace_strings = r
                                    win.word_len = pos + b.start(), pos + b.end()
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                #autore_append
                if obj.autore_append.has_key(self.key):
                    line = win.GetCurrentLine()
                    txt = win.GetTextRange(win.PositionFromLine(line), win.GetCurrentPos())
                    txt = txt.encode('utf-8')
                    s = obj.autore_append[self.key]
                    length = len(txt)
                    flag = False
                    for k, text in s:
                        pos = 0
                        b = k.search(txt, pos)
                        while b:
                            if b.end() == length: #find
                                flag = True
                                break
                            else:
                                pos += 1
                                b = k.search(txt, pos)
                        if flag:
                            r = []
                            r.append(unicode(b.group(), 'utf-8'))
                            r.extend(unicode(x, 'utf-8') for x in b.groups())
                            if self.parse_result(obj, text, 0, 0, self.key, matchtext=r, line=line, matchobj=b):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                m = []
                                for p in text:
                                    for i in range(len(r)):
                                        p = p.replace('\\' + str(i), r[i])
                                    m.append(p)
                                def f():
                                    win.BeginUndoAction()
                                    self.settext(m)
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True
                            else:
                                def f():
                                    win.BeginUndoAction()
#                                    win.inputassistant_obj = obj
                                    pos = win.PositionFromLine(line)
                                    win.replace_strings = r
                                    win.word_len = win.GetCurrentPos(), -1
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()
                                self.postcall(f)
                                return True

            else:
                if self.on_char: #in on_char event
                    #deal with auto identifiers
                    result = False
                    try:
                        if self.key[0] == 0 and self.key[1] == ord('('):
                            self.process_calltip_begin()
                            result = True
                        elif self.key[0] == 0 and self.key[1] == ord(')'):
                            self.process_calltip_end()
                            result = True
                        elif self.key[0] == 0 and self.key[1] == ord('.'):
                            self.process_autocomplete()
                            result = True
                        if not result:
                            return self.process_default()
                        else:
                            return True
                    except StopException:
                        pass
                    except:
                        error.traceback()
            return False
Пример #14
0
    def _run(self):
        if not self.syncvar.empty:
            return True
        win = self.editor
        objs = self.get_all_acps()
        if not objs:
            return False
        else:
            #matching
            for obj in objs:
                if not self.syncvar.empty:
                    return True
                if obj.projectname and obj.projectname not in common.getProjectName(
                        win.filename):
                    continue
                #autostring
                if obj.autostring.has_key(self.key):
                    s = obj.autostring[self.key]
                    for k, text in s:
                        if not self.syncvar.empty:
                            return True
                        word, start, end = self.getWord(k)
                        if k == word:
                            if self.parse_result(obj,
                                                 text,
                                                 start,
                                                 end,
                                                 self.key,
                                                 matchtext=None):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):

                                def f():
                                    win.BeginUndoAction()
                                    win.SetTargetStart(start)
                                    win.SetTargetEnd(end)
                                    win.ReplaceTarget('')
                                    win.GotoPos(start)
                                    self.settext(text)
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                            else:

                                def f():
                                    win.BeginUndoAction()
                                    #                                    win.inputassistant_obj = obj
                                    win.word_len = start, end + 1
                                    win.replace_strings = None
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                #autostring_append
                if obj.autostring_append.has_key(self.key):
                    s = obj.autostring_append[self.key]
                    for k, text in s:
                        word, start, end = self.getWord(k)
                        if k == word:
                            if self.parse_result(obj, text, start, end,
                                                 self.key):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):

                                def f():
                                    win.BeginUndoAction()
                                    self.settext(text)
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                            else:

                                def f():
                                    win.BeginUndoAction()
                                    #                                    win.inputassistant_obj = obj
                                    win.replace_strings = None
                                    win.word_len = win.GetCurrentPos(), -1
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                #autore
                if obj.autore.has_key(self.key):
                    line = win.GetCurrentLine()
                    txt = win.GetTextRange(win.PositionFromLine(line),
                                           win.GetCurrentPos())
                    txt = txt.encode('utf-8')
                    s = obj.autore[self.key]
                    length = len(txt)
                    flag = False
                    for k, text in s:
                        pos = 0
                        b = k.search(txt, pos)
                        while b:
                            if b.end() == length:  #find
                                flag = True
                                break
                            else:
                                pos += 1
                                b = k.search(txt, pos)
                        if flag:
                            r = []
                            r.append(unicode(b.group(), 'utf-8'))
                            r.extend([unicode(x, 'utf-8') for x in b.groups()])
                            if self.parse_result(obj,
                                                 text,
                                                 0,
                                                 0,
                                                 self.key,
                                                 matchtext=r,
                                                 line=line,
                                                 matchobj=b):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                m = []
                                for p in text:
                                    for i in range(len(r)):
                                        p = p.replace('\\' + str(i), r[i])
                                    m.append(p)

                                def f():
                                    win.BeginUndoAction()
                                    pos = win.PositionFromLine(line)
                                    win.SetTargetStart(pos + b.start())
                                    win.SetTargetEnd(pos + b.end())
                                    win.ReplaceTarget('')
                                    win.GotoPos(pos + b.start())
                                    self.settext(m)
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                            else:

                                def f():
                                    win.BeginUndoAction()
                                    #                                    win.inputassistant_obj = obj
                                    pos = win.PositionFromLine(line)
                                    win.replace_strings = r
                                    win.word_len = pos + b.start(
                                    ), pos + b.end()
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                #autore_append
                if obj.autore_append.has_key(self.key):
                    line = win.GetCurrentLine()
                    txt = win.GetTextRange(win.PositionFromLine(line),
                                           win.GetCurrentPos())
                    txt = txt.encode('utf-8')
                    s = obj.autore_append[self.key]
                    length = len(txt)
                    flag = False
                    for k, text in s:
                        pos = 0
                        b = k.search(txt, pos)
                        while b:
                            if b.end() == length:  #find
                                flag = True
                                break
                            else:
                                pos += 1
                                b = k.search(txt, pos)
                        if flag:
                            r = []
                            r.append(unicode(b.group(), 'utf-8'))
                            r.extend(unicode(x, 'utf-8') for x in b.groups())
                            if self.parse_result(obj,
                                                 text,
                                                 0,
                                                 0,
                                                 self.key,
                                                 matchtext=r,
                                                 line=line,
                                                 matchobj=b):
                                return True
                            if win.AutoCompActive():
                                self.postcall(win.AutoCompCancel)
                            if not isinstance(text, list):
                                m = []
                                for p in text:
                                    for i in range(len(r)):
                                        p = p.replace('\\' + str(i), r[i])
                                    m.append(p)

                                def f():
                                    win.BeginUndoAction()
                                    self.settext(m)
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True
                            else:

                                def f():
                                    win.BeginUndoAction()
                                    #                                    win.inputassistant_obj = obj
                                    pos = win.PositionFromLine(line)
                                    win.replace_strings = r
                                    win.word_len = win.GetCurrentPos(), -1
                                    win.UserListShow(list_type, " ".join(text))
                                    win.EndUndoAction()

                                self.postcall(f)
                                return True

            else:
                if self.on_char:  #in on_char event
                    #deal with auto identifiers
                    result = False
                    try:
                        if self.key[0] == 0 and self.key[1] == ord('('):
                            self.process_calltip_begin()
                            result = True
                        elif self.key[0] == 0 and self.key[1] == ord(')'):
                            self.process_calltip_end()
                            result = True
                        elif self.key[0] == 0 and self.key[1] == ord('.'):
                            self.process_autocomplete()
                            result = True
                        if not result:
                            return self.process_default()
                        else:
                            return True
                    except StopException:
                        pass
                    except:
                        error.traceback()
            return False