|
|
|
@@ -391,7 +391,7 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
|
|
|
|
consoleWindow?.windowLevel = UIWindow.Level.statusBar
|
|
|
|
|
consoleWindow?.isHidden = false
|
|
|
|
|
|
|
|
|
|
viewController = ConsoleViewController()
|
|
|
|
|
viewController.view = PassthroughView()
|
|
|
|
|
|
|
|
|
|
consoleWindow?.rootViewController = viewController
|
|
|
|
|
|
|
|
|
@@ -534,10 +534,20 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate {
|
|
|
|
|
|
|
|
|
|
/// Print items to the console view.
|
|
|
|
|
public func print(_ items: Any) {
|
|
|
|
|
if currentText == "" {
|
|
|
|
|
currentText = "\(items)"
|
|
|
|
|
let _currentText: String = {
|
|
|
|
|
if currentText == "" {
|
|
|
|
|
return "\(items)"
|
|
|
|
|
} else {
|
|
|
|
|
return currentText + "\n\(items)"
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
// Cut down string if it exceeds 300,000 characters to keep text view running smoothly.
|
|
|
|
|
if _currentText.count > 300000 {
|
|
|
|
|
let shortenedString = String(_currentText.suffix(300000))
|
|
|
|
|
currentText = shortenedString.stringAfterFirstOccurenceOf(delimiter: "\n") ?? shortenedString
|
|
|
|
|
} else {
|
|
|
|
|
currentText = currentText + "\n\(items)"
|
|
|
|
|
currentText = _currentText
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -995,6 +1005,18 @@ class ConsoleWindow: UIWindow {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Custom view for the console to appear above other windows while passing touches down.
|
|
|
|
|
class PassthroughView: UIView {
|
|
|
|
|
|
|
|
|
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
|
|
|
|
|
|
|
|
if let hitView = super.hitTest(point, with: event) {
|
|
|
|
|
return hitView.isKind(of: PassthroughView.self) ? nil : hitView
|
|
|
|
|
}
|
|
|
|
|
return super.hitTest(point, with: event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import UIKit.UIGestureRecognizerSubclass
|
|
|
|
|
|
|
|
|
@@ -1122,7 +1144,7 @@ class InvertedTextView: UITextView {
|
|
|
|
|
|
|
|
|
|
var pendingOffsetChange = false
|
|
|
|
|
|
|
|
|
|
// Thanks to WWDC21 Lab!
|
|
|
|
|
// Thanks to WWDC21 UIKit Lab!
|
|
|
|
|
override func layoutSubviews() {
|
|
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
|
@@ -1154,6 +1176,14 @@ extension UIDevice {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension String {
|
|
|
|
|
func stringAfterFirstOccurenceOf(delimiter: String) -> String? {
|
|
|
|
|
guard let upperIndex = (self.range(of: delimiter)?.upperBound) else { return nil }
|
|
|
|
|
let trailingString: String = .init(self.suffix(from: upperIndex))
|
|
|
|
|
return trailingString
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension TimeInterval {
|
|
|
|
|
var formattedString: String? {
|
|
|
|
|
let formatter = DateComponentsFormatter()
|
|
|
|
@@ -1168,6 +1198,8 @@ fileprivate func _debugPrint(_ items: Any) {
|
|
|
|
|
|
|
|
|
|
// Support for auto-rotate.
|
|
|
|
|
class ConsoleViewController: UIViewController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
|
|
|
|
|
|
|
|
// Cancel the panner console is being panned to allow for location manipulation.
|
|
|
|
|