Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cryptosense/terminal_size
Get the size of the attached terminal in OCaml
https://github.com/cryptosense/terminal_size
ioctl ocaml
Last synced: 3 months ago
JSON representation
Get the size of the attached terminal in OCaml
- Host: GitHub
- URL: https://github.com/cryptosense/terminal_size
- Owner: cryptosense
- License: bsd-2-clause
- Created: 2016-09-06T13:47:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-04-26T15:04:36.000Z (almost 3 years ago)
- Last Synced: 2024-04-20T00:53:15.684Z (10 months ago)
- Topics: ioctl, ocaml
- Language: C
- Size: 58.6 KB
- Stars: 12
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.md
Awesome Lists containing this project
README
# `Terminal_size`
[![Build Status][build_status_badge]][build_status_link]
[![Documentation][doc_badge]][doc_link]## What is it?
You can use this small ocaml library to detect the dimensions of the terminal
window attached to a process. It contains the two following functions:```ocaml
val get_rows : unit -> int option
val get_columns : unit -> int option
```## How does it work?
Usually, to get this information, one would open a pipe from `tput cols` or
`stty size` and parsing the output. Instead, this uses the `ioctl` that these
commands use, `TIOCGWINSZ`.[build_status_badge]: https://github.com/cryptosense/terminal_size/actions/workflows/main.yml/badge.svg
[build_status_link]: https://github.com/cryptosense/terminal_size/actions/workflows/main.yml
[doc_badge]: https://img.shields.io/badge/doc-online-blue.svg
[doc_link]: https://cryptosense.github.io/terminal_size/doc/