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

Add ability to zoom a window #870

Closed
pehota opened this issue Sep 6, 2018 · 22 comments
Closed

Add ability to zoom a window #870

pehota opened this issue Sep 6, 2018 · 22 comments

Comments

@pehota
Copy link

pehota commented Sep 6, 2018

I really like Kitty but there are several things that keep me from abandoning iTerm and tmux.
One of them is the ability to zoom a window (like tmux's zoom pane).
Unless I missed something in the documentation, there is no such functionality in Kitty currently.
It would really be a neat feature to have.

@kovidgoyal
Copy link
Owner

simply switch to the stack layout. That will effective zoom the currently focused layout. You can create a dedicated key binding for it in kitty.conf if you like using the goto_layout function.

@ptbrowne
Copy link

ptbrowne commented Sep 6, 2018

The zoom feature also allow to unzoom = go back to the previous layout. I see no previous_layout function in tabs.py.

Would you be open to a PR that implements this behavior ?

@kovidgoyal
Copy link
Owner

Switch back to the previosu layout and it is the same as unzoom.

@kovidgoyal
Copy link
Owner

If you mean you want an dedicated switch_to_previous layout function, sure, feel free to send a PR for that.

@ptbrowne
Copy link

ptbrowne commented Sep 6, 2018

@pehota At the moment to almost get this behavior I did :

map `>z goto_layout stack
map `>a goto_layout tall

@pehota
Copy link
Author

pehota commented Sep 6, 2018

Thank you @ptbrowne and @kovidgoyal

@esn89
Copy link

esn89 commented Sep 29, 2018

with the "last_layout" implement, does that mean we now siwtch to stack, and then can toggle "last_layout" to get the zoom in/out effect?

@kovidgoyal
Copy link
Owner

yes

@ronjouch
Copy link
Contributor

ronjouch commented Oct 12, 2018

@kovidgoyal thanks for f0357b0 implementing last_used_layout.

Going one step further: because I typically switch between current layout and fullscreen ("stack"), it would be great to also have a toggle_layout_with_layout <layout> command, which would dispense having two keyboard shortcuts. I would map f11 toggle_layout_with_layout stack, and pressing F11 would always toggle between the current/previous layout and the stack layout. So no need to have one mapping for stack, and another for tall. A single toggle.

Edge case: if no previous layout exists at initial invoke and layout is stack, it's a noop.

Does that makes sense? Would you accept a PR for that?

@kovidgoyal
Copy link
Owner

I dont think you need aa separate function for that. Just modify last_used_layout to switch to a random layout if there is no previous layout, then you can simply use it for your use case.

@ptbrowne
Copy link

ptbrowne commented Oct 12, 2018

Thanks for the last_layout implementation !

with the "last_layout" implement, does that mean we now siwtch to stack, and then can toggle "last_layout" to get the zoom in/out effect?

Is it possible to use the same key for zoom/unzoom ? Essentially having a conditional on the key ?

with the "last_layout" implement, does that mean we now siwtch to stack, and then can toggle "last_layout" to get the zoom in/out effect?

 map `>z goto_layout stack if current_layout() != 'stack' else last_layout

I presume it is not possible to have a conditional in the config, is it be possible to add custom functions, usable in config ?

@ronjouch
Copy link
Contributor

I don't think you need a separate function for that. Just modify last_used_layout to switch to a random layout if there is no previous layout, then you can simply use it for your use case.

@kovidgoyal the need is at startup: if there's no previous layout, then I'd like to switch to stack. Not to a random layout.

  1. I'm used to this behavior from various apps "F11" key, and also tmux bind -n C-b resize-pane -Z, which have this toggling behavior between current layout and maximized layout.
  2. More importantly, it feels natural: I'm using a layout with multiple windows in it. At some point I want all the available space for one window. I maximize. Then I'm done and I unmaximize.

@ptbrowne 's suggestion about scripting in mappings would be neat too.

@kovidgoyal
Copy link
Owner

So instead of using a random layout, use the "next_layout" and set enabled_layouts to have stack as the number two layout, so that at startup it is the next_layout.

As for scripting in mappings, I'm afraid that is not going to happen. What you can do is create your own kitten, to do arbitrary scripting, kittens have access to the full kitty environment (the boss object from which you can create windows/siwtch windows/tabs/etc). The downside, with kittens is currently they will cause a brief flash when a overlay window is opened to run the kitten. It should be easy to modify the kittens sub-system to create kittens that have to running component and instead can just be used to script kitty, seamlessly. See https://sw.kovidgoyal.net/kitty/kittens/custom.html

@ronjouch
Copy link
Contributor

ronjouch commented Oct 12, 2018

So instead of using a random layout, use next_layout and set enabled_layouts to have stack as the number two layout, so that at startup it is the next_layout.

@kovidgoyal but then I still have to bind (and remember to use) two keys: one to next_layout to stack on first use, and one to last_layout afterwards. Instead I'd like a single key to toggle between current layout and "maximized".

What I also tried was to remove all layouts but tall and stack. In this case, next_layout becomes a real toggle between the two since they're the only two, but I also use other layouts intermittently, so that doesn't work.

@kovidgoyal
Copy link
Owner

It should be trivial to to create a kitten to do that for yourself. It's a little too specialised a use case for me to bother with creating a dedicated endpoint in kitty for it. I will instead modify the kittens system to allow no-UI kittens, so there will be no flash either.

kovidgoyal added a commit that referenced this issue Oct 12, 2018
@ptbrowne
Copy link

I will instead modify the kittens system to allow no-UI kittens, so there will be no flash either.

Perfect, that was this that prevented me from using the kittens system. Thanks !

@kovidgoyal
Copy link
Owner

already done, 787100a

@Julian
Copy link

Julian commented Feb 13, 2022

Anyone have a fuller-featured implementation of this (as a kitten it sounds like) to share?

E.g. 2 things I immediately miss after the basic map kitty_mod+z toggle_layout stack is a way to:

  • indicate in the tabbar that a tab is zoomed
  • make launch while zoomed "work normally" -- i.e. not open the new window zoomed, it should now open the original zoomed window + the new one in a split window, but leave the other hidden windows hidden

@kovidgoyal
Copy link
Owner

If you want those semantic use detach-window instead and make thewindow
into a new tab.

@uri3l593
Copy link

Hi, anyone knows why the shortcut map ctrl+shift+z toggle_layout stack doesn't work in the latin american keyboard. I tried some shortcuts but nothing. Only works goto_layout stack, and other layouts, but that is not cool to do "zoom in and zoom out", thank you very much.

@uri3l593
Copy link

How do I open a new window or tab with the same working directory as the current user?
For example, I opened a terminal as user boch, then, I switched to the user root (entering su root), I open a new split window or tab in the same terminal and this is open as user boch. How can I make the other tabs or split windows open as root user in the same terminal? thanks.

@mtak
Copy link

mtak commented Apr 6, 2023

Hi, anyone knows why the shortcut map ctrl+shift+z toggle_layout stack doesn't work in the latin american keyboard. I tried some shortcuts but nothing. Only works goto_layout stack, and other layouts, but that is not cool to do "zoom in and zoom out", thank you very much.

Are you sure you are using Kitty >0.27.1? Ubuntu 22.04 has Kitty 0.21.2, which doesn't support this feature.

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

8 participants