Exemplo n.º 1
0
def selectedText():
    """
    Returns the currenty selected text or an empty string.
    """
    if kate.view().selection.exists:
        return kate.view().selection.text
    else:
        return ''
Exemplo n.º 2
0
def replaceSelectionWith(text, keepSelection = False):
    """
    Replaces the selection in the current view with text,
    and reselects the newly inserted text if keepSelection == True
    """
    d, v, s = kate.document(), kate.view(), kate.view().selection
    if s.exists:
        line, col = s.region[0]
    else:
        line, col = v.cursor.position
    lines = text.split('\n')
    endline, endcol = line + len(lines) - 1, len(lines[-1])
    if len(lines) < 2:
        endcol += col
    d.editingSequence.begin()
    if s.exists:
        s.removeSelectedText()
    v.insertText(text)
    d.editingSequence.end()
    if keepSelection:
        s.region = ((line, col), (endline, endcol))
Exemplo n.º 3
0
def setPos(linepos, col = None):
    """Set the cursor position to line, col or (line, col)."""
    if col is None:
        kate.view().cursor.position = linepos
    else:
        kate.view().cursor.position = (linepos, col)
Exemplo n.º 4
0
def pos():
    """The cursor position."""
    return kate.view().cursor.position
Exemplo n.º 5
0
def currentLine():
    """The text on the current line."""
    return kate.view().currentLine
Exemplo n.º 6
0
def hasSelection():
    """True if there is a selection"""
    return kate.view().selection.exists
Exemplo n.º 7
0
def insertText(text):
    kate.view().insertText(text)