Skip to content

Create ElidableList, an instance of Cell which can be dropped atomically#34

Draft
Xitian9 wants to merge 5 commits intomuesli4:masterfrom
Xitian9:elidablelist
Draft

Create ElidableList, an instance of Cell which can be dropped atomically#34
Xitian9 wants to merge 5 commits intomuesli4:masterfrom
Xitian9:elidablelist

Conversation

@Xitian9
Copy link
Collaborator

@Xitian9 Xitian9 commented Apr 6, 2022

This code has been in hledger in another form for a while. But it actually suits the framework of Cell very well, so I've translated it and hoved it over here in case others find it useful.

Note that this PR depends on both #29 and #33, which are both fairly small PRs that are much simpler. You can either merge those individually, in which case I'll rebase this and you can review it on its own, or you can merge them all here.

@Xitian9
Copy link
Collaborator Author

Xitian9 commented Apr 20, 2022

Since this depends on #29 and #33, and will also have to be rebased after merging #37, I'll mark this as draft for now.

@Xitian9 Xitian9 marked this pull request as draft April 20, 2022 08:21
Copy link
Owner

@muesli4 muesli4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes but they need a little bit of work.

The trim function will no longer produce garbage if given a length that
is longer than the Cell to trim. Previously the only way to safely trim
was with the trimOrPad function, which would also pad if the Cell was
too short. This new function avoids this possibly unwanted effect.

We also provide unsafe helper versions of the pad and fill functions
which take the visibleLength of the Cell as an argument, ensuring that
visibleLength is never calculated more than once.
This acts as a combination of fixedUntil and expandUntil: it will be
of fixed length until the first argument, after which it will expand to
match the size of the column up until the second argument.

Also add test coverage for grid and the various column specs.
This ensures that columns really are the advertised width, even with
very small column sizes.
@Xitian9 Xitian9 force-pushed the elidablelist branch 2 times, most recently from 2d882ea to 812c3e1 Compare October 27, 2022 00:07
This adds dropLeftNoPad, dropRightNoPad, and dropBothNoPad to the Cell
typeclass. These can be used to get tighter bounds on maximum column
width with the expandUntil and expandBetween LenSpecs.

This does not yet get tighter bounds when an AlignSpec other than
NoAlign is used.
ElidableList takes something which is an instance of Cell and creates a
list from which items will be dropped atomically.
@Xitian9 Xitian9 mentioned this pull request Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants