[cliptext-] clipstr() to width 1: truncate chars having width > 1 #2667
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.
Let's say we have a sheet with full-width characters, like あ,
clipstr()
currently causes a problem: if we change a column to width 1, each cell's first character is drawn with its full width, causing columns to be misaligned.This PR changes
clipstr()
to trim the fullwidth character to''
, so that the column will stay aligned:Note that this affects the behavior of the headers of hidden columns. They currently show the first character even when it's full-width:
but after this PR they will become blank:
I'm fine with blank headers for hidden columns. If we want to solve that, it can be fixed in
drawColHeader()
:visidata/visidata/sheets.py
Line 741 in 6b0a78a
An alternate design for this PR would have
clipstr()
replace the single chars withtrunch
:But then we'd want to disable the use of the truncator-symbol in certain places, like the top of hidden columns. To do that is easy enough, just call the
clipstr()
orclipdraw()
withtruncator=''
. But locating all those places would be more effort. So I'm submitting this PR, which is a less invasive change.