react-slate icon indicating copy to clipboard operation
react-slate copied to clipboard

Getting width and height of viewport?

Open ThariqS opened this issue 7 years ago • 2 comments

If I want to create a line that crosses the entire width of the terminal or fill half of the lines of the terminal with logs, I have no way (from what I can find) of finding the overall width/height of the console. Is there a way, if not, can it the width/height be passed down as props to the top level component?

ThariqS avatar Mar 02 '19 17:03 ThariqS

Doesn't process.stdout.columns and process.stdout.rows work for you? process.stdout is a TTY stream so you should be able to get width (columns) and height (rows) of the terminal (https://nodejs.org/api/tty.html)

zamotany avatar Mar 03 '19 13:03 zamotany

ah I didn't know that was a thing, thank you. It might be useful to have as a wrapper or documented somewhere?

ThariqS avatar Mar 03 '19 15:03 ThariqS