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

Feature: Apply layout at runtime; Implementing #742 #3984

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

Conversation

pkleineb
Copy link

As said in the title this PR aims to implement a system for applying layouts at runtime based on one layout file.

What I did:

  • added capabilities in the layout kdl parser for parsing multiple layout blocks (normal syntax applies)
  • added a new LayoutConfig struct that stores the currently selected layout and all layouts that got parsed. It also implements utility functions for switching to layouts and iterating over all of them
  • Since we are changing the main Layout struct from Layout to LayoutConfig I moved functionality like list_available_layouts() to LayoutConfig and marked the old functions as deprecated in rust itself
  • added Action::PreviousLayout and Action::NextLayout for Keybindings
  • added ScreenInstruction::PreviousLayout and ScreenInstruction::NextLayout telling the screen to switch Layouts
  • added screen.update_layout switching to the screens currently active layout using multiple new ScreenInstruction's

I gotta be honest this is my first time working with this big of a codebase and therefore I might not have used best practice or overlooked something during changing from Layout to LayoutConfig that breaks some Plugins, but since I don't have many plugins I wouldn't know.

I also implemented some unit and e2e tests for the functionality.

Let me know if there is something missing and I will try to implement that as soon as possible. Also if I should squash commits let me know!

…e layout file like discussed in zellij-org#742

Since these are quite some huge changes I feel the need to explain what
I did in more detail:
1. I implemented a way for the kdl parser to parser a layout file that
has multiple layouts
2. I created a new struct LayoutConfig that contains all parsed layouts
from a file
3. I went over basically everywhere where we were using Layout and
implemented LayoutConfigs logic so that we render the currently selected
layout just like before

Things that need more testing:
- if session ressurection works as intended
…ng runtime

Short summary:
1. Added `Action::PreviousLayout` and `Action::NextLayout`
2. Added `ScreenInstruction::PreviousLayout` and
ScreenInstruction::NextLayout` which switch layouts and get called from
their respective actions
3. Added a function update_layout that calls more ScreenInstructions
creating new tabs and deleting old ones
This is just the tests that don't need any snaps to be reworked
chore(screen): was randomly crashing when switching between layouts quickly
@Zykino
Copy link
Contributor

Zykino commented Feb 12, 2025

Hello,

Thanks for this big looking contribution (I’m not a maintainer, I’m "just" helping peoples that have questions on Discord).

Not sure how to tell you but… do you know about the swap layouts feature?

The description I see looks awfully lot like this feature and I fear you work on re-implementing that already exist 😅

PS: I see in the issue you tagged in the title that you also see the similarity. So maybe a comparative description could help?
Note that zellij action new-tab -l <layout-name> create a new tab using the named layout, which as I understand it is what the comment you mentioned would need?

@pkleineb
Copy link
Author

@Zykino Yeah I was also quite confused about how this exactly differs from Swaplayouts. I also dont have much experience with them.

But isnt it that you cannot create new Tabs in Swaplayouts? With this feature it would allow you to create layouts that differ in tab amount and therefore be unique to Swaplayouts.

Also I am not quite sure on how to understand your command down below. Since the command would be called from outside of zellij in the terminal right? This is rather a zellij local keybindable action.

Let me know if I confused something.

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.

2 participants