Skip to content

Add command to get terminal size #13

@noelwelsh

Description

@noelwelsh

Add command (effect, program, documentation) to get the current terminal size.

It looks like the size can be obtained with the command CSI18t, but it's not clear this is widely supported. If it's not widely supported, the next step is to use the ioctl C API.

See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html and search for XTWINOPS for the escape code to get the terminal size (we're interested in getting it in characters; pixels doesn't seem as useful).

For example of C code using ioctl see https://rosettacode.org/wiki/Terminal_control/Dimensions#Library:_BSD_libc

Crossterm code, which is a bit more complicated, is at https://github.com/crossterm-rs/crossterm/blob/e104a7cb400910609cdde36f322e3905c4baa805/src/terminal/sys/unix.rs#L59

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions