Repository navigation
Completely support full-width characters in differential rendering - #654
Merged
Merged
Conversation
tompng
force-pushed
the
differential_rendering_fullwidth
branch
from
April 1, 2024 17:57
95220ed to
75ca084
Compare
ima1zumi
reviewed
Apr 25, 2024
| total_width += mbchar_width | ||
| break if (start_col + max_width) < total_width | ||
| chunk << gc if start_col < total_width | ||
| break if !cover_end && total_width > start_col + width |
Member
There was a problem hiding this comment.
Could you add comments to these conditional branches?
Member
Author
There was a problem hiding this comment.
I forgot to implement this.
# Red background あ
Reline::Unicode.take_mbchar_range "\e[41mあ", 1, 2, padding: true
# Red background whitespace + No background whitespace
["\e[41m \e[0m ", 1, 2]I've updated the implementation and add comments
|
|
||
| DIALOG_DEFAULT_HEIGHT = 20 | ||
|
|
||
| private def padding_space_with_escape_sequences(str, width) |
Member
There was a problem hiding this comment.
I'm curious, why did you combine calculating padding with take_mbchar_range?
Member
Author
There was a problem hiding this comment.
Padding sometimes have background colors.
The last testcase I added is a good example.
assert_equal ["\e[41m \e[42mい\e[43m ", 1, 4], Reline::Unicode.take_mbchar_range("\e[41mあ\e[42mい\e[43mう\e[0m", 1, 4, padding: true)
So we can't add non-colored space as padding. Padding logic cannot be separated from take_mbchar_range
tompng
force-pushed
the
differential_rendering_fullwidth
branch
from
April 27, 2024 09:35
75ca084 to
a7c4064
Compare
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Apr 29, 2024
differential rendering (ruby/reline#654) * Add a cut variation of Reline::Unicode.take_range method take_mbchar_range * Consider fullwidth take_range in differential rendering ruby/reline@29714df09f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

When dialog is cleared, we need to restore the text that was hidden behind dialogs.
To implement restoring full width characters hidden behind dialog,
Reline::Unicode.take_rangelacks of feature.It does not provide where to render the string. column information is missing.
Sometimes we need other cut variation depending on adjacent dialog position.

The image below shows a variation of
take_range('一二三四五六七八九', 5, 8, option)So I add
Reline::Unicode.take_mbchar_rangethat has optioncover_begin, cover_end, paddingand make it return the actual cut position.