コード例 #1
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
def selectedText():
    """
    Returns the currenty selected text or an empty string.
    """
    if kate.view().selection.exists:
        return kate.view().selection.text
    else:
        return ''
コード例 #2
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
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))
コード例 #3
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
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)
コード例 #4
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
def pos():
    """The cursor position."""
    return kate.view().cursor.position
コード例 #5
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
def currentLine():
    """The text on the current line."""
    return kate.view().currentLine
コード例 #6
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
def hasSelection():
    """True if there is a selection"""
    return kate.view().selection.exists
コード例 #7
0
ファイル: editor.py プロジェクト: Alwnikrotikz/lilykde
def insertText(text):
    kate.view().insertText(text)