Exemple #1
0
def setText(text):
    """Set the document text."""
    # Just setting d.text does work, but triggers a bug in the
    # Katepart syntax highlighting: the first part of the document
    # looses its highlighting when a user undoes the conversion
    # with Ctrl+Z
    d = kate.document()
    d.editingSequence.begin()
    for i in range(d.numberOfLines):
        d.removeLine(0)
    kate.document().text = text
    d.editingSequence.end()
Exemple #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))
Exemple #3
0
def interrupt():
    from lilykde import runlily
    runlily.interrupt(kate.document())
Exemple #4
0
def publish():
    from lilykde import runlily
    runlily.runLilyPond(kate.document())
Exemple #5
0
def preview():
    from lilykde import runlily
    runlily.runLilyPond(kate.document(), preview=True)
Exemple #6
0
def fragment(start, end):
    """Returns the text from start (line, col) to end (line, col)..."""
    return kate.document().fragment(start, end)
Exemple #7
0
def search(text, start, caseSensitive=True, searchBackwards=False):
    """
    Search through the document.
    Returns match, (line, column), length
    """
    return kate.document().search(text, start, caseSensitive, searchBackwards)
Exemple #8
0
def line(lineNum):
    """The text on the given line number."""
    return kate.document().line(lineNum)
Exemple #9
0
def clear():
    """Clear the current editor buffer."""
    # kate.document().clear() is broken in Pate 0.5.1
    d = kate.document()
    for i in range(d.numberOfLines):
        d.removeLine(0)
Exemple #10
0
def append(text):
    """Append text to document (starting in a new line)."""
    d = kate.document()
    d.insertLine(d.numberOfLines, text)
Exemple #11
0
def insertLine(lineNum, text):
    """Insert text at the given line number."""
    kate.document().insertLine(lineNum, text)
Exemple #12
0
def text():
    """The document text."""
    return kate.document().text
Exemple #13
0
def editEnd():
    """End an editing sequence."""
    kate.document().editingSequence.end()
Exemple #14
0
def editBegin():
    """Start an editing sequence."""
    kate.document().editingSequence.begin()