[WIP] Message effects

This commit is contained in:
Isaac
2024-05-10 20:57:12 +04:00
parent fe8c2d8c15
commit 7ef63a81df
43 changed files with 3050 additions and 704 deletions

View File

@@ -312,6 +312,10 @@ public final class ChatInputTextView: ChatInputTextViewImpl, UITextViewDelegate,
}
}
public var currentRightInset: CGFloat {
return self.customTextContainer.rightInset
}
private var didInitializePrimaryInputLanguage: Bool = false
public var initialPrimaryLanguage: String?
@@ -656,6 +660,45 @@ public final class ChatInputTextView: ChatInputTextViewImpl, UITextViewDelegate,
self.isUpdatingLayout = false
}
public func currentTextBoundingRect() -> CGRect {
let glyphRange = self.customLayoutManager.glyphRange(forCharacterRange: NSRange(location: 0, length: self.textStorage.length), actualCharacterRange: nil)
var boundingRect = CGRect()
var startIndex = glyphRange.lowerBound
while startIndex < glyphRange.upperBound {
var effectiveRange = NSRange(location: NSNotFound, length: 0)
let rect = self.customLayoutManager.lineFragmentUsedRect(forGlyphAt: startIndex, effectiveRange: &effectiveRange)
if boundingRect.isEmpty {
boundingRect = rect
} else {
boundingRect = boundingRect.union(rect)
}
if effectiveRange.location != NSNotFound {
startIndex = max(startIndex + 1, effectiveRange.upperBound)
} else {
break
}
}
return boundingRect
}
public func lastLineBoundingRect() -> CGRect {
let glyphRange = self.customLayoutManager.glyphRange(forCharacterRange: NSRange(location: 0, length: self.textStorage.length), actualCharacterRange: nil)
var boundingRect = CGRect()
var startIndex = glyphRange.lowerBound
while startIndex < glyphRange.upperBound {
var effectiveRange = NSRange(location: NSNotFound, length: 0)
let rect = self.customLayoutManager.lineFragmentUsedRect(forGlyphAt: startIndex, effectiveRange: &effectiveRange)
boundingRect = rect
if effectiveRange.location != NSNotFound {
startIndex = max(startIndex + 1, effectiveRange.upperBound)
} else {
break
}
}
return boundingRect
}
public func updateTextElements() {
var blockQuoteIndex = 0
var validBlockQuotes: [Int] = []