Skip to content

sogaiu/janet-termsize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

janet-termsize

A Janet implementation of determining a terminal's size (rows and columns). No C compilation necessary.

Usage

(import termsize :as ts)

(ts/rows-and-cols)
# =>
[24 80]

(ts/rows)
# =>
24

(ts/cols)
# =>
80

Notes

Possibly of interest:

  • The :web "operating system" (emscripten) isn't supported, but various attempts have been made to try to support others including:

    • :bsd - BSD that isn't the other specific ones?
    • :cygwin
    • :dragonfly
    • :freebsd
    • :linux - includes Termux on Android
    • :macos
    • :mingw
    • :netbsd
    • :posix - some UNIXy machine not more specifically recognized?
    • :windows

    Not all have been tested though. Please report if something isn't working :)

  • Tries to use FFI where practical (ATM, only x86_64 + some operating systems)

  • Falls back to external process methods (stty for Unixy systems and powershell for Windows)

  • The function rows-and-cols hands things off to various helper functions such as via-ioctl, via-winapi, or via-shell. These are exposed but no particular effort may be made to keep them the same (or around) over time [1].

  • When implementing FFI-related bits for Windows, it was helpful to examine this page to figure out what things like DWORD, HANDLE, etc. are under the covers. Once the underlying types were understood, this table was used to determine a target keyword. As an example, consider DWORD. According to the page at MS, it is:

    > A 32-bit unsigned integer. The range is 0 through 4294967295
    > decimal.
    

    So taking that to mean uint32_t, according to the "primitive types" table, that could be either :uint32 or :u32 (both probably work).


[1] The author doesn't find making things private to be worth all of the extra work that often seems to lead to (e.g. testing and investigation typically become more cumbersome).

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages