mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-29 21:46:11 +03:00
takeColumns: take even zero-width characters as long as possible
This change makes it so that takeColumns (which is used by 'str' to account for the widths of Unicode characters) will continue taking characters that do not exhaust the allowed width, meaning that it will now take zero-width characters. Previously it stopped taking characters as soon as it exhausted the allowed width and that meant it would ignore zero-width characters following that point.
This commit is contained in:
parent
8b5021ff4e
commit
9ab39545a2
@ -236,11 +236,9 @@ takeColumns :: Int -> String -> String
|
||||
takeColumns _ "" = ""
|
||||
takeColumns numCols (c:cs) =
|
||||
let w = V.safeWcwidth c
|
||||
in if w == numCols
|
||||
then [c]
|
||||
else if w < numCols
|
||||
then c : takeColumns (numCols - w) cs
|
||||
else ""
|
||||
in if w > numCols
|
||||
then []
|
||||
else c : takeColumns (numCols - w) cs
|
||||
|
||||
-- | Make a widget from a string, but wrap the words in the input's
|
||||
-- lines at the available width using the default wrapping settings. The
|
||||
|
Loading…
Reference in New Issue
Block a user