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

Float Pane #5576

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open

Float Pane #5576

wants to merge 67 commits into from

Conversation

e82eric
Copy link

@e82eric e82eric commented Jun 17, 2024

Hi, I wanted to make an attempt at #270

This probably needs quite a bit of iteration (this is my first attempt at rust), but wanted to create the pull request to see if this is something you would be open to adding and to see if I am on the right track.

float_pane

@e82eric e82eric force-pushed the float-pane branch 3 times, most recently from 9bd3c95 to 03eabc7 Compare June 23, 2024 16:38
@derekthecool
Copy link
Contributor

Nice work! Demo video looks good.

@mathjiajia
Copy link

it would be nice to have a border for this floating pane

@e82eric
Copy link
Author

e82eric commented Jul 3, 2024

Updated with border.

float_pane_with_border2

Configs:

config.float_pane_padding = {
  left = '10%',
  right = '10%',
  top = '10%',
  bottom = '10%',
}
config.float_pane_border = {
  left_width = '0.5cell',
  right_width = '0.5cell',
  bottom_height = '0.25cell',
  top_height = '0.25cell',
  left_color = '#665c54',
  right_color = '#665c54',
  bottom_color = '#665c54',
  top_color = '#665c54',
}

@e82eric
Copy link
Author

e82eric commented Jul 6, 2024

I think this is ready to be reviewed now.

@Pajn
Copy link

Pajn commented Jul 13, 2024

Thanks a lot, this is the one feature I've been missing since transition from tmux to wezterm mux 🙏🏼

Tested this and it works really well, just commenting with some small issues I've seen:

  • The float panes all open in my home directory instead of the current directory like split panes and new tabs do
  • The pane selection UI is hard to read if having no split panes and one floating since the underlying pane and the float panes letter overlaps
  • If moving all non floating panes to a new tab or window the floating pane is shown on an otherwise invisible window, would be nice to either disallow this or de-float the floating pane

Screenshot from 2024-07-13 10-26-29
Screenshot from 2024-07-13 10-26-51

A very nice action to have but definitely not required for this to be super useful on its own, is to be able to toggle the floating status of a pane so you can transition a floating pane to a split pane and vice verse.

@e82eric
Copy link
Author

e82eric commented Jul 14, 2024

@Pajn I think I have the working directory issue fixed now.

For the pane selection my intention was to treat the float like a overlay and turn any selection operations into no-ops and prevent the mouse from selecting a pane (I think there were some scenarios that I missed like the selection UI). I pushed an update that I think turn those into nops now. This may not be the right strategy, is there a scenario where you would want to be able to select/interact with the panes underneath the float?

I think I have it updated so that closing the pane underneath the float is blocked now. Which I think will prevent the scenario where only the float is showing.

I tried out being able to move the float to a split today. It seemed to work, I pushed it to this branch if you want to give it a try. I didn't want to include it in this pull request to keep the scope down.
https://github.com/e82eric/wezterm/tree/move-float-to-split

This is what it looked like.
move_float_to_split

@Pajn
Copy link

Pajn commented Jul 14, 2024

Wow! I was just starting to familiarize myself with the code to see if I could help but not at that speed :)
Very quick testing have all the issues I experienced fixed.

This may not be the right strategy, is there a scenario where you would want to be able to select/interact with the panes underneath the float?

I was mostly just trying to break it to see where the limitations where. The one possible usecase I can see is to move one background pane to another tab/window if you need access to it after realizing the float pane was longer lived than you intended. However I think that's better solved by being able to transition the float pane to a split anyway. And disabling those actions when in a float definitely avoids a whole class of potential problems.

I didn't want to include it in this pull request to keep the scope down.

Totes! I was just excited. Thanks a lot for the branch though, will definitely start playing with it.
And if there is anything I can do to help get this merged, let me know.

@Suri312006
Copy link

i really like the work man, good stuff been wanting this feature, as im coming from zellij that has a really nice implementation of floating panes

@e82eric
Copy link
Author

e82eric commented Oct 16, 2024

Quick update on this

New stuff.

  • Added support for hiding/showing the floating pane.
  • Added support for multiple floating panes.
    • Switching between these uses the left and right pane navigation
    • @aleksandersumowski does this match what you were looking for with temporary panes?
  • Added support for moving an existing pane to a floating pane
  • Added support for moving a floating pane to a vertical or horizontal split

Items from PR review

  • The floating panes now shows in the results of wezterm cli list
    • The json output has an additional is_floating property
  • cli activate-pane --pane-id now works with floating panes
  • cli kill-pane --pane-id works with floating panes
  • Re-attaching multiplexer now retains floating pane visibility and active index.
  • When multiple clients are attached to multiplexer, changes get updated on both screens now
  • The floating pane does not currently work with the scrollbar
    • This should be possible. (I spent some time trying to get this to work and I think I just need to spend some more time to figure out how to get it to draw in the correct place)
      • This one may make sense as a separate PR
  • Special Gotchas.
    • Working on compiling a list
  • Lua Window/Tab Styling events
    • Need to figure out how to test/validate these.

I think it will take me a week or 2 more to get this in a state to move out of draft.

If anyone has a chance please try the latest and let me know if you find any issues.

Multiple floating panes:
multiple-floating-panes

Re-attach multiplexer:
reattach

Multiple Clients:
multiple-clients

@aleksandersumowski
Copy link

looks great from my perspective!

one minor question: is it be possible to pass a command to execute in the pane as an optional parameter? or does it always launch system shell?

@e82eric
Copy link
Author

e82eric commented Oct 17, 2024

@aleksandersumowski are you thinking of something like being able to run fzf in a floating pane?

This is my attempt at being able to run fzf and use the result in the current pane (not sure if the send-text is the best way to do this).

local function spawn_new_tab_with_pane_info(window, pane)
  local current_pane_id = pane:pane_id()

  local command = string.format([[
    #!/bin/bash
    current_pane_id=%s
    selected_commit=$(git log --oneline | fzf | awk '{print $1}')
    if [ -n "$selected_commit" ]; then
      wezterm cli activate-pane --pane-id "$current_pane_id"
      wezterm cli send-text --pane-id "$current_pane_id" -- "$selected_commit"
    fi
    exec $SHELL
  ]], current_pane_id)

  window:perform_action(
    wezterm.action.SpawnCommandInNewFloatingPane {
      args = { 'bash', '-c', command },
    },
    pane
  )
end

config.keys = {
  {
    key = 'y',
    mods = 'CTRL|SHIFT',
    label = 'floating fzf',
    action = wezterm.action_callback(spawn_new_tab_with_pane_info),
  },
}

fzf

@Yukaii
Copy link

Yukaii commented Oct 17, 2024

I hope wezterm cli spawn will also have the ability to start commands in a floating panel, so I can be used like tmux popup command!

@quantonganh
Copy link
Contributor

@Yukaii Have you tried something like this?

$ wezterm cli spawn --floating-pane lazygit

@aleksandersumowski
Copy link

aleksandersumowski commented Oct 17, 2024

😍😍😍
this is exactly the kind of possibilities I was thinking about - I can also see that the floating panel is closing once the fzf is done. Ideally I would like more possibilities than fzf without additional wrapper can provide, but that seems very much doable with the floating pane as is.

floating-pane

tbh I've tried compiling your branch and testing it myself but ./target/debug/wezterm was still complaining that SpawnCommandInNewFloatingPane - I must be doing something incorrectly

@e82eric
Copy link
Author

e82eric commented Oct 18, 2024

@aleksandersumowski just noticed in the screenshot that you were on the main branch from my fork, I think that might be why SpawnCommandInNewFloatingPane isn't working, the floating pane work is on the float-pane branch.

@e82eric
Copy link
Author

e82eric commented Oct 20, 2024

@wez quick heads up, this is ready to be reviewed again. (No rush)

New stuff.

  • Added support for multiple floating panes.
  • Added support for hiding/showing the floating panes.
    • Switching between these uses the left and right pane navigation. Up and down are currently no-op
  • Added support for moving an existing pane to a floating pane
  • Added support for moving a floating pane to a vertical or horizontal split

Items from PR review

  • The floating panes now show in the results of wezterm cli list
    • The json output has an additional is_floating property
  • cli activate-pane --pane-id now works with floating panes
  • cli kill-pane --pane-id now works with floating panes
  • Re-attaching multiplexer now retains floating pane visibility and active index.
  • When multiple clients are attached to multiplexer, changes now get updated on both screens
  • The floating pane does not currently work with the scrollbar
    • This should be possible. (I spent some time trying to get this to work and I think I just need to spend some more time to figure out how to get it to draw in the correct place)
    • Does it work if I add this as a follow-up PR?
  • The floating pane now has a scrollbar
  • Special Gotchas.
    • If you close the last non floating pane on a tab it also closes the floating panes
    • If the floating panes are hidden it is kind of hard to know that they are there.
    • Pane selection UI is no-op when floating panes are visible
    • If you click outside of the floating pane it will activate the clicked pane and hide the floating pane. It may be hard for the user to know that they need to toggle the floating panes to unhide them.
    • Pane selection by index only applies to non floating panes. if a floating pane is visibile when select by index is called the floating panes will be hidden
  • Lua Window/Tab Styling events
    • Need to figure out how to test/validate these. Do you happen to have an example?

Stuff that works with floating panes

  • cli list
  • cli spawn --floating
  • cli activate-pane --pane-id
  • cli move-pane-to-new-tab
  • cli kill-pane
  • cli zoom-pane
  • pane level overlays work (quick select, search, copy, etc)
  • tab/window overlays work
    • floating panes will be covered while the overlay is active

Stuff that doesn't work

  • split pane when floating pane is active
    • This seems possible but I am not sure if it would be useful
  • get-pane-direction
    • This may take some design. (Maybe up or down or a new floating direction etc)
  • Adjust pane size
    • Should be possible. Right now my thought is to add this in a follow up PR
  • Adjust position.
    • Should be possible. Right now my thought is to add this in a follow up PR
  • Scrollbar
    • Should be possible. Right now my thought is to add this in a follow up PR
  • Activate-pane-direction
    • This may take some design. (Maybe up or down or a new floating direction etc)
  • pane-select
    • This would take some design to figure out how to figure out what parts of the underlying panes are not hidden by the floating pane.

@e82eric e82eric marked this pull request as ready for review October 20, 2024 00:44
@e82eric e82eric requested a review from wez October 20, 2024 00:44
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

Successfully merging this pull request may close these issues.