In normal mode - QTextEdit.ExtraSelection which highlightes the cursor
503501
def extraSelections(self):
        
        if not isinstance(self._mode, Normal):
            return []

        selection = QTextEdit.ExtraSelection()
        selection.format.setBackground(QColor('#ffcc22'))
        selection.format.setForeground(QColor('#000000'))
        selection.cursor = self._qpart.textCursor()
        selection.cursor.movePosition(QTextCursor.NextCharacter, QTextCursor.KeepAnchor)

        return [selection]
520165
def perform_extended_selection(self, event=None):
        
        TextHelper(self.editor).select_extended_word(
            continuation_chars=self.continuation_characters)
        if event:
            event.accept()
712796
def mouseDoubleClickEvent(self, event):
        """"""
        if self.rename_tabs is True and \
                event.buttons() == Qt.MouseButtons(Qt.LeftButton):
            # Tab index
            index = self.tabAt(event.pos())
            if index >= 0:
                # Tab is valid, call tab name editor
                self.tab_name_editor.edit_tab(index)
        else:
            # Event is not interesting, raise to parent
            QTabBar.mouseDoubleClickEvent(self, event)
693935
private void highlightText(int start) {
        editor.setCaretPosition(editor.getText().length());
        editor.moveCaretPosition(start);
    }
218769
def highlight_occurences(editor):
    

    format = editor.language.theme.get("accelerator.occurence")
    if not format:
        return False

    extra_selections = editor.extraSelections() or []
    if not editor.isReadOnly():
        word = editor.get_word_under_cursor()
        if not word:
            return False

        block = editor.document().findBlock(0)
        cursor = editor.document().find(word,
                                        block.position(),
                                        QTextDocument.FindCaseSensitively | QTextDocument.FindWholeWords)
        while block.isValid() and cursor.position() != -1:
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(format.background())
            selection.cursor = cursor
            extra_selections.append(selection)
            cursor = editor.document().find(word,
                                            cursor.position(),
                                            QTextDocument.FindCaseSensitively | QTextDocument.FindWholeWords)
            block = block.next()
    editor.setExtraSelections(extra_selections)
    return True
1082211
function( offsetParent, corner, offsetX, offsetY ) {
					this.editor.focus();
					offsetParent = offsetParent || CKEDITOR.document.getDocumentElement();

					// #9362: Force selection check to update commands' states in the new context.
					this.editor.selectionChange( 1 );

					this.show( offsetParent, corner, offsetX, offsetY );
				}
1346812
def _makeMatchSelection(self, block, columnIndex, matched):
        
        selection = QTextEdit.ExtraSelection()

        if matched:
            bgColor = Qt.green
        else:
            bgColor = Qt.red

        selection.format.setBackground(bgColor)
        selection.cursor = QTextCursor(block)
        selection.cursor.setPosition(block.position() + columnIndex)
        selection.cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor)

        return selection
1316927
private void doHighlight(String colorMode) throws WidgetException {
		if (!(getGUIDriver() instanceof HighlightProvider)) {
			return;
		}
		HighlightProvider highDriver = (HighlightProvider) getGUIDriver();

		if (highDriver.isHighlight()) {
			setBackgroundColor(highDriver.getHighlightColor(colorMode));
		}
	}
1242955
def __Script_Editor_Output_plainTextEdit_set_default_view_state(self):
        

        self.Script_Editor_Output_plainTextEdit.moveCursor(QTextCursor.End)
        self.Script_Editor_Output_plainTextEdit.ensureCursorVisible()
1151237
def eventFilter( self, object, event ):
        
        if ( event.type() == event.KeyPress ):
            if ( event.key() == Qt.Key_Escape ):
                self._completerTree.hide()
                self.completer().popup().hide()
                
                self.cancelEdit()
                
            elif ( event.key() in (Qt.Key_Return, Qt.Key_Enter) ):
                self.acceptEdit()
                return True
                
            elif ( event.key() == Qt.Key_Tab ):
                if ( self.completer().popup().isVisible() ):
                    text   = nativestring(self.completer().currentCompletion())
                    super(XNavigationEdit, self).setText(text)
                    return True
                else:
                    self.acceptEdit()
                    return False
            
        elif ( event.type() == event.MouseButtonPress ):
            if ( not self._completerTree.rect().contains(event.pos()) ):
                self._completerTree.hide()
                self.completer().popup().hide()
                
                self.cancelEdit()
        
        return False
503133
def eventFilter(self, object, event):
        
        index = self.indexOf(object)
        pressed = event.type() == event.KeyPress
        released = event.type() == event.KeyRelease
        
        if index == -1 or \
           not (pressed or released) or \
           self.isEditorHandlingBlocked():
            return super(XSerialEdit, self).eventFilter(object, event)
        
        text = nativestring(event.text()).strip()
        
        # handle Ctrl+C (copy)
        if event.key() == QtCore.Qt.Key_C and \
           event.modifiers() == QtCore.Qt.ControlModifier and \
           pressed:
            self.copy()
            return True
        
        # handle Ctrl+X (cut)
        elif event.key() == QtCore.Qt.Key_X and \
             event.modifiers() == QtCore.Qt.ControlModifier and \
             pressed:
            if not self.isReadOnly():
                self.cut()
            return True
        
        # handle Ctrl+A (select all)
        elif event.key() == QtCore.Qt.Key_A and \
             event.modifiers() == QtCore.Qt.ControlModifier and \
             pressed:
            self.selectAll()
            return True
        
        # handle Ctrl+V (paste)
        elif event.key() == QtCore.Qt.Key_V and \
             event.modifiers() == QtCore.Qt.ControlModifier and \
             pressed:
            if not self.isReadOnly():
                self.paste()
            return True
        
        # ignore tab movements
        elif event.key() in (QtCore.Qt.Key_Tab, QtCore.Qt.Key_Backtab):
            pass
        
        # delete all selected text
        elif event.key() == QtCore.Qt.Key_Backspace:
            sel_text = self.selectedText()
            if sel_text and not self.isReadOnly():
                self.clearSelection()
                return True
        
        # ignore modified keys
        elif not released:
            return super(XSerialEdit, self).eventFilter(object, event)
        
        # move to the previous editor
        elif object.cursorPosition() == 0:
            if event.key() in (QtCore.Qt.Key_Backspace, QtCore.Qt.Key_Left):
                self.goBack()
        
        # move to next editor
        elif object.cursorPosition() == object.maxLength():
            valid_chars = string.ascii_letters + string.digits
            valid_text = text != '' and text in valid_chars
            
            if valid_text or event.key() == QtCore.Qt.Key_Right:
                self.goForward()
        
        return super(XSerialEdit, self).eventFilter(object, event)
1341818
def _highlight_cursorlines(self, cli, new_screen, cpos, x, y, width, height):
        
        cursor_line_token = (':', ) + self.cursorline_token
        cursor_column_token = (':', ) + self.cursorcolumn_token

        data_buffer = new_screen.data_buffer

        # Highlight cursor line.
        if self.cursorline(cli):
            row = data_buffer[cpos.y]
            for x in range(x, x + width):
                original_char = row[x]
                row[x] = _CHAR_CACHE[
                    original_char.char, original_char.token + cursor_line_token]

        # Highlight cursor column.
        if self.cursorcolumn(cli):
            for y2 in range(y, y + height):
                row = data_buffer[y2]
                original_char = row[cpos.x]
                row[cpos.x] = _CHAR_CACHE[
                   original_char.char, original_char.token + cursor_column_token]

        # Highlight color columns
        for cc in self.get_colorcolumns(cli):
            assert isinstance(cc, ColorColumn)
            color_column_token = (':', ) + cc.token
            column = cc.position

            for y2 in range(y, y + height):
                row = data_buffer[y2]
                original_char = row[column]
                row[column] = _CHAR_CACHE[
                   original_char.char, original_char.token + color_column_token]
367090
def extend_selection_to_next(self, what='word', direction='left'):
        
        self.__move_cursor_anchor(what, direction, QTextCursor.KeepAnchor)
1342098
def onShortcutUnindentWithBackspace(self):
        
        assert self._qpart.textBeforeCursor().endswith(self.text())

        charsToRemove = len(self._qpart.textBeforeCursor()) % len(self.text())
        if charsToRemove == 0:
            charsToRemove = len(self.text())

        cursor = self._qpart.textCursor()
        cursor.setPosition(cursor.position() - charsToRemove, QTextCursor.KeepAnchor)
        cursor.removeSelectedText()
896410
def cursor_position_changed(self):
        """"""
        log.debug("cursor_position_changed")

        cur = self.textCursor()
        log.debug(cur.position())
        log.debug(cur.selectedText())
        if len(cur.selectedText()) == 0:
            cur.select(QtGui.QTextCursor.WordUnderCursor)
            self.setTextCursor(cur)
79748
def move_cursor(self, chars=0):
        """"""
        direction = QTextCursor.Right if chars > 0 else QTextCursor.Left
        for _i in range(abs(chars)):
            self.moveCursor(direction, QTextCursor.MoveAnchor)
615297
def indent(self):
        
        cursor = self.editor.textCursor()
        assert isinstance(cursor, QtGui.QTextCursor)
        if cursor.hasSelection():
            self.indent_selection(cursor)
        else:
            # simply insert indentation at the cursor position
            tab_len = self.editor.tab_length
            cursor.beginEditBlock()
            if self.editor.use_spaces_instead_of_tabs:
                nb_space_to_add = tab_len - cursor.positionInBlock() % tab_len
                cursor.insertText(nb_space_to_add * " ")
            else:
                cursor.insertText('\t')
            cursor.endEditBlock()