{"id":18535503,"url":"https://github.com/soulverteam/soulvertextkit","last_synced_at":"2025-04-09T15:32:29.107Z","repository":{"id":63920549,"uuid":"337135204","full_name":"soulverteam/SoulverTextKit","owner":"soulverteam","description":"Turn your standard NSTextView or UITextView into a Soulver-like notepad calculator","archived":false,"fork":false,"pushed_at":"2021-02-08T16:45:32.000Z","size":2082,"stargazers_count":52,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T06:51:54.811Z","etag":null,"topics":["notepad-calculator","nstextview","soulver","swift","uitextview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulverteam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-08T16:21:07.000Z","updated_at":"2025-04-03T08:04:26.000Z","dependencies_parsed_at":"2023-01-14T14:00:20.572Z","dependency_job_id":null,"html_url":"https://github.com/soulverteam/SoulverTextKit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulverteam%2FSoulverTextKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulverteam%2FSoulverTextKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulverteam%2FSoulverTextKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulverteam%2FSoulverTextKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulverteam","download_url":"https://codeload.github.com/soulverteam/SoulverTextKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248058143,"owners_count":21040704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notepad-calculator","nstextview","soulver","swift","uitextview"],"created_at":"2024-11-06T19:24:44.602Z","updated_at":"2025-04-09T15:32:29.090Z","avatar_url":"https://github.com/soulverteam.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SoulverTextKit\n\n![Swift 5.3](https://img.shields.io/badge/Swift-5.3-blue.svg?style=flat)\n![Platform](https://img.shields.io/badge/platform-macOS-lightgrey.svg?style=flat)\n![Platform](https://img.shields.io/badge/platform-iOS-lightgrey.svg?style=flat)\n\nSoulverTextKit lets you add a line-by-line calculation feature to any NSTextView or UITextView. It uses [SoulverCore](https://soulver.app/core) for number crunching, which also provides unit conversions, date \u0026 times calculations, and more.\n\n\u003cimg src=\"Images/Example.gif\" width=\"558\"\u003e\n\n## Requirements\n\n- Xcode 11+\n- Swift 5+\n\n## Supported Platforms\n\n- macOS 10.14.4+\n- iOS/iPadOS 13+\n\n## Installation\n\nSoulverTextKit is distributed using the [Swift Package Manager](https://swift.org/package-manager). To install it into a project, simply add it as a dependency within your `Package.swift` manifest:\n\n```swift\nlet package = Package(\n    ...\n    dependencies: [\n        .package(url: \"https://github.com/soulverteam/SoulverTextKit.git\", from: \"0.0.1\")\n    ],\n    ...\n)\n```\n\n[Or add the package in Xcode.](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)\n\n## Usage\n\nThere are 3 steps to integrate SoulverTextKit in your project. Examples for both NSTextView \u0026 UITextView are provided in this repository. \n\n###  Step 1\n#### Import SoulverTextKit in your text view delegate\n\n```swift\nimport SoulverTextKit\n```\n### Step 2\n#### Create an instance variable of ParagraphCalculator and initialize it with your TextView's NSTextStorage and NSTextContainer:\n\n```swift\n\n    @IBOutlet var textView: NSTextView!\n    var paragraphCalculator: SoulverTextKit.ParagraphCalculator!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        self.paragraphCalculator = ParagraphCalculator(answerPosition: .afterEquals, textStorage: self.textView.textStorage, textContainer: self.textView.textContainer)\n    }\n\n```\n\n### Step 3\n#### Implement NS/UITextView textDidChange and NSLayoutManager didChangeGeometry delegate methods\n\n```swift\n\n    func textDidChange(_ notification: Notification) {\n        \n        // Let us know when the text changes, so we can evaluate any changed lines if necessary\n        paragraphCalculator.textDidChange()\n    }\n\t\t\n    func layoutManager(_ layoutManager: NSLayoutManager, textContainer: NSTextContainer, didChangeGeometryFrom oldSize: NSSize) {\n\n        // Let us know when the text view changes size, so we can change update the formatting if necessary\n        paragraphCalculator.layoutDidChange()\n    }\n```\n\n### Step 4 (optional)\n#### Prevent the user editing the result of a paragraph\n\n```swift\n    func textView(_ textView: NSTextView, shouldChangeTextIn affectedCharRange: NSRange, replacementString: String?) -\u003e Bool {\n\n        // Check with us to see if the user should be able to edit parts of the paragraph.        \n        switch paragraphCalculator.shouldAllowReplacementFor(affectedCharRange: affectedCharRange, replacementString: replacementString) {\n        case .allow:\n            return true\n        case .deny:\n            NSSound.beep()\n            return false\n        case .setIntertionPoint(range: let range):\n            textView.setSelectedRange(range)\n            return false\n        }\n        \n    }\n```\n\n\n## Styles\n\nThere are 3 built-in styles for calculation paragraphs: `afterTab`, `afterPipe` and `afterEquals`. Choose your preferred style when creating the `ParagraphCalculator`.\n\n#### After Tab\n\n\u003cimg src=\"Images/AfterTab.png\" width=\"582\"\u003e\n\n#### After Pipe\n\n\u003cimg src=\"Images/AfterPipe.png\" width=\"582\"\u003e\n\n#### After Equals\n\n\u003cimg src=\"Images/AfterEquals.png\" width=\"585\"\u003e\n\n## License\n\nCopyright (c) 2021 Zac Cohan. \nSoulverTextKit is distributed under the MIT License. \nThe use of the [SoulverCore](https://soulver.app/core) math engine in commercial software requires a special license. You can also modify ParagraphCalculator to use another math engine like [Math.js](https://github.com/josdejong/mathjs) or [Expression](https://github.com/nicklockwood/Expression).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulverteam%2Fsoulvertextkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulverteam%2Fsoulvertextkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulverteam%2Fsoulvertextkit/lists"}