Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support terminal handling of columns #19

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Support terminal handling of columns #19

merged 1 commit into from
Jul 17, 2024

Conversation

ianthomas23
Copy link
Member

This PR adds support for correct terminal handling of number of columns, set using Shell.setSize. An example of a command that uses this is ls, which by default writes the file and directory list in a number of columns that fit in the terminal width.

The terminal size is stored as environment variables LINES and COLUMNS. These can be checked using the commands env or stty size.

In terms of implementation, if stdin is not specified when loading the JS/WASM command file then stdin is a valid TTY. To get this to work as we desire two functions are monkey-patched, one which returns the window size (otherwise hard-coded as 24x80) and the other is the get_char function by which we pass in stdin characters one at a time.

I have modified both coreutils.js and grep.js to export TTY as this is needed for the monkey-patching. This change will have to be repeated in the emscripten forge recipes.

There is no coloured terminal output yet.

@ianthomas23 ianthomas23 added the enhancement New feature or request label Jul 16, 2024
@ianthomas23 ianthomas23 merged commit d2b8686 into main Jul 17, 2024
4 checks passed
@ianthomas23 ianthomas23 deleted the terminal_columns branch July 17, 2024 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant