<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 20, 2024 at 9:38 AM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/20/24 00:02, Oliver Webb via Toybox wrote:<br>
> I spotted the more implementation in pending. Looking at it, it's missing quite a lot of stuff, <br>
> Such as the ability to go back in a file.<br>
<br>
More never had the ability to go backwards, less did. Different command.<br></blockquote><div><br></div><div>(...but there's a lot of confusion because many modern systems have more just a symlink to less.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> It's built in a way where nothing is accumulated, Which <br>
> means that support for that would require a half-rewrite.<br>
<br>
My todo item in more was that it has to wordwrap to the current screen size to<br>
figure out when it's done a line, and that implies UTF8/unicode fontmetrics, and<br>
also implies ANSI escape sequence handling (for at least color changes).<br>
<br>
> What does POSIX specify as far as options?<br>
<br>
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html" rel="noreferrer" target="_blank">https://pubs.opengroup.org/onlinepubs/9699919799/utilities/more.html</a><br>
<br>
> Looking at the man page, quite a bit. None of which I've<br>
> ever seen used before.<br>
> <br>
> Looking at the other keybindings GNU more provides which I can implement, There's "=" (prints current<br>
> line number) ":f" (print filename and line), as well as being able to use the down arrow to go down <br>
> (with the added side effect of any escape key doing so too, not the end of the world, especially<br>
> since we can't scroll up) That are Implemented them in the attached patch.<br>
<br>
Again, more and less are not the same command.<br>
<br>
> There is also a testing problem. vi.c doesn't do TEST_HOST because it needs a -s option<br>
> to pass in scripts to test with.<br>
<br>
Which is an issue I need to figure out how to address. What does a test that<br>
_only_ toybox passes actually prove? (That it hasn't changed since we last<br>
looked at it?)<br>
<br>
> less and more are _worse_ since they don't change anything.<br>
<br>
They (and vi) care about current terminal size. Automating tests for that<br>
probably involves a PTY wrapper with a pty master side that can do things like<br>
query the current (virtual) cursor position, which I've sometimes sketched out<br>
notes for but not actually tried to write yet. (It's after "get the test suite<br>
running under qemu in mkroot.)<br>
<br>
> Manually testing often introduces regressions, so I dunno what the solution is here<br>
<br>
I have design ideas. Blogged about them some years ago, I think? (Or maybe wrote<br>
about them in the mailing list web archive, which dreamhost put some rather<br>
large holes in on more than one occasion because dreamhost...)<br>
<br>
> This patch improves things for now, but if we are planning on doing a<br>
> future less implementation. <br>
<br>
I have been planning one all along, yes. The crunch_str() stuff I did was a<br>
first pass at general line handling stuff that could be used by less and by<br>
shell line editing and by vi and so on, but people wrote a vi that does not and<br>
never will share code with the rest of those so that's off the table<br>
permanently. I put that on a back burner until I do shell command editing and<br>
history (which needs to know the indentation from the prompt via the ANSI escape<br>
that sends back a current position, but what should it do when the terminal<br>
doesn't respond to that? People can type ahead before the prompt is even written<br>
and the probe reply gets appended to that so it can come in at any point,<br>
there's some redrawing. In bash there's a horrible \[ and \] escape syntax<br>
around "non printing" characters which you can use to manually fudge its<br>
measurement of ANSI escapes, but it still gets it wrong when the previous<br>
command didn't end with a newline ala "echo -n potato" and I want to get it<br>
right...)<br>
<br>
Anyway, there's users of this in "top" and in hexedit's ctrl-F input and so on.<br>
Except hexedit's ctrl-f appears to have broken since I wrote it, how nice...<br>
<br>
> We could probably merge more into that and make them share a common base either as 2 functions in<br>
> the same file, or just make more a OLDTOY pointing to less like how [ points to [[.<br>
<br>
I've done stuff on this and it turns out the two don't share nearly as much<br>
logic as you'd think. A quick grep finds:<br>
<br>
<a href="https://landley.net/notes-2018.html#10-10-2018" rel="noreferrer" target="_blank">https://landley.net/notes-2018.html#10-10-2018</a><br>
<br>
<a href="https://landley.net/notes-2017.html#31-12-2017" rel="noreferrer" target="_blank">https://landley.net/notes-2017.html#31-12-2017</a><br>
<br>
> less seems moderately easy (Read lines into list, show lines, scroll down and read more lines,<br>
> scroll up and go back in list.)<br>
<br>
It seemed easy to me too, until I sat down to try to understand its behavior.<br>
<br>
> Especially since we already have vi.c which does almost all the stuff<br>
> less does at it's core, there's a lot of potential code-sharing (To which<br>
> file though, lib/tty.c?).<br>
<br>
I have zero input into the vi.c in pending. I was too slow, so it was taken out<br>
of my hands. I pass along changes to it without particularly reviewing them, it<br>
shares no code with any other command in toybox, and trying to clean it up or<br>
promote it has been punted to a post-1.0 item along with implementing "screen"<br>
and similar.<br>
<br>
> But I have to ask the question "If it's so easy, why isn't it in toybox yet?" Is it just because<br>
> other TODO items taking up time, or is it because it's harder to implement than it seems.<br>
<br>
Because I care about edge cases like ansi escapes and utf8 fontmetrics and<br>
resizing the screen partway through displaying, because I haven't got test suite<br>
infrastructure that can emulate the other half of a PTY yet without which<br>
testing has to be manual, because I wanted multiple things to share<br>
infrastructure (including potentially stuff like "fold")...<br>
<br>
Rob<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div></div>