[2/2] pacman: let the progress bar "C"/"c" move up and down at a more regular rate

Message ID 20220722202705.67778-2-xyproto@archlinux.org
State New
Headers show
Series [1/2] pacman: remove redundant argument | expand

Commit Message

Alexander F. Rødseth July 22, 2022, 8:27 p.m. UTC
For some terminal widths, the "C"/"c" character does not alternate at
regular intervals, but may look like it is stuck at either lowercase or
uppercase.

The previous behavior toggled based on the character position, while this
new behavior toggles the chomp alternation based on the progress percentage value.

This leads to slightly improved chomping.

Signed-off-by: Alexander F. Rødseth <xyproto@archlinux.org>
---
 src/pacman/callback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Allan McRae July 28, 2022, 11:45 p.m. UTC | #1
On 23/7/22 06:27, Alexander F. Rødseth wrote:
> For some terminal widths, the "C"/"c" character does not alternate at
> regular intervals, but may look like it is stuck at either lowercase or
> uppercase.
> 
> The previous behavior toggled based on the character position, while this
> new behavior toggles the chomp alternation based on the progress percentage value.
> 
> This leads to slightly improved chomping.
> 

How I would love to remove this option, but I think I would suffer a 
revolt from users!

This is fine.

> Signed-off-by: Alexander F. Rødseth <xyproto@archlinux.org>
> ---
>   src/pacman/callback.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/pacman/callback.c b/src/pacman/callback.c
> index df4032a4..aa6303bf 100644
> --- a/src/pacman/callback.c
> +++ b/src/pacman/callback.c
> @@ -165,7 +165,7 @@ static void fill_progress(const int percent, const int proglen)
>   				if(i > hashlen - hash) {
>   					putchar('-');
>   				} else if(i == hashlen - hash) {
> -					if(i % 2 == 0) {
> +					if(percent % 2 == 0) {
>   						fputs("\033[1;33mC\033[m", stdout);
>   					} else {
>   						fputs("\033[1;33mc\033[m", stdout);

Patch

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index df4032a4..aa6303bf 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -165,7 +165,7 @@  static void fill_progress(const int percent, const int proglen)
 				if(i > hashlen - hash) {
 					putchar('-');
 				} else if(i == hashlen - hash) {
-					if(i % 2 == 0) {
+					if(percent % 2 == 0) {
 						fputs("\033[1;33mC\033[m", stdout);
 					} else {
 						fputs("\033[1;33mc\033[m", stdout);