Indent selected text

        :param cursor: QTextCursor
1419
def indent_selection(self, cursor):
        
        doc = self.editor.document()
        tab_len = self.editor.tab_length
        cursor.beginEditBlock()
        nb_lines = len(cursor.selection().toPlainText().splitlines())
        c = self.editor.textCursor()
        if c.atBlockStart() and c.position() == c.selectionEnd():
            nb_lines += 1
        block = doc.findBlock(cursor.selectionStart())
        i = 0
        # indent every lines
        while i < nb_lines:
            nb_space_to_add = tab_len
            cursor = QtGui.QTextCursor(block)
            cursor.movePosition(cursor.StartOfLine, cursor.MoveAnchor)
            if self.editor.use_spaces_instead_of_tabs:
                for _ in range(nb_space_to_add):
                    cursor.insertText(" ")
            else:
                cursor.insertText('\t')
            block = block.next()
            i += 1
        cursor.endEditBlock()
387379
def indent(text: str, num: int = 2) -> str:
    """"""
    lines = text.splitlines()
    return "\n".join(indent_iterable(lines, num=num))
659144
def select(self, cursor, qstring, vals=()):
    ""
    cursor.execute(qstring, vals) # hmm; do I not want to commit at the end of this?
    return cursor.fetchall()
163975
function indent(str, prefix) {
  prefix = prefix || '   ';
  var lines = str.split("\n");
  lines.forEach(function(line, i) {
    lines[i] = prefix + line;
  });
  return lines.join("\n");
}
235063
def indent(text, num=4):
    """"""
    str_indent = ' ' * num
    return str_indent + ('\n' + str_indent).join(text.splitlines())
114171
def indentsize(line):
    """"""
    expline = string.expandtabs(line)
    return len(expline) - len(string.lstrip(expline))
391109
def left_indent(text, indent=12, end='\n'):
    '''  '''
    indent = ' ' * indent
    lines = [indent + line for line in text.splitlines(True)]
    lines.append(end)
    return ''.join(lines)
698145
def _on_mouse_moved(self, event):
        
        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()
418952
def indent(text, indent=2, width=128):
    
    return "\n".join(
        textwrap.wrap(text,
                      width=width,
                      initial_indent=" " * indent,
                      subsequent_indent=" " * indent))
793577
def replaceSelected(self):
        
        SCI = self.qteWidget

        # Restore the original styling.
        self.qteWidget.SCISetStylingEx(0, 0, self.styleOrig)

        # Select the region spanned by the string to replace.
        start, stop = self.matchList[self.selMatchIdx]
        line1, col1 = SCI.lineIndexFromPosition(start)
        line2, col2 = SCI.lineIndexFromPosition(stop)
        SCI.setSelection(line1, col1, line2, col2)

        text = SCI.selectedText()
        text = re.sub(self.toReplace, self.toReplaceWith, text)

        # Replace that region with the new string and move the cursor
        # to the end of that string.
        SCI.replaceSelectedText(text)
        line, col = SCI.lineIndexFromPosition(start + len(text))
        SCI.setCursorPosition(line, col)

        # Backup the new document style bits.
        line, col = SCI.getNumLinesAndColumns()
        text, style = self.qteWidget.SCIGetStyledText((0, 0, line, col))
        self.styleOrig = style

        # Determine if this was the last entry in the match list.
        if len(self.matchList) == self.selMatchIdx + 1:
            return False
        else:
            self.highlightAllMatches()
            return True
206620
def setText(self, sequence):
        """"""
        self.setToolTip(sequence)
        super(ShortcutLineEdit, self).setText(sequence)
30695
private void addText(TextCursor cursor, int limit, ArrayList<MDText> elements) {
        if (cursor.currentOffset < limit) {
            elements.add(new MDRawText(cursor.text.substring(cursor.currentOffset, limit)));
            cursor.currentOffset = limit;
        }
    }
574646
def cut(self):
        
        tc = self.textCursor()
        helper = TextHelper(self)
        tc.beginEditBlock()
        no_selection = False
        sText = tc.selection().toPlainText()
        if not helper.current_line_text() and sText.count("\n") > 1:
            tc.deleteChar()
        else:
            if not self.textCursor().hasSelection():
                no_selection = True
                TextHelper(self).select_whole_line()
            super(CodeEdit, self).cut()
            if no_selection:
                tc.deleteChar()
        tc.endEditBlock()
        self.setTextCursor(tc)
880000
def _add_decoration(self, cursor):
        
        if self.select_word(cursor):
            self.editor.set_mouse_cursor(Qt.PointingHandCursor)
        else:
            self.editor.set_mouse_cursor(Qt.IBeamCursor)
855491
def append(self, text):
        
        cursor = QTextCursor(self._doc)
        cursor.movePosition(QTextCursor.End)
        cursor.insertBlock()
        cursor.insertText(text)
1308489
def __select_text_under_cursor_blocks(self, cursor):
        

        start_block = self.document().findBlock(cursor.selectionStart()).firstLineNumber()
        end_block = self.document().findBlock(cursor.selectionEnd()).firstLineNumber()
        cursor.setPosition(self.document().findBlockByLineNumber(start_block).position())
        cursor.movePosition(QTextCursor.StartOfLine, QTextCursor.MoveAnchor)
        cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor, end_block - start_block)
        cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
242754
def set_indent(TokenClass, implicit=False):
    """"""
    def callback(lexer, match, context):
        text = match.group()
        if context.indent < context.next_indent:
            context.indent_stack.append(context.indent)
            context.indent = context.next_indent
        if not implicit:
            context.next_indent += len(text)
        yield match.start(), TokenClass, text
        context.pos = match.end()
    return callback