{"id":16895809,"url":"https://github.com/bnorm/patchwork","last_synced_at":"2026-05-20T02:31:42.473Z","repository":{"id":57717926,"uuid":"308338407","full_name":"bnorm/patchwork","owner":"bnorm","description":"A library for generating ANSI patches for updating existing console output","archived":false,"fork":false,"pushed_at":"2020-11-15T15:50:10.000Z","size":300,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-25T10:44:04.189Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnorm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-29T13:33:21.000Z","updated_at":"2020-11-09T02:39:13.000Z","dependencies_parsed_at":"2022-08-24T11:11:08.850Z","dependency_job_id":null,"html_url":"https://github.com/bnorm/patchwork","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/bnorm%2Fpatchwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpatchwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpatchwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnorm%2Fpatchwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnorm","download_url":"https://codeload.github.com/bnorm/patchwork/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244592038,"owners_count":20477834,"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":[],"created_at":"2024-10-13T17:26:22.099Z","updated_at":"2026-05-20T02:31:37.451Z","avatar_url":"https://github.com/bnorm.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# patchwork\n\n[![Maven Central][maven-central-badge]][maven-central-link]\n\nCreate ANSI patches of text strings which can be printed to a console to update\nexisting text. This library supports multiline output which allows for\ncombination with all sorts of text based console output.\n\n## Examples\n\n### Progress Bar\n\nTo display some kind of progress bar in the console as a task is being\nperformed, the following pattern can be used.\n\n```kotlin\nfun progressBarString(progress: Int): String = ...\n\nvar previous: String? = null\nwhile (progress in 1..100) {\n  val next = progressBarString(progress)\n  print(previous.patch(next))\n  previous = next\n}\n```\n\n### Logging With Progress Bar\n\nTo display some kind of progress bar in the console while also logging text,\nyou can use the following pattern.\n\n```kotlin\nfun progressBarString(progress: Int): String = ...\n\nvar previous: String? = null\nwhile (progress in 1..100) {\n  val log = \"... lines you would like logged ...\"\n  val next = progressBarString(progress)\n  print(previous.patch(log + next))\n  previous = next\n}\n```\n\n### Table Progress\n\nTo display more complex messages you can use a library like\n[picnic](https://github.com/JakeWharton/picnic) to generate a user-friendly\ntable which can display progress for multiple things at the same time. See the\nsample project for an [example][picnic-example].\n\n![picnic-example](docs/picnic-example.svg)\n\n## Platforms\n\nSome platforms (Windows) do not natively support ANSI text manipulation. Some\nthird-party libraries like [jansi](https://github.com/fusesource/jansi) can add\nthis support through platform specific APIs.\n\n## What's Next?\n\n- ANSI Colors: ANSI text styling really messes with the diff calculation. Text\n  changes in the middle of styled text will also require tracking the style of\n  both text strings and applying the correct style in the patched text.\n\n[maven-central-badge]: https://maven-badges.herokuapp.com/maven-central/com.bnorm.patchwork/patchwork/badge.svg\n[maven-central-link]: https://maven-badges.herokuapp.com/maven-central/com.bnorm.patchwork/patchwork\n[picnic-example]: https://github.com/bnorm/patchwork/blob/main/sample/src/main/kotlin/main.kt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fpatchwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnorm%2Fpatchwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnorm%2Fpatchwork/lists"}