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

gum choose: set initial vertical position (--cursor.MoveCursor(y, x)) #506

Open
iconoclasthero opened this issue Mar 3, 2024 · 1 comment
Labels
cmd/choose enhancement New feature or request

Comments

@iconoclasthero
Copy link

iconoclasthero commented Mar 3, 2024

Is your feature request related to a problem? Please describe.
looking at the options for gum choose, I do not see a way to position the cursor on a specific row (i.e., vertical position), only --cursor.alignment (which appears to be L, R, C)

what do you want?
can i put the cursor in the middle of the list that gum choose generates?
the output without gum is based on tput lines, the currently-playing song will be in the middle, i.e. (tput lines ÷ 2), and i can look up and down the list as i like. gum is intended to allow me to chose from that list, but i want to start in the middle, not at the top.

i found --output.MoveCursor(y, x) somewhere and that sees like an idea of what would work... so e.g., if this put the cursor in the middle of the list with --cursor.MoveCursor(y, x)

  clear -x
  lines=$(tput lines)
  echo "$lines"
  readarray -t playlistarray < <(\mpc playlist -f \(%position%\)~%artist%~%album%~\(%track%\)~%title%~\(%time%\)| { printf '(-POS-)~Artist~Album~(#)~Title~(mm:ss)\n' ; \grep \($(\mpc  current -f %position%)\) -m1 -C$(("$lines"/3)) ; } | column -s "~" -o " | " --table | \grep --color=always -e '' -e ".*$(mpc -f %position% current).*")
  n="${#playlistarray[@]}"
  i=$(gum choose --header.bold "${playlistarray[@]:1:$n}" --cursor.italic --height=$(("$lines"/1)) --header="${playlistarray[0]}" --header.padding="0 2" --cursor.MoveCursor($(($lines/2)), 0))
  i="${i%%)*}"
  i="${i#(}"
  mpc -P "$MPDPASS" play "$i"

(NB: mpc and grep are aliased in ~/.bash_aliases so commands copied from the cli may be prefixed with '')

@iconoclasthero iconoclasthero changed the title gum choose: set initial vertical position (--output.MoveCursor(y, x)) gum choose: set initial vertical position (--cursor.MoveCursor(y, x)) Mar 3, 2024
@iconoclasthero
Copy link
Author

Why isn't this a thing?!

@caarlos0 caarlos0 added cmd/choose enhancement New feature or request labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/choose enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants