iamb icon indicating copy to clipboard operation
iamb copied to clipboard

[Feature Request] Layout Scripting

Open fuguesoft opened this issue 11 months ago • 0 comments

Another far-fetched idea:

The ability to script layouts based on room/space selection. What I mean is, having the ability to configure how the window is laid out when I open a ceratin room/space.

For instance, from an empty view with only the rooms window visible, if I select iamb-users from the rooms panel and <CR>, my config tells iamb to:

  1. Move the Rooms window all the way to the left, set the width to 10% and set the height to 100vh
  2. Open Chat window to the right, set width to 70% and height to 100vh
  3. Open Members window to the right, set width to 20% and height to 100vh

In my config, I would configure a default layout for any room as well as specific layouts for specific rooms. It would look something like this:

[settings.window_layout]
"my_cool_layout_1" = {
  pattern = {"*:matrix.org","*:backrooms.net"},
  windows = {
    spilt_h = {
      rooms = {
        direction = "horizontal",
        width = 10,
        height = 100,
      },
      chat = {
        width = 70,
        height = 100,
      },
      members = {
        width = "remaining",
        height = 100,
      },
    },
  },
}
default = "my_cool_layout_1"

Result:

 __________________________________________________________________________
+ iamb-users | Neovim | niri                                               +
+ Rooms---┐┌Neovim----------------------------------------┐┌Member(1Bil)-- +
+ iamb-u..||                                              || cool_peep_181 +
+ Neovim  || cool_peep_181 hey now, that's pretty cool    || angry_tyler9  +
+ niri    ||                                              || ...           +
+ ...     || angry_tyler9 grrrrrr                         ||               +
+         || [☺ 24]                                       ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+ ________||______________________________________________||_______________+
+ :                                                                        +
+ _________________________________________________________________________+

The order of the tables determines the window position order. First is leftmost, last is rightmost. The split_h and split_v variables determine the direction of window propagation for horizontal and vertical respectively. If omitted, this defaults to horizontal.

Additionally, if unset, the height and width parameters would default to 100% or perhaps stretch to fill the remaining space.

Another example would look like this:

[settings.window_layout]
"my_cool_layout_2" = {
  pattern = {"*:matrix.org","*:backrooms.net"},
  windows = {
    spilt_h = {
      rooms = {
        direction = "horizontal",
        width = 10,
        height = 100,
      },
      chat = {
        width = 70,
        height = 100,
        split_v = {
          <room_name>.chat,
        },
      },
      members = {
        width = "remaining",
        height = 100,
        split_v = {
          <room_name>.members,
        },
      },
    },
  },
}

Where <room-name> is the target room/space you want to reference for its chat, member or other associated windows.

Result:

 __________________________________________________________________________
+ iamb-users | Neovim | niri                                               +
+ Rooms---┐┌Neovim----------------------------------------┐┌Member(1Bil)-- +
+ iamb-u..||                                              || cool_peep_181 +
+ Neovim  || cool_peep_181 hey now, that's pretty cool    || angry_tyler9  +
+ niri    ||                                              || ...           +
+ ...     || angry_tyler9 grrrrrr                         ||               +
+         || [☺ 24]                                       ||               +
+         ||                                              ||               +
+         |└----------------------------------------------┘└---------------+
+         |┌niri------------------------------------------┐┌Member(4Trl)---+
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+         ||                                              ||               +
+ ________||______________________________________________||_______________+
+ :                                                                        +
+ _________________________________________________________________________+

I can also specify keybinds to invoke these pre-defined layouts.

[global_macros.normal]
# Invoke predefined layout for focused room/space
"<M-S-1>" = ":layout my_cool_layout_1" 

But all that might be too much for the base program So maybe it should be some sort of plugin

fuguesoft avatar Mar 30 '25 22:03 fuguesoft