mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
[WIP] Message effects
This commit is contained in:
@@ -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] = []
|
||||
|
||||
Reference in New Issue
Block a user