-
-
Notifications
You must be signed in to change notification settings - Fork 693
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
base: main
Are you sure you want to change the base?
Conversation
…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
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? |
@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. |
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:
layout
blocks (normal syntax applies)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 themLayout
toLayoutConfig
I moved functionality likelist_available_layouts()
toLayoutConfig
and marked the old functions as deprecated in rust itselfAction::PreviousLayout
andAction::NextLayout
for KeybindingsScreenInstruction::PreviousLayout
andScreenInstruction::NextLayout
telling the screen to switch Layoutsscreen.update_layout
switching to the screens currently active layout using multiple newScreenInstruction
'sI 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
toLayoutConfig
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!