當前位置: 首頁>>代碼示例>>Python>>正文


Python api.TextHelper類代碼示例

本文整理匯總了Python中pyqode.core.api.TextHelper的典型用法代碼示例。如果您正苦於以下問題:Python TextHelper類的具體用法?Python TextHelper怎麽用?Python TextHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TextHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的pyqode.core.api.TextHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。