avoid cursor jitter when updating progress display
When the progress display gets longer, and then shorter again, it causes the cursor to jitter back and forth. Somehow I never noticed this until this morning, but then it became intolerable to watch. To fix it, pad the progress display to the maximum length it's occupied. Sponsored-by: Svenne Krap on Patreon
This commit is contained in:
parent
e9b0cf08eb
commit
1c11dd4793
2 changed files with 7 additions and 4 deletions
|
@ -16,6 +16,7 @@ git-annex (8.20210904) UNRELEASED; urgency=medium
|
|||
* reinject: Fix crash when reinjecting a file from outside the repository.
|
||||
(Reversion in version 8.20210621)
|
||||
* borg: Some improvements to memory use when importing a lot of archives.
|
||||
* Avoid cursor jitter when updating progress display.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Fri, 03 Sep 2021 12:02:55 -0400
|
||||
|
||||
|
|
|
@ -459,12 +459,14 @@ updateMeter (Meter totalsizev sv bv displaymeter) new = do
|
|||
-- | Display meter to a Handle.
|
||||
displayMeterHandle :: Handle -> RenderMeter -> DisplayMeter
|
||||
displayMeterHandle h rendermeter v msize old new = do
|
||||
olds <- takeMVar v
|
||||
let s = rendermeter msize old new
|
||||
olds <- swapMVar v s
|
||||
let padding = replicate (length olds - length s) ' '
|
||||
let s' = s <> padding
|
||||
putMVar v s'
|
||||
-- Avoid writing when the rendered meter has not changed.
|
||||
when (olds /= s) $ do
|
||||
let padding = replicate (length olds - length s) ' '
|
||||
hPutStr h ('\r':s ++ padding)
|
||||
when (olds /= s') $ do
|
||||
hPutStr h ('\r':s')
|
||||
hFlush h
|
||||
|
||||
-- | Clear meter displayed by displayMeterHandle. May be called before
|
||||
|
|
Loading…
Add table
Reference in a new issue