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


Python TextHelper.current_column_nbr方法代码示例

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


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

示例1: request_completion

# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_column_nbr [as 别名]
 def request_completion(self):
     """
     Requests a code completion at the current cursor position.
     """
     _logger().debug('request code completion')
     self._col = self.editor.textCursor().positionInBlock() - len(
         self.completion_prefix)
     helper = TextHelper(self.editor)
     if not self._request_cnt:
         # only check first byte
         tc = self.editor.textCursor()
         while tc.atBlockEnd() and not tc.atBlockStart() and \
                 tc.position():
             tc.movePosition(tc.Left)
         disabled_zone = TextHelper(self.editor).is_comment_or_string(
             tc)
         if disabled_zone:
             _logger().debug(
                 "cc: cancel request, cursor is in a disabled zone")
             return False
         self._request_cnt += 1
         self._collect_completions(self.editor.toPlainText(),
                                   helper.current_line_nbr(),
                                   helper.current_column_nbr() -
                                   len(self.completion_prefix),
                                   self.editor.file.path,
                                   self.editor.file.encoding,
                                   self.completion_prefix)
         return True
     return False
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:32,代码来源:code_completion.py

示例2: CodeCompletionMode

# 需要导入模块: from pyqode.core.api.utils import TextHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextHelper import current_column_nbr [as 别名]

#.........这里部分代码省略.........
                        results, self.completion_prefix)
        context = results[0]
        results = results[1:]
        line, column, request_id = context
        debug('request context: %r', context)
        debug('latest context: %r', (self._last_cursor_line,
                                               self._last_cursor_column,
                                               self._request_id))
        self._last_request_id = request_id
        if (line == self._last_cursor_line and
                column == self._last_cursor_column):
            if self.editor:
                all_results = []
                for res in results:
                    all_results += res
                self._show_completions(all_results)
        else:
            debug('outdated request, dropping')

    #
    # Helper methods
    #
    def _is_popup_visible(self):
        return self._completer.popup().isVisible()

    def _reset_sync_data(self):
        debug('reset sync data and hide popup')
        self._last_cursor_line = -1
        self._last_cursor_column = -1
        self._hide_popup()

    def request_completion(self):
        line = self._helper.current_line_nbr()
        column = self._helper.current_column_nbr() - \
            len(self.completion_prefix)
        same_context = (line == self._last_cursor_line and
                        column == self._last_cursor_column)
        if same_context:
            if self._request_id - 1 == self._last_request_id:
                # context has not changed and the correct results can be
                # directly shown
                debug('request completion ignored, context has not '
                                'changed')
                self._show_popup()
            else:
                # same context but result not yet available
                pass
            return True
        else:
            debug('requesting completion')
            data = {
                'code': self.editor.toPlainText(),
                'line': line,
                'column': column,
                'path': self.editor.file.path,
                'encoding': self.editor.file.encoding,
                'prefix': self.completion_prefix,
                'request_id': self._request_id
            }
            try:
                self.editor.backend.send_request(
                    backend.CodeCompletionWorker, args=data,
                    on_receive=self._on_results_available)
            except NotRunning:
                _logger().exception('failed to send the completion request')
                return False
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:70,代码来源:code_completion.py


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