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

detecting cell size #26

Closed
iambumblehead opened this issue Mar 10, 2024 · 5 comments
Closed

detecting cell size #26

iambumblehead opened this issue Mar 10, 2024 · 5 comments

Comments

@iambumblehead
Copy link
Owner

iambumblehead commented Mar 10, 2024

per vifm/vifm#419 (comment)

not sure about doing it from a bash script, but cell dimentions could be determined from terminal window resolution and number of its lines and columns

google-searching shows that this returns rows and columns stty size and this does work here in foot terminal and xterm. There is also $LINES and $COLUMNS env vars.

But how should window resolution should be detected

cmd=$(printf '%b' "${TMUX:+\\ePtmux;\\e}\\e[14t${TMUX:+\\e\\\\}")
IFS=";" read -a REPLY -s -t 2 -d "S" -p $cmd >&2
echo "${REPLY[2]}x${REPLY[1]}"

update: the function above does not return resolution from vifm-spawned script call :(

@iambumblehead
Copy link
Owner Author

@iambumblehead
Copy link
Owner Author

@xaizek to loop you in

@iambumblehead
Copy link
Owner Author

I tried this from the bash bible again and this time it work. I must have done something wrong the last time I tried using it...

get_window_size() {
    # Usage: get_window_size
    printf '%b' "${TMUX:+\\ePtmux;\\e}\\e[14t${TMUX:+\\e\\\\}"
    IFS=';t' read -d t -t 0.05 -sra term_size
    printf '%s\n' "${term_size[1]}x${term_size[2]}"
}

@iambumblehead
Copy link
Owner Author

it looks like the above function only returns a valid value interrmittently

$ resolution_window_get
469x696
$ resolution_window_get
^[[4;469;696t469x696
$ resolution_window_get
469x696
$ resolution_window_get
469x696
$ resolution_window_get
^[[4;469;696t469x696
$ resolution_window_get
^[[4;469;696t469x696
$ resolution_window_get
^[[4;469;696t469x696
$ resolution_window_get
^[[4;469;696t469x696
$ resolution_window_get
469x696

@iambumblehead iambumblehead changed the title detecting cell size detecting cell size [solution] Mar 10, 2024
@iambumblehead iambumblehead changed the title detecting cell size [solution] detecting cell size Mar 12, 2024
@iambumblehead
Copy link
Owner Author

the script still needs to be updated to use terminal-reported cell size but a separate/new issue and PR can be created for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant