fun-a-day, day 15

the big thing today was automatic wrapping.

the rules around what to do when the cursor is in the rightmost column
turn out to be pretty confusing. and the exact behavior on wrapping is
a lot more complicated than one would expect [1].

i had been putting this off as long as i could but finally sat down
and started on it. at this point the wrapping logic is not totally
correct but works in the majority of cases.

back to funaday 2023 home

-----------------------------------------------------------------------

[1] basically, the issue is what to do when the cursor is in the
rightmost column and a character is printed. should the cursor wrap
around to the next line? should it stay where it is?

it turns out that vt100, xterm, and most modern terminal emulators
do something called "smart wrapping" where the cursor stays in its
position and only wraps if more input comes in. in some cases the
terminal will ignore non-printing inputs (like newlines) too.

the exact details of which inputs are ignored in the rightmost state
and which are not (as well as which movement commands can get the
cursor out of this state) are what make it a bit tricky to implement.

some more links if you're interested:

  * this xterm FAQ entry
  * this stackoverflow answer (from the xterm author)

this is definitely something that will need additional attention.
it's also likely to be something that will ultimately require a
custom terminfo description for determ.