brunogama/boxed
Just some joke that is gone too far. It draws boxes around strings. If your xcode console is too crowded it might be useful
Features
- Create ASCII-style boxes around text
- Create emoji-style boxes for a more playful look
- Support for multi-line content
- Optional centered first line
- Customizable box width
- Smart width calculation based on content
- Proper handling of visual string lengths
- Customizable box styles
Installation
Swift Package Manager
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/yourusername/Boxed.git", from: "1.0.0")
]Usage
Basic ASCII Box
import Boxed
Boxed.ascii("Hello, World!")Output:
┌──────────────────────┐
│ │
│ Hello, World! │
│ │
└──────────────────────┘Emoji Box
import Boxed
Boxed.emoji("Welcome!\nTo my app")Output:
🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦
⬜️ ⬜️
⬜️ Welcome! ⬜️
⬜️ To my app ⬜️
⬜️ ⬜️
🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦Customization Options
Boxed.ascii(
"Custom Width Example",
width: 40,
centerFirstLine: true
)
Boxed.emoji(
"Multiple\nLines\nOf\nText",
width: 30,
centerFirstLine: false
)API Reference
ASCII Box
public static func ascii(
_ message: String,
width: Int = 120,
centerFirstLine: Bool = true,
boxStyle: BoxCharactersProvider = BoxStyle.ascii
)Emoji Box
public static func emoji(
_ message: String,
width: Int = 120,
centerFirstLine: Bool = true,
boxStyle: BoxCharactersProvider = BoxStyle.ascii
)Parameters
message: The text content to be boxed (supports multiple lines using \n)width: The minimum width of the box (default: 120)centerFirstLine: Whether to center the first line of text (default: true)boxStyle: The style provider for box characters (default: BoxStyle.ascii)
Custom Box Styles
You can create custom box styles by implementing the BoxCharactersProvider protocol:
public protocol BoxCharactersProvider {
var topLeft: Character { get }
var topRight: Character { get }
var bottomLeft: Character { get }
var bottomRight: Character { get }
var horizontal: Character { get }
var vertical: Character { get }
}Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Package Metadata
Repository: brunogama/boxed
Stars: 0
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
README: README.md