Subject: Re: bug#57434: 28.1.91; Terminal Emacs Mac OS flickering.

From: Eli Zaretskii <[email-masked]>
Date: Mon, 29 Aug 2022 19:01:23 +0300

> From: Dmitrii Kuragin <[email-masked]>
> Date: Mon, 29 Aug 2022 07:18:43 -0700
> Cc: Gerd Möllmann <[email-masked]>, 
> 	[email-masked]
> 
> I compiled with `-O0 -g3`, then
> ```
> lldb
> (lldb) file nextstep/Emacs.app/Contents/MacOS/Emacs
> Current executable set to '/Users/kuragin/Desktop/emacs/nextstep/Emacs.app/Contents/MacOS/Emacs'
> (x86_64).
> (lldb) breakpoint set -f scroll.c -l 270
> Breakpoint 1: where = Emacs`do_scrolling + 485 at scroll.c:271:11, address = 0x0000000100032da5
> ```
> 
> But, it doesn't stop there...

Why scroll.c:271, when the code you patched begins on line 684?

> When I have line numbers enabled, I assume, the scrolling logic would always try to insert/delete/write lines. In
> my case it might be:
>  - Writing (Is that writing on top of the current lines?) is cheaper.
>  - Screen flickers because of the specific frequency of the terminal (or the way we flush the buffer).
>    For example, we insert empty lines and then the screen is updated, only then we add content in there and
> redisplay again.
> 
> Potentially, some redrawing might happen inside of `ins_del_lines`? Instead of redrawing the whole screen,
> we redraw it in the middle of modifying it?

There shouldn't be any redrawing when none of the shown buffers
changes in any way.  You see flickering when Emacs is completely idle,
yes?