Files
ghostgram/submodules/TextFormat/Sources/StringPadding.swift
T
ichmagmaus111andClaude Opus 5.5 0622057a4f Ghostgram: open-source release
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 17:57:09 +01:00

18 lines
587 B
Swift

import Foundation
public extension String {
func rightJustified(width: Int, pad: String = " ", truncate: Bool = false) -> String {
guard width > count else {
return truncate ? String(suffix(width)) : self
}
return String(repeating: pad, count: width - count) + self
}
func leftJustified(width: Int, pad: String = " ", truncate: Bool = false) -> String {
guard width > count else {
return truncate ? String(prefix(width)) : self
}
return self + String(repeating: pad, count: width - count)
}
}