{"id":15395009,"url":"https://github.com/goto-bus-stop/ansi-scrollbox","last_synced_at":"2025-06-25T06:02:57.103Z","repository":{"id":31875020,"uuid":"130056966","full_name":"goto-bus-stop/ansi-scrollbox","owner":"goto-bus-stop","description":"a basic scrollable area for terminal apps","archived":false,"fork":false,"pushed_at":"2023-01-24T04:03:07.000Z","size":22,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-16T21:18:24.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goto-bus-stop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-18T12:13:14.000Z","updated_at":"2023-03-04T06:34:36.000Z","dependencies_parsed_at":"2023-02-13T16:35:38.545Z","dependency_job_id":null,"html_url":"https://github.com/goto-bus-stop/ansi-scrollbox","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/goto-bus-stop/ansi-scrollbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fansi-scrollbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fansi-scrollbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fansi-scrollbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fansi-scrollbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goto-bus-stop","download_url":"https://codeload.github.com/goto-bus-stop/ansi-scrollbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fansi-scrollbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261816053,"owners_count":23213840,"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-01T15:25:20.118Z","updated_at":"2025-06-25T06:02:57.087Z","avatar_url":"https://github.com/goto-bus-stop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansi-scrollbox\n\na basic scrollable area for terminal apps\n\n[![npm][npm-image]][npm-url]\n[![travis][travis-image]][travis-url]\n[![standard][standard-image]][standard-url]\n\n[npm-image]: https://img.shields.io/npm/v/ansi-scrollbox.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/ansi-scrollbox\n[travis-image]: https://img.shields.io/travis/goto-bus-stop/ansi-scrollbox.svg?style=flat-square\n[travis-url]: https://travis-ci.org/goto-bus-stop/ansi-scrollbox\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: http://npm.im/standard\n\n## Install\n\n```\nnpm install ansi-scrollbox\n```\n\n## Usage\n\n```js\nvar scrollbox = require('ansi-scrollbox')\nvar differ = require('ansi-diff')()\nvar lorem = require('@jamen/lorem')\n\nvar box = scrollbox({\n  width: 20,\n  height: 20\n})\n\nbox.setContent(lorem(6000))\n\nfunction render () {\n  process.stdout.write(differ.update(box.toString()))\n}\nsetInterval(render, 100)\n\nrequire('keypress')(process.stdin)\nprocess.stdin.setRawMode(true)\nprocess.stdin.resume()\n// Optionally add default scroll keybindings (things like up, down, home, end)\nprocess.stdin.on('keypress', box.keypress)\n```\n\n## API\n\n### `box = scrollbox(opts={})`\n\nPrepare a new scrollbox.\n\n- `opts.width` - Width in columns of the scrollbox.\n- `opts.height` - Height in rows of the scrollbox.\n\n### `box.setContent(content)`, `box.content = content`\n\nSet the content of the scrollbox.\n\n### `box.content`\n\nGet the content of the scrollbox.\n\n### `box.scroll(offset)`\n\nSet the scroll position. `offset` is the number of rows from the start of the content. When `offset` is negative, it's the number of rows from the end of the content. Use -1 to scroll to the very end; -1 is \"sticky\" so it will stay at the end when the content updates.\n\n### `box.resize(opts)`\n\nUpdate the size of the scrollbox.\n\n- `opts.width` - Width in columns of the scrollbox.\n- `opts.height` - Height in rows of the scrollbox.\n\n### `box.toString()`\n\nGet the visible contents of the box. Use with something like [ansi-diff](https://github.com/mafintosh/ansi-diff) for efficient updates on screene.\n\n### `unsub = box.subscribe(listener)`\n\nCall `listener` whenever the box's content, size, or scroll position change. Do `unsub()` to stop listening.\n\n### `box.keypress`\n\nAn event listener that implements basic keyboard controls:\n\n- `up` or `k` to scroll 1 row up\n- `down` or `j` to scroll 1 row down\n- `home` to scroll to the start\n- `end` to scroll to the start\n\nUse it with the [keypress](https://github.com/TooTallNate/keypress) module:\n\n```js\nrequire('keypress')(process.stdin)\nprocess.stdin.on('keypress', box.keypress)\n```\n\n## License\n\n[Apache-2.0](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fansi-scrollbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoto-bus-stop%2Fansi-scrollbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fansi-scrollbox/lists"}