Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[cliptext-] clipstr() to width 1: truncate chars having width > 1 #2667

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jan 7, 2025

Let's say we have a sheet with full-width characters, like あ,
normal
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.
width1-current

This PR changes clipstr() to trim the fullwidth character to '', so that the column will stay aligned:
width1-new

Note that this affects the behavior of the headers of hidden columns. They currently show the first character even when it's full-width:
hidden-current
but after this PR they will become blank:
hidden-new

I'm fine with blank headers for hidden columns. If we want to solve that, it can be fixed in drawColHeader():

clipdraw(scr, y+i, x, name, hdrcattr, w=colwidth)

An alternate design for this PR would have clipstr() replace the single chars with trunch:

        if w_s > 1:
            #add these 2 lines to replace the char with trunch:
            if trunch:
                return trunch, dispwidth(trunch)

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() or clipdraw() with truncator=''. But locating all those places would be more effort. So I'm submitting this PR, which is a less invasive change.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants