def _get_input_buffer_cursor_pos(self):
        """Get the cursor position within the input buffer."""
        cursor = self._control.textCursor()
        cursor.setPosition(self._prompt_pos, QtGui.QTextCursor.KeepAnchor)
        input_buffer = cursor.selection().toPlainText()

        # Don't count continuation prompts
        return len(input_buffer.replace('\n' + self._continuation_prompt, '\n'))
Get the cursor position within the input buffer.
angrmanagement/vendor/qtconsole/console_widget.py