{"id":24285858,"url":"https://github.com/alexarchambault/native-terminal","last_synced_at":"2025-09-25T07:31:17.309Z","repository":{"id":39967992,"uuid":"236767068","full_name":"alexarchambault/native-terminal","owner":"alexarchambault","description":"Small Java library to setup / interact with a Windows terminal","archived":false,"fork":false,"pushed_at":"2025-04-01T14:18:02.000Z","size":109,"stargazers_count":5,"open_issues_count":9,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-01T14:21:43.731Z","etag":null,"topics":["jansi","windows","windows-10","windows-command-line"],"latest_commit_sha":null,"homepage":"","language":"Java","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/alexarchambault.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-28T15:21:58.000Z","updated_at":"2025-04-01T14:09:37.000Z","dependencies_parsed_at":"2024-12-17T22:33:45.459Z","dependency_job_id":"e07f6255-fd10-4511-aae8-1d9ba4e6f352","html_url":"https://github.com/alexarchambault/native-terminal","commit_stats":{"total_commits":76,"total_committers":5,"mean_commits":15.2,"dds":0.5526315789473684,"last_synced_commit":"6218565cd81b0bae550c975d39c03159af0955b1"},"previous_names":["alexarchambault/native-terminal","alexarchambault/windows-ansi"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/alexarchambault/native-terminal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexarchambault%2Fnative-terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexarchambault%2Fnative-terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexarchambault%2Fnative-terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexarchambault%2Fnative-terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexarchambault","download_url":"https://codeload.github.com/alexarchambault/native-terminal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexarchambault%2Fnative-terminal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276881827,"owners_count":25721413,"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","status":"online","status_checked_at":"2025-09-25T02:00:09.612Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["jansi","windows","windows-10","windows-command-line"],"created_at":"2025-01-16T07:09:52.197Z","updated_at":"2025-09-25T07:31:17.297Z","avatar_url":"https://github.com/alexarchambault.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# native-terminal\n\n[![Build status](https://github.com/alexarchambault/native-terminal/workflows/CI/badge.svg)](https://github.com/alexarchambault/native-terminal/actions?query=workflow%3ACI)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.alexarchambault.native-terminal/native-terminal.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.alexarchambault.native-terminal/native-terminal)\n\n*native-terminal* is a small Java library to setup / interact with terminals in a native fashion. It allows to\n- query the terminal size, and\n- on Windows, change the console mode so that it accepts ANSI escape codes.\n\nIt relies on internals of the [jline-native](https://github.com/jline/jline3/tree/master/native) library to do so, and also works from\nGraalVM native images.\n\nCompared to using [jline](https://github.com/jline/jline3), *native-terminal* only and solely calls the right\n`ioctl` system calls\n(or `kernel32.dll` system calls, like [`SetConsoleMode`](https://docs.microsoft.com/en-us/windows/console/setconsolemode)\nor [`GetConsoleScreenBufferInfo`](https://docs.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo), on Windows),\nlowering the odds of something going wrong when generating or using a GraalVM native image for example.\n\n## Usage\n\nAdd to your `build.sbt`\n```scala\nlibraryDependencies += \"io.github.alexarchambault.native-terminal\" % \"native-terminal\" % \"0.0.7\"\n```\n\nThe latest version is [![Maven Central](https://img.shields.io/maven-central/v/io.github.alexarchambault.native-terminal/native-terminal.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.alexarchambault.native-terminal/native-terminal).\n\n### Change terminal mode\n\nChange the terminal mode on Windows, so that it accepts ANSI escape codes with\n```java\nimport io.github.alexarchambault.nativeterm.NativeTerminal;\n\nboolean success = NativeTerminal.setupAnsi();\n```\n\nA returned value of `false` means ANSI escape codes aren't supported by the Windows version you're running on.\nThese are supposed to be supported by Windows 10 build 10586 (Nov. 2015) onwards.\n\nCalling this method is safe on other platforms. It simply returns true in that case.\n\n### Get terminal size\n\n```java\nimport io.github.alexarchambault.nativeterm.NativeTerminal;\nimport io.github.alexarchambault.nativeterm.TerminalSize;\n\nTerminalSize size = NativeTerminal.getSize();\nint width = size.getWidth();\nint height = size.getHeight();\n```\n\nIf you call this method often, on Unix-es, you might want to use `TerminalSizeCache` instead.\n\n```java\nimport io.github.alexarchambault.nativeterm.TerminalSize;\nimport io.github.alexarchambault.nativeterm.TerminalSizeCache;\n\nTerminalSize size = TerminalSizeCache.size();\nint width = size.getWidth();\nint height = size.getHeight();\n```\n\nOn Unix-es, `TerminalSizeCache` registers a handler for the WINCH signal, that invalidates\nthe cached terminal size. That way, the terminal size is queried only when the terminal size\nchanges, or if it's not cached yet (or the cached value has been invalidated).\nIf the terminal size didn't change, the cached value is returned, and no unnecessary system call\nquerying the terminal size is made.\n\nOn Windows, this class just calls `NativeTerminal.size()` upon every call to\n`TerminalSizeCache.size()`.\n\n## License\n\nAll files in this repository, except `NativeImageFeature.java`, can be used either under the\nApache 2.0 license, or the GNU GPL version 2 license, at your convenience.\n\nThe `NativeImageFeature.java` file, originally based on a GNU GPL version 2 only file, is licensed only\nunder the GNU GPL version 2 license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexarchambault%2Fnative-terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexarchambault%2Fnative-terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexarchambault%2Fnative-terminal/lists"}