tools icon indicating copy to clipboard operation
tools copied to clipboard

📎 `init` separators are too long

Open sebmck opened this issue 2 years ago • 5 comments

Description

Can we use the console width to decide how wide to make these?

313774620_1140239643577186_3071873384434397001_n

sebmck avatar Nov 08 '22 15:11 sebmck

I have done some research on how to implement this.

For winodws, windows_sys crate provide GetConsoleScreenBufferInfo method which takes HANDLE

For unix rustix crate provide tcgetwinsize method which takes Fd (File Descriptor)

Here are some of the github repo

  • https://github.com/eminence/terminal-size (best one)
  • https://github.com/softprops/termsize
  • https://github.com/clap-rs/term_size-rs
  • https://github.com/nicokoch/termsize-rs
  • https://github.com/JohnTitor/termize

Assign this issue to me and let me know if you have any suggestions.

dhrjarun avatar Nov 19 '22 11:11 dhrjarun

@DhrjArun FYI we already such logic in our code base, but it's internal to our diagnostics.

https://github.com/rome/tools/blob/main/crates/rome_diagnostics/src/v2/display.rs#L58-L176

An interesting refactor might be to make it a bit generic, so we can use it outside of a diagnostic

ematipico avatar Nov 19 '22 14:11 ematipico

@DhrjArun FYI we already such logic in our code base, but it's internal to our diagnostics.

https://github.com/rome/tools/blob/main/crates/rome_diagnostics/src/v2/display.rs#L58-L176

An interesting refactor might be to make it a bit generic, so we can use it outside of a diagnostic

I would love to do this.

dhrjarun avatar Nov 19 '22 15:11 dhrjarun

@ematipico CountWidth struct counts the width of content in the header. Everytime write_str method is called it takes content and increases its width value.

let's say width is 50, Which will be subtracted from the HEADER_WIDTH which is a hardcoded value of 100 to produce line_width.

but if the console width is less than 100, the horizontal line will overflow like this. Screenshot 2022-11-20 at 16 44 50

That is why we need to know the console width (which is not implemented) to replace the hardcoded 100 with the current console width.

dhrjarun avatar Nov 20 '22 11:11 dhrjarun

👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed, S-Planned , S-Wishlist or umbrella

github-actions[bot] avatar Dec 05 '22 12:12 github-actions[bot]