Skip to content

Commit b4712b0

Browse files
committed
Use synchronized-output mode.
1 parent f9d287e commit b4712b0

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎setup.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'hyrule >= 1',
1818
'toolz >= 1',
1919
'construct >= 2.10.70',
20-
'blessed >= 1.20.0',
20+
'blessed >= 1.24.0',
2121
'platformdirs >= 4.3.6',
2222
'metadict >= 0.1.3'],
2323
packages = setuptools.find_packages(),

‎simalq/main.hy‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@
196196
(while (B.inkey :timeout 0))
197197
(B.inkey :esc-delay .01))
198198

199+
(defn print-full-screen [#* output]
200+
(setv output (+ B.home (.join "" output)))
201+
(with [(.synchronized-output B :timeout .05)]
202+
; .05 s may well be too little time for SSH, but making the user
203+
; not wait too long for a local terminal that just isn't
204+
; responding, as is the more common case, is more important.
205+
(print output :flush T :end "")))
206+
199207
;; --------------------------------------------------------------
200208
;; ** The main loop for IO
201209
;; --------------------------------------------------------------
@@ -220,11 +228,9 @@
220228
(msg (get e.args 0)))))))
221229

222230
(defn print-main-screen [#** kwargs]
223-
(print
224-
:flush T :sep "" :end ""
225-
B.home
226-
(.join "\n" (map (fn [x] (bless-colorstr B x)) (draw-screen
227-
B.width B.height #** kwargs)))))
231+
(print-full-screen (.join "\n" (gfor
232+
line (draw-screen B.width B.height #** kwargs)
233+
(bless-colorstr B line)))))
228234

229235
;; --------------------------------------------------------------
230236
;; ** Text screens
@@ -305,9 +311,8 @@
305311
(io-mode
306312

307313
:draw (fn []
308-
(print
309-
:flush T :sep "" :end ""
310-
B.home B.clear
314+
(print-full-screen
315+
B.clear
311316
(.join "\n" (cut lines
312317
top-line-ix
313318
(+ top-line-ix B.height))))
@@ -346,9 +351,8 @@
346351
(io-mode
347352

348353
:draw (fn []
349-
(print
350-
:flush T :sep "" :end ""
351-
B.home B.clear
354+
(print-full-screen
355+
B.clear
352356
(.join "\n" (gfor
353357
line (cut display-lines B.height)
354358
(cut line B.width)))))

0 commit comments

Comments
 (0)