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

Wrong number of column #718

Closed
eeeXun opened this issue Nov 14, 2021 · 5 comments
Closed

Wrong number of column #718

eeeXun opened this issue Nov 14, 2021 · 5 comments
Labels

Comments

@eeeXun
Copy link

eeeXun commented Nov 14, 2021

problem

I use this setting to set ratio of lf automatically.

%{{
    w=$(tput cols)
    if [ $w -le 80 ]; then
        lf -remote "send $id set ratios 1:2"
    elif [ $w -le 160 ]; then
        lf -remote "send $id set ratios 1:2:3"
    else
        lf -remote "send $id set ratios 1:2:3:5"
    fi
}}

But after upgrading my system yesterday, the column always be 80.
The command I type in lf %tput cols always get 80. No matter how I resize my terminal.

System version

OS: 5.15.2-arch1-1
bash: 5.1.8

@BachoSeven
Copy link

I believe the relevant change in your system is the latest ncurses version (also happened in mine after such update), which is v6.3-1

@BachoSeven
Copy link

@gokcehan I'm still experiencing this issue, can you reproduce the fact that %tput cols always returns 80 from lf?

@gokcehan gokcehan added bug and removed question labels Feb 6, 2022
@gokcehan
Copy link
Owner

gokcehan commented Feb 6, 2022

@BachoSeven Sorry I thought your previous response was a solution. I didn't read it carefully. I can reproduce this on my machine as well. I'm marking this as a bug. An easy workaround is to use $ command instead:

${{
    w=$(tput cols)
    if [ $w -le 80 ]; then
        lf -remote "send $id set ratios 1:2"
    elif [ $w -le 160 ]; then
        lf -remote "send $id set ratios 1:2:3"
    else
        lf -remote "send $id set ratios 1:2:3:5"
    fi
}}

It might also be possible to export a variable with the number of columns before launching lf and use that variable in the command instead of running tput cols.

@BachoSeven
Copy link

@gokcehan Thanks very much for the workaround; will update the wiki example for now since it might be an issue or change of behaviour with ncurses and not with lf.

If I got your final comment correctly, what you're saying is that since we don't use the async % we could export a variable before launching lf in order to speed things up; however I just realised that, at least in bash and zsh, that is already being done by the shell, and was able to do %echo $COLUMNS successfully from within lf. So an alternative (for those using zsh/bash at least, so will not put this in wiki for now) could be:

%{{
    w=$COLUMNS
    if [ $w -le 80 ]; then
        lf -remote "send $id set ratios 1:2"
    elif [ $w -le 160 ]; then
        lf -remote "send $id set ratios 1:2:3"
    else
        lf -remote "send $id set ratios 1:2:3:5"
    fi
}}

ilyagr added a commit to ilyagr/lf that referenced this issue Oct 23, 2022
Currently, the example fails confusingly for newer versions
of `tput`. See gokcehan#718.
gokcehan pushed a commit that referenced this issue Nov 13, 2022
…fix) (#975)

* When clicking on file preview, only open files on right-click

Currently, when mouse is on, I often click on the preview accidentally
since it's such a large target. Moreover, there is very little space I
can click without having the `lf` state change drastically (since I must
click on the current file for the preview to stay the same).

This commit prevents that.

* (Minor): Change example in docs to work around a bug

Currently, the example fails confusingly for newer versions
of `tput`. See #718.
@gokcehan
Copy link
Owner

I have now added $lf_width and $lf_height variables so the following should work now:

cmd recol %{{
    if [ $lf_width -le 80 ]; then
        lf -remote "send $id set ratios 1:2"
    elif [ $lf_width -le 160 ]; then
        lf -remote "send $id set ratios 1:2:3"
    else
        lf -remote "send $id set ratios 1:2:3:5"
    fi
}}

Closing this issue now. Feel free to report if there's an issue.

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

No branches or pull requests

3 participants