products/sources/formale sprachen/Isabelle/Tools/jEdit/dist/macros/Emacs image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: Emacs_Transpose_Lines.bsh   Sprache: Unknown

Spracherkennung für: .bsh vermutete Sprache: Shell {Shell[73] PVS[91] CS[109]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

/**
 * Transpose line at caret with previous line, and move caret to next line.
 *  Emulates Emacs "transpose-lines" command (without prefix argument support).
 */

source (MiscUtilities.constructPath(dirname(scriptPath), "EmacsUtil.bsh"));

void emacsTransposeLines()
{
    caret = textArea.getCaretPosition();
    if ((caret == 0) || atEndOfBuffer())
    {
        beep();
        return;
    }

    caretLine = textArea.getCaretLine();
    lineStart = textArea.getLineStartOffset (caretLine);
    lineEnd = textArea.getLineEndOffset (caretLine);
    lineIndex = textArea.getLineOfOffset (caretLine);

    selection = new Selection.Range (lineStart, lineEnd);
    line = textArea.getSelectedText(selection);

    // Get the location of the previous line

    textArea.goToPrevLine (false);
    prevLineCaret = textArea.getCaretLine();
    prevLineStart = textArea.getLineStartOffset (prevLineCaret);

    // Go back to the original location.
    
    textArea.setCaretPosition (caret);
    
    // Delete the line
    
    textArea.deleteLine();
    
    // Insert it in the new location.

    buffer.insert (prevLineStart, line);
}

emacsTransposeLines();


[ Dauer der Verarbeitung: 0.59 Sekunden  ]