{"id":19032713,"url":"https://github.com/joutvhu/control-terminal","last_synced_at":"2025-04-23T16:41:21.651Z","repository":{"id":52709087,"uuid":"359430154","full_name":"joutvhu/control-terminal","owner":"joutvhu","description":"Control terminal cursor, screen and create string styling","archived":false,"fork":false,"pushed_at":"2023-07-28T07:03:24.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T03:57:17.883Z","etag":null,"topics":["color","console","cursor","logging","styling","terminal"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/joutvhu.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-04-19T11:12:16.000Z","updated_at":"2023-07-28T07:03:28.000Z","dependencies_parsed_at":"2022-09-08T14:22:20.616Z","dependency_job_id":null,"html_url":"https://github.com/joutvhu/control-terminal","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/joutvhu%2Fcontrol-terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joutvhu%2Fcontrol-terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joutvhu%2Fcontrol-terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joutvhu%2Fcontrol-terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joutvhu","download_url":"https://codeload.github.com/joutvhu/control-terminal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250472030,"owners_count":21436068,"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":["color","console","cursor","logging","styling","terminal"],"created_at":"2024-11-08T21:30:40.226Z","updated_at":"2025-04-23T16:41:21.635Z","avatar_url":"https://github.com/joutvhu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Control Terminal\n\n- Control terminal cursor\n- Terminal string styling\n\n## Installation\n\nInstall using `pnpm`:\n\n```shell\npnpm add control-terminal\n```\n\nOr `yarn`:\n\n```shell\nyarn add control-terminal\n```\n\nOr `npm`:\n\n```shell\nnpm i control-terminal\n```\n\n## Usage\n\n```typescript\nimport * as terminal from 'control-terminal';\n\nconsole.log(terminal.style.bold.blue('Hello world!'));\nconsole.log(terminal.style.bgBlue.hex('#ff7b72')('Blue backgroud'));\n\nterminal.cursor.erasePreviousLine();\n\nconsole.log(terminal.style.bgRgb(255, 123, 114).underline('Underline'));\n```\n\nOutput:\n\n![example-log](doc/media/example-log.png)\n\n## Cursor\n\nThe methods in `terminal.cursor` namespace will help you control cursor and terminal.\n\nMoving cursor methods:\n\n- `goTo(line: number, column: number)`: Move the cursor to a specific position (line \u003e= 1, column \u003e= 1)\n- `gotoStart()`: Move the cursor to line 1, column 1\n- `carriageReturn()`: Move the cursor to start of line\n- `up(line: number = 1)`: Move the cursor up `line` lines\n- `down(line: number = 1)`: Move the cursor down `line` lines\n- `forward(column: number = 1)`: Move the cursor forward `column` columns\n- `backward(column: number = 1)`: Move the cursor backward `column` columns\n- `previousLine()`: Move the cursor up 1 line, column 1\n\nClear screen methods:\n\n- `clearScreen()`: Clear the screen\n- `reset()`: Reset device\n- `eraseToEndLine()`: Erase to the end of line that begins the cursor's current position\n- `eraseToEndScreen()`: Erase to the end of screen that begins the cursor's current position\n- `eraseCurrentLine()`: Erase the current line of the cursor\n  ```js\n  // Two these are equivalent.\n  terminal.cursor.eraseCurrentLine();\n  terminal.cursor.carriageReturn().eraseToEndLine();\n  ```\n- `erasePreviousLine(line: number = 1)`: Erase the previous line from the cursor\n  ```js\n  // Two these are equivalent.\n  terminal.cursor.erasePreviousLine(line);\n  terminal.cursor.up(line).eraseCurrentLine();\n  ```\n\nOther methods:\n\n- `hide()`: Hide cursor\n- `save()`: Save cursor position\n- `restore()`: Restore cursor position\n\n## Styles\n\nThe `terminal.style` namespace will help you string styling.\n\nModifiers:\n\n- `reset`: Resets the current color chain.\n- `bold`: Make text bold.\n- `dim`: Emitting only a small amount of light.\n- `italic`: Make text italic. _(Not widely supported)_\n- `underline`: Make text underline. _(Not widely supported)_\n- `slowBlink`: Make text slow blink. _(Not widely supported)_\n- `rapidBlink`: Make text rapid blink. _(Not widely supported)_\n- `inverse`: Inverse background and foreground colors.\n- `hidden`: Prints the text, but makes it invisible.\n- `strikethrough`: Puts a horizontal line through the center of the text. (Not widely supported)\n- `fraktur`: Make text fraktur. _(Not widely supported)_\n- `framed`: Make text framed. _(Not widely supported)_\n- `encircled`: Make text encircled. _(Not widely supported)_\n- `overline`: Make text overline. _(Not widely supported)_\n\nColors:\n\n- `black`\n- `red`\n- `green`\n- `yellow`\n- `blue`\n- `magenta`\n- `cyan`\n- `white`\n- `blackBright`\n- `redBright`\n- `greenBright`\n- `yellowBright`\n- `blueBright`\n- `magentaBright`\n- `cyanBright`\n- `whiteBright`\n\nBackground colors:\n\n- `bgBlack`\n- `bgRed`\n- `bgGreen`\n- `bgYellow`\n- `bgBlue`\n- `bgMagenta`\n- `bgCyan`\n- `bgWhite`\n- `bgBlackBright`\n- `bgRedBright`\n- `bgGreenBright`\n- `bgYellowBright`\n- `bgBlueBright`\n- `bgMagentaBright`\n- `bgCyanBright`\n- `bgWhiteBright`\n\nExample:\n\n```js\nconsole.log(terminal.style.bold.bgCyan.green('Hello'));\n\nconsole.log(terminal.style.italic.bgBlack.white.underline('Hello'));\n\nconsole.log(terminal.style.white.inverse.bgMagentaBright('Hello'));\n```\n\n### Support 256 color and True color\n\nControl Terminal support 256 colors and True color (16 million colors) on terminal applications.\n\nThe following color models can be used:\n\n256 colors:\n\n- `ansi256(code: number)`\n\n```js\nterminal.style.ansi256(12)('Blue text');\n```\n\n- `bgAnsi256(code: number)`\n\n```js\nterminal.style.bgAnsi256(12)('Blue background');\n```\n\nRGB:\n\n- `rgb(red: number, green: number, blue: number)`\n\n```js\nterminal.style.rgb(88, 166, 255)('Blue text');\n```\n\n- `bgRgb(red: number, green: number, blue: number)`\n\n```js\nterminal.style.bgRgb(88, 166, 255)('Blue background');\n```\n\nHex:\n\n- `hex(hex: string)`\n\n```js\nterminal.style.hex('#58a6ff')('Blue text');\n```\n\n- `bgHex(hex: string)`\n\n```js\nterminal.style.bgHex('#58a6ff')('Blue background');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoutvhu%2Fcontrol-terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoutvhu%2Fcontrol-terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoutvhu%2Fcontrol-terminal/lists"}