• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python api.TextHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _on_mouse_released

 def _on_mouse_released(self, event):
     """ mouse pressed callback """
     if event.button() == 1 and self._deco:
         cursor = TextHelper(self.editor).word_under_mouse_cursor()
         if cursor and cursor.selectedText():
             self._timer.request_job(
                 self.word_clicked.emit, cursor)
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:7,代码来源:wordclick.py


示例2: _on_item_activated

 def _on_item_activated(item, *args):
     assert isinstance(item, QtWidgets.QTreeWidgetItem)
     data = item.data(0, QtCore.Qt.UserRole)
     try:
         l = data['line']
     except TypeError:
         return  # file item or root item
     start = data['start']
     lenght = data['end'] - start
     if data is not None:
         # open editor and go to line/column
         e = editor.open_file(data['path'], data['line'], data['start'])
         if e is None:
             return
         # select text
         helper = TextHelper(e)
         try:
             cursor = helper.select_lines(start=l, end=l)
         except AttributeError:
             _logger().debug('failed to select occurent line in editor, not'
                             ' a subclass of QPlainTextEdit')
         else:
             assert isinstance(cursor, QtGui.QTextCursor)
             cursor.movePosition(cursor.StartOfBlock)
             cursor.movePosition(cursor.Right, cursor.MoveAnchor, start)
             cursor.movePosition(cursor.Right, cursor.KeepAnchor, lenght)
             e.setTextCursor(cursor)
开发者ID:SirmoGames,项目名称:hackedit,代码行数:27,代码来源:find_replace.py


示例3: _check_word_cursor

    def _check_word_cursor(self, tc=None):
        """
        Request a go to assignment.

        :param tc: Text cursor which contains the text that we must look for
                   its assignment. Can be None to go to the text that is under
                   the text cursor.
        :type tc: QtGui.QTextCursor
        """
        if not tc:
            tc = TextHelper(self.editor).word_under_cursor()

        request_data = {
            'code': self.editor.toPlainText(),
            'line': tc.blockNumber(),
            'column': tc.columnNumber(),
            'path': self.editor.file.path,
            'encoding': self.editor.file.encoding
        }
        try:
            self.editor.backend.send_request(
                workers.goto_assignments, request_data,
                on_receive=self._on_results_available)
        except NotRunning:
            pass
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:25,代码来源:goto_assignements.py


示例4: _select_word_under_mouse_cursor

 def _select_word_under_mouse_cursor(self):
     """ Selects the word under the mouse cursor. """
     cursor = TextHelper(self.editor).word_under_mouse_cursor()
     if (self._previous_cursor_start != cursor.selectionStart() and
             self._previous_cursor_end != cursor.selectionEnd()):
         self._remove_decoration()
         self._add_decoration(cursor)
     self._previous_cursor_start = cursor.selectionStart()
     self._previous_cursor_end = cursor.selectionEnd()
开发者ID:brunoviu,项目名称:OpenCobolIDE,代码行数:9,代码来源:goto.py


示例5: _on_key_pressed

 def _on_key_pressed(self, event):
     helper = TextHelper(self.editor)
     indent = helper.line_indent() * ' '
     if self.editor.textCursor().positionInBlock() == len(indent):
         self.QUOTES_FORMATS['"'] = '%s:'
     else:
         self.QUOTES_FORMATS['"'] = '%s'
     self.QUOTES_FORMATS['{'] = '\n' + indent + '%s'
     self.QUOTES_FORMATS['['] = '\n' + indent + '%s'
     super(AutoCompleteMode, self)._on_key_pressed(event)
开发者ID:SirmoGames,项目名称:hackedit,代码行数:10,代码来源:autocomplete.py


示例6: _on_mouse_moved

 def _on_mouse_moved(self, event):
     """ mouse moved callback """
     if event.modifiers() & QtCore.Qt.ControlModifier:
         cursor = TextHelper(self.editor).word_under_mouse_cursor()
         if not self._cursor or cursor.position() != self._cursor.position():
             self._check_word_cursor(cursor)
         self._cursor = cursor
     else:
         self._cursor = None
         self._clear_selection()
开发者ID:GrandHsu,项目名称:pyqode.core,代码行数:10,代码来源:wordclick.py


示例7: _on_action_quick_doc_triggered

 def _on_action_quick_doc_triggered(self):
     tc = TextHelper(self.editor).word_under_cursor(select_whole_word=True)
     request_data = {
         'code': self.editor.toPlainText(),
         'line': tc.blockNumber(),
         'column': tc.columnNumber(),
         'path': self.editor.file.path,
         'encoding': self.editor.file.encoding
     }
     self.editor.backend.send_request(
         quick_doc, request_data, on_receive=self._on_results_available)
开发者ID:SirmoGames,项目名称:hackedit,代码行数:11,代码来源:quick_doc.py


示例8: test_dynamic_folding_insert_section

def test_dynamic_folding_insert_section():
    # test insert section under empty data division
    # data division (which is not a fold trigger initially) block will become a fold trigger
    editor = CobolCodeEdit()
    editor.setPlainText(section_code, '', '')
    th = TextHelper(editor)
    block = editor.document().findBlockByNumber(2)
    assert TextBlockHelper.is_fold_trigger(block) is False
    cursor = th.goto_line(2, column=len('       DATA DIVISION.'))
    cursor.insertText('\n       WORKING-STORAGE SECTION.')
    assert TextBlockHelper.is_fold_trigger(block) is True
开发者ID:SirmoGames,项目名称:pyqode.cobol,代码行数:11,代码来源:test_folding.py


示例9: _in_method_call

 def _in_method_call(self):
     helper = TextHelper(self.editor)
     line_nbr = helper.current_line_nbr() - 1
     expected_indent = helper.line_indent() - 4
     while line_nbr >= 0:
         text = helper.line_text(line_nbr)
         indent = len(text) - len(text.lstrip())
         if indent == expected_indent and 'class' in text:
             return True
         line_nbr -= 1
     return False
开发者ID:PierreBizouard,项目名称:pyqode.python,代码行数:11,代码来源:autocomplete.py


示例10: test_add_decoration

def test_add_decoration(editor):
    helper = TextHelper(editor)
    helper.goto_line(2, 2)
    cursor = helper.word_under_cursor(select_whole_word=True)
    deco = TextDecoration(cursor)
    deco.set_as_bold()
    deco.set_as_underlined(QtGui.QColor("#FF0000"))
    editor.decorations.append(deco)
    assert not editor.decorations.append(deco)
    assert deco.contains_cursor(cursor)
    # keep editor clean for next tests
    editor.decorations.clear()
开发者ID:SirmoGames,项目名称:pyqode.core,代码行数:12,代码来源:test_decoration.py


示例11: _on_post_key_pressed

 def _on_post_key_pressed(self, event):
     if not event.isAccepted() and not self._ignore_post:
         txt = event.text()
         next_char = TextHelper(self.editor).get_right_character()
         if txt in self.MAPPING:
             to_insert = self.MAPPING[txt]
             if (not next_char or next_char in self.MAPPING.keys() or
                     next_char in self.MAPPING.values() or
                     next_char.isspace()):
                 TextHelper(self.editor).insert_text(
                     self.QUOTES_FORMATS[txt] % to_insert)
     self._ignore_post = False
开发者ID:sopak,项目名称:cadquery-freecad-module,代码行数:12,代码来源:autocomplete.py


示例12: _on_item_clicked

 def _on_item_clicked(self, item):
     """
     Go to the item position in the editor.
     """
     if item:
         name = item.data(0, QtCore.Qt.UserRole)
         if name:
             go = name.block.blockNumber()
             helper = TextHelper(self._editor)
             if helper.current_line_nbr() != go:
                 helper.goto_line(go, column=name.column)
             self._editor.setFocus()
开发者ID:sopak,项目名称:cadquery-freecad-module,代码行数:12,代码来源:outline.py


示例13: test_clear_decoration

def test_clear_decoration(editor):
    # should work even when there are no more decorations
    helper = TextHelper(editor)
    editor.decorations.clear()
    cursor = helper.word_under_cursor(select_whole_word=True)
    deco = TextDecoration(cursor)
    deco.set_as_bold()
    deco.set_as_underlined(QtGui.QColor("#FF0000"))
    editor.decorations.append(deco)
    assert not editor.decorations.append(deco)
    editor.decorations.clear()
    assert editor.decorations.append(deco)
    assert editor.decorations.remove(deco)
开发者ID:SirmoGames,项目名称:pyqode.core,代码行数:13,代码来源:test_decoration.py


示例14: test_remove_decoration

def test_remove_decoration(editor):
    helper = TextHelper(editor)
    TextHelper(editor).goto_line(1, 2)
    cursor = helper.word_under_cursor(select_whole_word=True)
    deco = TextDecoration(cursor)
    deco.set_as_bold()
    deco.set_as_underlined(QtGui.QColor("#FF0000"))
    editor.decorations.append(deco)
    assert editor.decorations.remove(deco)
    # already removed, return False
    assert not editor.decorations.remove(deco)
    assert editor.decorations.append(deco)
    # keep editor clean for next tests
    editor.decorations.clear()
开发者ID:SirmoGames,项目名称:pyqode.core,代码行数:14,代码来源:test_decoration.py


示例15: _on_bt_toggled

 def _on_bt_toggled(self, *ar):
     if not self._lock:
         self._lock = True
         for w in self._widgets:
             if w == self.sender():
                 break
         if self._toggled:
             self._toggled.setChecked(False)
         self._toggled = w
         th = TextHelper(self.editor)
         line = w.scope.blockNumber()
         th.goto_line(line, column=th.line_indent(line))
         self._lock = False
         self.editor.setFocus()
开发者ID:SirmoGames,项目名称:hackedit,代码行数:14,代码来源:navigation.py


示例16: _compute_offsets

 def _compute_offsets(self):
     original_tc = self.editor.textCursor()
     tc = self.editor.textCursor()
     start = tc.selectionStart()
     end = tc.selectionEnd()
     tc.setPosition(start)
     start_line = tc.blockNumber()
     tc.setPosition(end)
     end_line = tc.blockNumber()
     th = TextHelper(self.editor)
     th.select_lines(start=start_line, end=end_line, apply_selection=True)
     source = th.selected_text()
     results = get_field_infos(source, self.editor.free_format)
     self.editor.setTextCursor(original_tc)
     self.pic_infos_available.emit(results)
开发者ID:SirmoGames,项目名称:hackedit,代码行数:15,代码来源:pic_offset.py


示例17: _computeOffsets

 def _computeOffsets(self):
     original_tc = self.editor.textCursor()
     tc = self.editor.textCursor()
     assert isinstance(tc, QTextCursor)
     start = tc.selectionStart()
     end = tc.selectionEnd()
     tc.setPosition(start)
     start_line = tc.blockNumber() + 1
     tc.setPosition(end)
     end_line = tc.blockNumber() + 1
     th = TextHelper(self.editor)
     th.select_lines(start=start_line, end=end_line, apply_selection=True)
     source = th.selected_text()
     self.picInfosAvailable.emit(get_field_infos(source))
     self.editor.setTextCursor(original_tc)
开发者ID:Astalaseven,项目名称:OpenCobolIDE,代码行数:15,代码来源:modes.py


示例18: test_dynamic_folding_insert_end_if

def test_dynamic_folding_insert_end_if():
    # test insert section under empty data division
    # data division (which is not a fold trigger initially) block will become a fold trigger
    editor = CobolCodeEdit()
    editor.setPlainText(end_if_code, '', '')
    th = TextHelper(editor)
    block = editor.document().findBlockByNumber(4)
    first, last = FoldScope(block).get_range()
    assert first == 4
    assert last == 5
    cursor = th.goto_line(5, column=len('          DISPLAY "FOO"'))
    cursor.insertText('\n       END-IF')
    first, last = FoldScope(block).get_range()
    assert first == 4
    assert last == 6
    editor.close()
开发者ID:SirmoGames,项目名称:pyqode.cobol,代码行数:16,代码来源:test_folding.py


示例19: _on_post_key_pressed

 def _on_post_key_pressed(self, event):
     if not event.isAccepted() and not self._ignore_post:
         txt = event.text()
         trav = self.editor.textCursor()
         assert isinstance(trav, QtGui.QTextCursor)
         trav.movePosition(trav.Left, trav.MoveAnchor, 2)
         literal = TextHelper(self.editor).is_comment_or_string(trav)
         if not literal:
             next_char = TextHelper(self.editor).get_right_character()
             if txt in self.MAPPING:
                 to_insert = self.MAPPING[txt]
                 if (not next_char or next_char in self.MAPPING.keys() or
                         next_char in self.MAPPING.values() or
                         next_char.isspace()):
                     TextHelper(self.editor).insert_text(
                         self.QUOTES_FORMATS[txt] % to_insert)
     self._ignore_post = False
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:17,代码来源:autocomplete.py


示例20: requestGoTo

    def requestGoTo(self, tc=None):
        """
        Request a go to assignment.

        :param tc: Text cursor which contains the text that we must look for
                   its assignment. Can be None to go to the text that is under
                   the text cursor.
        :type tc: QtGui.QTextCursor
        """
        if not tc:
            tc = TextHelper(self.editor).word_under_cursor(
                select_whole_word=True)
        symbol = tc.selectedText()
        analyser = getattr(self.editor, "analyserMode")
        if analyser:
            node = analyser.root_node.find(symbol)
            if node:
                self._definition = node
                QTimer.singleShot(100, self._goToDefinition)
开发者ID:Astalaseven,项目名称:OpenCobolIDE,代码行数:19,代码来源:modes.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mode.Mode类代码示例发布时间:2022-05-27
下一篇:
Python api.TextBlockHelper类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap