public inbox for goredo-devel@lists.cypherpunks.ru
Atom feed
* What is the purpose of fillUpToTermSize?
@ 2021-04-28 23:49 Rin Takanashi
  2021-04-29 11:39 ` Sergey Matveev
  0 siblings, 1 reply; 2+ messages in thread
From: Rin Takanashi @ 2021-04-28 23:49 UTC (permalink / raw)
  To: goredo-devel

[-- Attachment #1: Type: text/plain, Size: 1011 bytes --]

Hello,

I was wondering what is the fillUpToTermSize function supposed to do. From
the name it seems to stretch the string with spaces to the terminal's width
but from what I understand it stretches the supplied string to the length
of the longest previously supplied string.

I don't really know why this behavior would be wanted, but I ran into this
function when it caused many newlines (caused by a lot of extra spaces) in
the output of redo after a long line was printed to stderr from one of my
.do files.

Example:
=== all.do
redo-ifchange long
~~~

=== long.do
redo-always

for i in $(seq 1 1 200); do
        printf "$i" >&2
done
~~~

The code above should produce several newlines right after "redo . long"
which result from the extra spaces on this line and the "redo . all" line
is not affected.

When I removed everything but the return statement from this function no
other output seemed to be broken and there were no weird newlines, so
that's why I'm unsure as to this function's purpose.

-Rin

[-- Attachment #2: Type: text/html, Size: 1658 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: What is the purpose of fillUpToTermSize?
  2021-04-28 23:49 What is the purpose of fillUpToTermSize? Rin Takanashi
@ 2021-04-29 11:39 ` Sergey Matveev
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Matveev @ 2021-04-29 11:39 UTC (permalink / raw)
  To: goredo-devel

[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]

Greetings!

*** Rin Takanashi [2021-04-29 01:49]:
>I was wondering what is the fillUpToTermSize function supposed to do. From
>the name it seems to stretch the string with spaces to the terminal's width
>but from what I understand it stretches the supplied string to the length
>of the longest previously supplied string.

Initially it was really the function that filled line with spaces up to
terminal's width. But when window gets resized, all that spaces made
awful picture. Later its implementation was replaced with remembering
the previous line length, that did not produce that many invisible
(until window is resized) spaces.

All of that exists only because of statusline that is printed by default
at the bottom of the screen. Very often the text you want to output is
shorter than previously printed status line and you will see part of
statusline after your text. Like in that example:

    $ printf "longstatusline\rmy text\n"
    my texttusline

And I cleared that remaining text with spaces. But you example with seq
200 is good example when that algorithm clearly sucks.

I replaced it with honest CSI ANSI escape sequence that clears the line
to the end. As I understand, it should not harm anywhere. If someone
does not want to see any kind of escape codes, then anyway he will
disable statusline display (-no-status) -- so clearing escape sequence
won't appear at all anywhere. NO_COLOR will disable even printing the
colouring codes too, making goredo's output readable even when captured
with "script" utility for example. And that removes any problems when
window is resized.

I released 1.4.0 version with that change.
Thanks for pointing at that issue! Hope current honest escape code
clearing won't bring any problems I currently do not see.

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263  6422 AE1A 8109 E498 57EF

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-29 11:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 23:49 What is the purpose of fillUpToTermSize? Rin Takanashi
2021-04-29 11:39 ` Sergey Matveev