[pyobj-] improve display of sets and simple objects #2331
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This set of commits is aimed at making
pyobj-expr
more user-friendly. As it stands now, the results from looking at certain values are quite strange.None
: gives a sheet with no rowsset([1,2,3])
: a sheet with no rows (because what is shown are its attributes, not its elements)str()
: a sheet with no rows, with the headertext
, which is different from the previous two cases1
orTrue
: a sheet of attributes, hard to make sense of:I've added a new sheet type,
PythonAtomSheet
to holdNone
or abool
, a number, or an empty string. The goal is to improve the display. The change makes it easy to distinguish an expression value ofNone
from""
, due to the⌀
shown. And it shows bools/numbers in a simple 1x1 cell, instead of a 4x3 sheet of display attributes.The new sheet also doesn't allow diving deeper into such simple objects. By contrast, the way visidata already works is, after
pyobj-expr
for a number1
, you can keep hittingEnter
to dive in on thedenominator
field infinitely. It's quite confusing for a new user.And I fixed a bug where if a sheet had no rows,
open-row
takes the user to a newPyobjExpr
sheet.(to reproduce,
vd nonexistent_file.tsv
thenENTER
)Some quirks of this PR:
None
is shown as it is in a standard sheet, an empty cell with⌀
next to it. Maybe it should show the text "None".deduceType
will put?
next to the column header.PythonAtomSheet
unlike regular strings that go into a TextSheet. I did that to prevent further dives into the empty string. But that creates an inconsistency, the header for empty strings is "value", but for all other strings it's "text". To get rid of the special handling for empty strings, just change the code to: