Various improvements

This commit is contained in:
Ali
2023-04-14 18:59:33 +04:00
parent 014ee47a95
commit cfe7f43e0d
33 changed files with 430 additions and 85 deletions

View File

@@ -414,11 +414,13 @@ public func foldLineBreaks(_ text: String) -> String {
public func foldLineBreaks(_ text: NSAttributedString) -> NSAttributedString {
let remainingString = NSMutableAttributedString(attributedString: text)
var lines: [NSAttributedString] = []
while true {
if let range = remainingString.string.range(of: "\n") {
let mappedRange = NSRange(range, in: remainingString.string)
lines.append(remainingString.attributedSubstring(from: NSRange(location: 0, length: mappedRange.upperBound - 1)))
let restString = remainingString.attributedSubstring(from: NSRange(location: 0, length: mappedRange.upperBound - 1))
lines.append(restString)
remainingString.replaceCharacters(in: NSRange(location: 0, length: mappedRange.upperBound), with: "")
} else {
if lines.isEmpty {