{"id":18031769,"url":"https://github.com/dagronf/dsfmaxlengthdisplaytextfield","last_synced_at":"2025-03-27T05:30:58.546Z","repository":{"id":149491843,"uuid":"504468022","full_name":"dagronf/DSFMaxLengthDisplayTextField","owner":"dagronf","description":"An `NSTextField` that specifies a maximum count after which text is highlighted to indicate an overflow","archived":false,"fork":false,"pushed_at":"2022-08-24T09:52:51.000Z","size":203,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T04:31:40.684Z","etag":null,"topics":["macos","maxlength","nstextfield","twitter"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dagronf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-17T09:14:19.000Z","updated_at":"2023-12-05T05:55:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa992a0d-4aa7-406a-99d7-d13ace1cbe4f","html_url":"https://github.com/dagronf/DSFMaxLengthDisplayTextField","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFMaxLengthDisplayTextField","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFMaxLengthDisplayTextField/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFMaxLengthDisplayTextField/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FDSFMaxLengthDisplayTextField/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/DSFMaxLengthDisplayTextField/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791341,"owners_count":20672665,"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":["macos","maxlength","nstextfield","twitter"],"created_at":"2024-10-30T10:10:43.467Z","updated_at":"2025-03-27T05:30:58.533Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DSFMaxLengthDisplayTextField\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/dagronf/DSFMaxLengthDisplayTextField\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/macOS-10.11+-red\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-lightgrey\" /\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\nAn `NSTextField` that specifies a maximum count after which text is highlighted to indicate an overflow\n\n![animated demo](./screenshots/primary.gif)\n\n![Multiline](./screenshots/secondary.png)\n\n## Why?\n\nI always liked the Twitter approach for indicating that text was oversized - it allows you to easily curate your content appropriately to fit the available size.\n\n## API\n\nThis control uses the concept of a \"grapheme cluster\" for its character count - this means that emojis/complex characters represent a single character within the string\n\nFor example, the string `a=🧖🏼‍♀️, b=💆‍♂️, c=🙆🏾` represents 13 characters\n\n| 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  | 10 | 11 | 12 | 13 |\n|----|----|----|----|----|----|----|----|----|----|----|----|----|\n| a | = | 🧖🏼‍♀️ | , |   | b | = | 💆‍♂️ | , |   | c | = | 🙆🏾 |\n\n\u003c!-- **Note:** In UTF8, this length is 48, UTF16 the length is 26 --\u003e\n\n### Settable properties\n\n| Property                      | Type      | Description                                           |\n|-------------------------------|-----------|-------------------------------------------------------|\n| `maxCharacters`               | `Int`     | The maximum number of characters allowed              |\n| `overflowTextColor`           | `NSColor` | The color to use for 'overflow' characters            |\n| `overflowTextBackgroundColor` | `NSColor` | The background color to use for 'overflow' characters |\n| `underlineOverflowCharacters` | `Bool`    | Whether to underline overflow characters              |\n\n### Observable properties\n\nThese properties are KVO observable.\n\n| Property                      | Type   | Description                                               |\n|-------------------------------|--------|-----------------------------------------------------------|\n| `isValid`                     | `Bool` | Does the text fit within the maximum characters specified |\n| `characterCount`              | `Int`  | Total character count                                     |\n| `charactersAvailable`         | `Int`  | The number of characters available before overflow occurs |\n| `overflowCharacterCount`      | `Int`  | The number of overflow characters                         |\n\n### Callbacks\n\n| Parameter                  | Type             | Description                        |\n|----------------------------|------------------|------------------------------------|\n| `contentChangedCallback`   | `() -\u003e Void`     | Called when the content changes    |\n| `isValidChangedCallback`   | `(Bool) -\u003e Void` | Called when the validity changes   |\n\n### Combine (macOS 10.15+)\n\n| Parameter            | Description                                      |\n|----------------------|--------------------------------------------------|\n| `validityPublisher`  | Publishes when the validity of the field changes |\n\n\u003cdetails\u003e\n\u003csummary\u003eCombine Example Usage\u003c/summary\u003e\n\n```swift\n@IBOutlet weak var titleField: DSFMaxLengthDisplayTextField!\n...\ntitleField.validityPublisher\n   .removeDuplicates()\n   .sink { newValue in\n      Swift.print(\"Title Validity changed: \\(newValue)\")\n   }\n```\n\n\u003c/details\u003e\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2022 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfmaxlengthdisplaytextfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fdsfmaxlengthdisplaytextfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fdsfmaxlengthdisplaytextfield/lists"}