当前位置: 首页>>代码示例>>Python>>正文


Python HyperParser.get_surrounding_brackets方法代码示例

本文整理汇总了Python中idlelib.HyperParser.HyperParser.get_surrounding_brackets方法的典型用法代码示例。如果您正苦于以下问题:Python HyperParser.get_surrounding_brackets方法的具体用法?Python HyperParser.get_surrounding_brackets怎么用?Python HyperParser.get_surrounding_brackets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idlelib.HyperParser.HyperParser的用法示例。


在下文中一共展示了HyperParser.get_surrounding_brackets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: calltip_event

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
    def calltip_event(self, event=None):
        window = self.docWindow.window
        if window is None:
            return

        if not window.update_calltip.get():
            # don't process calltip event
            return

        # get calltip
        # code borrows from CallTips.py::open_calltip
        evalfuncs = False
        hp = HyperParser(self.editwin, "insert")
        sur_paren = hp.get_surrounding_brackets('(')
        if not sur_paren:
            return
        hp.set_index(sur_paren[0])
        name = hp.get_expression()
        if not name or (not evalfuncs and name.find('(') != -1):
            return

        w = window
        w.entry.delete("0", "end")
        w.entry.insert("insert", name)
        w.get_doc()
开发者ID:CWade3051,项目名称:Py,代码行数:27,代码来源:DocViewer.py

示例2: open_calltip

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
 def open_calltip(self, evalfuncs):
     self._remove_calltip_window()
     hp = HyperParser(self.editwin, 'insert')
     sur_paren = hp.get_surrounding_brackets('(')
     if not sur_paren:
         return
     hp.set_index(sur_paren[0])
     expression = hp.get_expression()
     if not expression or not evalfuncs and expression.find('(') != -1:
         return
     arg_text = self.fetch_tip(expression)
     if not arg_text:
         return
     self.calltip = self._make_calltip_window()
     self.calltip.showtip(arg_text, sur_paren[0], sur_paren[1])
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:17,代码来源:calltips.py

示例3: paren_closed_event

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
 def paren_closed_event(self, event):
     # If it was a shortcut and not really a closing paren, quit.
     closer = self.text.get("insert-1c")
     if closer not in _openers:
         return
     hp = HyperParser(self.editwin, "insert-1c")
     if not hp.is_in_code():
         return
     indices = hp.get_surrounding_brackets(_openers[closer], True)
     if indices is None:
         self.warn_mismatched()
         return
     self.activate_restore()
     self.create_tag(indices)
     self.set_timeout()
开发者ID:dr4ke616,项目名称:custom_python,代码行数:17,代码来源:ParenMatch.py

示例4: open_calltip

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
    def open_calltip(self, evalfuncs):
        self._remove_calltip_window()

        hp = HyperParser(self.editwin, "insert")
        sur_paren = hp.get_surrounding_brackets("(")
        if not sur_paren:
            return
        hp.set_index(sur_paren[0])
        name = hp.get_expression()
        if not name or (not evalfuncs and name.find("(") != -1):
            return
        arg_text = self.fetch_tip(name)
        if not arg_text:
            return
        self.calltip = self._make_calltip_window()
        self.calltip.showtip(arg_text, sur_paren[0], sur_paren[1])
开发者ID:Rogerlin2013,项目名称:CrossApp,代码行数:18,代码来源:CallTips.py

示例5: paren_closed_event

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
 def paren_closed_event(self, event):
     closer = self.text.get('insert-1c')
     if closer not in _openers:
         return
     else:
         hp = HyperParser(self.editwin, 'insert-1c')
         if not hp.is_in_code():
             return
         indices = hp.get_surrounding_brackets(_openers[closer], True)
         if indices is None:
             self.warn_mismatched()
             return
         self.activate_restore()
         self.create_tag(indices)
         self.set_timeout()
         return
开发者ID:aevitas,项目名称:wotsdk,代码行数:18,代码来源:idlelibparenmatch.py

示例6: open_calltip

# 需要导入模块: from idlelib.HyperParser import HyperParser [as 别名]
# 或者: from idlelib.HyperParser.HyperParser import get_surrounding_brackets [as 别名]
    def open_calltip(self, evalfuncs):
        self._remove_calltip_window()

        # - 2016 9 28 --
        lt = self.text.get('insert linestart', 'insert')
        m = re.search(r'(\w+)<[^>]*', lt)

        if m:
            from idlelib.languages import _cppclassref
            if m.group(1) in _cppclassref.CPP_CLASSREF:
                arg_text = _cppclassref.CPP_CLASSREF[m.group(1)]
                if not arg_text:
                    return

                self.calltip = self._make_calltip_window()
##                print `self.text.index('insert-1c')`, `self.text.index('insert').split('.')[0]+'.end'`
                self.calltip.showtip(
                    arg_text,
                    self.text.index('insert-1c'),
                    self.text.index('insert').split('.')[0]+'.end',
                )
                return
        # ---

        hp = HyperParser(self.editwin, "insert")
        sur_paren = hp.get_surrounding_brackets('(')
        if not sur_paren:
            return

        hp.set_index(sur_paren[0])
        expression = hp.get_expression()
        if not expression or (not evalfuncs and expression.find('(') != -1):
            return
        arg_text = self.fetch_tip(expression)
        # - 2016 9 27 --
        if hasattr(self.editwin, 'ftype') and self.editwin.ftype.get() in ('C++/l',):
            e = ''
            if not arg_text:
                # treat as constructor
                lt = self.text.get('insert linestart', 'insert lineend')
##                print `lt`, 1
                if re.match(r'^[ \t]', lt, flags=re.MULTILINE):
                    e = lt.lstrip().split()[0]
                    if e == 'string':
                        e = 'basic_string'
                    arg_text = self.fetch_tip(e)

            if not arg_text:
                e = e.split('<')[0]
                if e == 'string':
                    e = 'basic_string'
                arg_text = self.fetch_tip(e)

            if not arg_text:
                # treat as member function
                if expression.count('.') != 1:
                    return # gives up

                name = expression.split('.')[0]
                func = expression.split('.')[1]
                # queue<int> q;  < hit this
                # q.push(1);     < skip this
                # q.front();     < when call here
                ln = int(sur_paren[0].split('.')[0])-1
                pat = re.compile(
                    (
                        r'\b{n}(?!\.)'
                    ).format(n=name)
                )
                lt = self.text.get('{}.0'.format(ln), '{}.end'.format(ln))
                m = pat.search(lt)
                while ln > 0 and not m:
                    lt = self.text.get('{}.0'.format(ln), '{}.end'.format(ln))
                    m = pat.search(lt)
                    ln -= 1

                if m:
                    pat = re.compile(
                        (
                            r'((?:{w}::)*{w}(?:<[^<>]*(?:<[^>]*>)*[^<>]*>)?)\s*'
                            r'{n}'
                        ).format(
                            n=name,
                            w=r'(?:[_A-Za-z]\w*)',
                        )
                    )
                    m2 = pat.search(lt)
                    if m2:
                        e = m2.group(1)
                        if e == 'string':
                            e = 'basic_string'
                        arg_text = self.fetch_tip('{}::{}'.format(e, func))

                    if not arg_text:
                        e = lt.lstrip().split()[0]
                        if e == 'string':
                            e = 'basic_string'
                        arg_text = self.fetch_tip(
                            '{}::{}'.format(e, func)
                        )
#.........这里部分代码省略.........
开发者ID:rsk0315,项目名称:papyrus,代码行数:103,代码来源:CallTips.py


注:本文中的idlelib.HyperParser.HyperParser.get_surrounding_brackets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。