From b7dea0f3332b91dc889772b0b8da71b0297efe30 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Thu, 31 Jul 2025 14:35:18 +0200 Subject: [PATCH] Add method to get the last line of a buffer --- editor/editor.lisp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/editor/editor.lisp b/editor/editor.lisp index d933b2d..57b3552 100644 --- a/editor/editor.lisp +++ b/editor/editor.lisp @@ -454,6 +454,11 @@ serial connection the editor normally runs under.") (buffer-view instance) (make-instance 'buffer-view :buffer instance) (top-line (buffer-view instance)) (first-line instance))) +(defmethod last-line ((buffer buffer)) + (loop :for line := (first-line buffer) :then (next-line buffer) + :until (null (next-line line)) + :finally (return line))) + (defmethod buffer-string ((buffer buffer)) "Returns a string equivalent to BUFFER's contents." (with-output-to-string (output)