rfcs
rfcs copied to clipboard
Add RFC for the inclusion of all erase codes in the Term package
@rhagenson @jemc I have a better implementation idea. Same shape of things but without the need for the match statement.
I prefer this and think it is easier to follow.
Thoughts?
primitive EraseLeft
fun apply(): String =>
"\x1B[1K"
primitive EraseLine
fun apply(): String =>
"\x1B[2K"
primitive EraseRight
fun apply(): String =>
"\x1B[0K"
type _EraseDirection is (EraseLeft | EraseLine | EraseRight)
primitive Ansi
fun erase(direction: _EraseDirection = EraseRight): String =>
"""
Erases content. The direction to erase is dictated by the `direction`
parameter. Use `EraseLeft` to erase everything from the cursor to the
beginning of the line. Use `EraseLine` to erase the entire line. Use
`EraseRight` to erase everything from the cursor to the end of the line.
The default direction is `EraseRight`.
"""
direction()
I like that a lot more. I was trying to think of a way to get rid of the match because I did not like one condition being the fall through in else when we know all the states that are possible.
@rhagenson yeah. I didn't like it either. I dashed it off yesterday to get it open.
I've updated again because "dur", exhaustive match, the else wasn't needed. I think I like the version in the RFC better than the one in my comment now. It fits the existing API better.
@ergl Type aliases dont appear in any generated documentation.
Approved during today's sync call :heavy_check_mark: