fix: remove per-call finish-output from backend-write (flush once per frame via end-sync)

backend-write flushed output after every single draw-text/draw-rect
call, causing hundreds of individual flushes per frame. This caused
visible flicker on slow terminals.

Remove finish-output from backend-write — all critical flush points
(initialize-backend, shutdown-backend, enable-mouse, enable-bracketed-paste,
end-sync) already call finish-output explicitly.

DECICM sync (begin-sync/end-sync) wraps every frame boundary,
making the frame render atomically with a single flush at end-sync.
This commit is contained in:
2026-05-14 19:36:21 -04:00
parent 916f473107
commit bb579be207
4 changed files with 6 additions and 10 deletions

View File

@@ -886,16 +886,14 @@ a hard-coded 80x24 at the end:
*** Backend Write (Simple) *** Backend Write (Simple)
Writes a string to the backend's output stream, forces the stream to Writes a string to the backend's output stream and returns its length.
flush, and returns the length of the string. Uses ~finish-output~ to Does NOT flush — explicit sync points (~initialize-backend~,
ensure the data is actually sent, which matters for pipe and network ~end-sync~, etc.) call ~finish-output~ as needed.
output.
#+BEGIN_SRC lisp :tangle ../src/backend/simple.lisp #+BEGIN_SRC lisp :tangle ../src/backend/simple.lisp
(defmethod backend-write ((b simple-backend) string) (defmethod backend-write ((b simple-backend) string)
(let ((stream (backend-output-stream b))) (let ((stream (backend-output-stream b)))
(write-string string stream) (write-string string stream)
(finish-output stream)
(length string))) (length string)))
#+END_SRC #+END_SRC

View File

@@ -701,15 +701,15 @@ Uses a fallback chain to determine terminal dimensions:
*** backend-write *** backend-write
Writes a string to the backend's output stream, flushing after each Writes a string to the backend's output stream. Does NOT flush — the
write to ensure the terminal receives the escape sequence immediately. caller is responsible for calling ~finish-output~ at appropriate sync
points (frame boundaries via ~end-sync~, initialization, shutdown).
Returns the string length for protocol compatibility. Returns the string length for protocol compatibility.
#+BEGIN_SRC lisp :tangle ../src/backend/modern.lisp #+BEGIN_SRC lisp :tangle ../src/backend/modern.lisp
(defmethod backend-write ((b modern-backend) string) (defmethod backend-write ((b modern-backend) string)
(let ((stream (backend-output-stream b))) (let ((stream (backend-output-stream b)))
(write-string string stream) (write-string string stream)
(finish-output stream)
(length string))) (length string)))
#+END_SRC #+END_SRC

View File

@@ -204,7 +204,6 @@ as a fallback when a keyword is not in *named-colors*.")
(defmethod backend-write ((b modern-backend) string) (defmethod backend-write ((b modern-backend) string)
(let ((stream (backend-output-stream b))) (let ((stream (backend-output-stream b)))
(write-string string stream) (write-string string stream)
(finish-output stream)
(length string))) (length string)))
(defmethod capable-p ((b modern-backend) feature) (defmethod capable-p ((b modern-backend) feature)

View File

@@ -77,7 +77,6 @@
(defmethod backend-write ((b simple-backend) string) (defmethod backend-write ((b simple-backend) string)
(let ((stream (backend-output-stream b))) (let ((stream (backend-output-stream b)))
(write-string string stream) (write-string string stream)
(finish-output stream)
(length string))) (length string)))
(defmethod draw-text ((b simple-backend) x y string fg bg (defmethod draw-text ((b simple-backend) x y string fg bg