Added dwindle layout, accept fib, fibonacci as keywords from config, added helper to lsp file, and comment to default config.
Browse files
+1 −0 src/bar/bar.zig
| @@ -18,6 +18,7 @@ fn getLayoutSymbol(layout_index: u32, config: config_mod.Config) []const u8 { | ||
| 18 | 18 | .floating => config.layout_floating_symbol, |
| 19 | 19 | .scrolling => config.layout_scrolling_symbol, |
| 20 | 20 | .grid => config.layout_grid_symbol, |
| 21 | + .dwindle => config.layout_dwindle_symbol, | |
| 21 | 22 | }; |
| 22 | 23 | } |
| 23 | 24 |
+4 −0 src/config/config.zig
| @@ -88,6 +88,7 @@ pub const Layouts = enum(u32) { | ||
| 88 | 88 | floating, |
| 89 | 89 | scrolling, |
| 90 | 90 | grid, |
| 91 | + dwindle, | |
| 91 | 92 | |
| 92 | 93 | pub fn fromString(name: []const u8) ?Layouts { |
| 93 | 94 | if (std.meta.stringToEnum(Layouts, name)) |v| return v; |
| @@ -95,6 +96,8 @@ pub const Layouts = enum(u32) { | ||
| 95 | 96 | if (std.mem.eql(u8, name, "normie")) return .floating; |
| 96 | 97 | if (std.mem.eql(u8, name, "float")) return .floating; |
| 97 | 98 | if (std.mem.eql(u8, name, "scroll")) return .scrolling; |
| 99 | + if (std.mem.eql(u8, name, "fib")) return .dwindle; | |
| 100 | + if (std.mem.eql(u8, name, "fibonacci")) return .dwindle; | |
| 98 | 101 | return null; |
| 99 | 102 | } |
| 100 | 103 | }; |
| @@ -208,6 +211,7 @@ pub const Config = struct { | ||
| 208 | 211 | layout_floating_symbol: []const u8 = "><>", |
| 209 | 212 | layout_scrolling_symbol: []const u8 = "[S]", |
| 210 | 213 | layout_grid_symbol: []const u8 = "[#]", |
| 214 | + layout_dwindle_symbol: []const u8 = "[\\]", | |
| 211 | 215 | |
| 212 | 216 | scheme_normal: ColorScheme = .{ .foreground = 0xbbbbbb, .background = 0x1a1b26, .border = 0x444444 }, |
| 213 | 217 | scheme_selected: ColorScheme = .{ .foreground = 0x0db9d7, .background = 0x1a1b26, .border = 0xad8ee6 }, |
+1 −0 src/config/lua.zig
| @@ -1147,6 +1147,7 @@ fn luaSetLayoutSymbol(state: ?*c.lua_State) callconv(.c) c_int { | ||
| 1147 | 1147 | .floating => cfg.layout_floating_symbol = symbol, |
| 1148 | 1148 | .scrolling => cfg.layout_scrolling_symbol = symbol, |
| 1149 | 1149 | .grid => cfg.layout_grid_symbol = symbol, |
| 1150 | + .dwindle => cfg.layout_dwindle_symbol = symbol, | |
| 1150 | 1151 | } |
| 1151 | 1152 | return 0; |
| 1152 | 1153 | } |
+2 −2 src/monitor.zig
| @@ -15,7 +15,7 @@ pub const Pertag = struct { | ||
| 15 | 15 | nmasters: [10]i32 = [_]i32{1} ** 10, |
| 16 | 16 | mfacts: [10]f32 = [_]f32{0.55} ** 10, |
| 17 | 17 | sellts: [10]u32 = [_]u32{0} ** 10, |
| 18 | - ltidxs: [10][5]?*const Layout = [_][5]?*const Layout{.{ null, null, null, null, null }} ** 10, | |
| 18 | + ltidxs: [10][6]?*const Layout = [_][6]?*const Layout{.{ null, null, null, null, null, null }} ** 10, | |
| 19 | 19 | showbars: [10]bool = [_]bool{true} ** 10, |
| 20 | 20 | }; |
| 21 | 21 | |
| @@ -49,7 +49,7 @@ pub const Monitor = struct { | ||
| 49 | 49 | stack: ?*Client = null, |
| 50 | 50 | next: ?*Monitor = null, |
| 51 | 51 | bar_win: xlib.Window = 0, |
| 52 | - lt: [5]?*const Layout = .{null} ** 5, | |
| 52 | + lt: [6]?*const Layout = .{null} ** 6, | |
| 53 | 53 | pertag: Pertag = .{}, |
| 54 | 54 | }; |
| 55 | 55 |
+5 −0 src/wm/wm.zig
| @@ -17,6 +17,7 @@ const monocle = @import("../layouts/monocle.zig"); | ||
| 17 | 17 | const floating = @import("../layouts/floating.zig"); |
| 18 | 18 | const scrolling = @import("../layouts/scrolling.zig"); |
| 19 | 19 | const grid = @import("../layouts/grid.zig"); |
| 20 | +const dwindle = @import("../layouts/dwindle.zig"); | |
| 20 | 21 | |
| 21 | 22 | pub const core = @import("core.zig"); |
| 22 | 23 | pub const actions = @import("actions.zig"); |
| @@ -167,6 +168,7 @@ pub const WindowManager = struct { | ||
| 167 | 168 | &floating.layout, |
| 168 | 169 | &scrolling.layout, |
| 169 | 170 | &grid.layout, |
| 171 | + &dwindle.layout, | |
| 170 | 172 | }; |
| 171 | 173 | |
| 172 | 174 | fn initMonitor(self: *WindowManager, mon: *Monitor, num: usize, x: i16, y: i16, w: c_int, h: c_int) void { |
| @@ -267,12 +269,14 @@ pub const WindowManager = struct { | ||
| 267 | 269 | new_mon.lt[2] = &floating.layout; |
| 268 | 270 | new_mon.lt[3] = &scrolling.layout; |
| 269 | 271 | new_mon.lt[4] = &grid.layout; |
| 272 | + new_mon.lt[5] = &dwindle.layout; | |
| 270 | 273 | for (0..10) |i| { |
| 271 | 274 | new_mon.pertag.ltidxs[i][0] = new_mon.lt[0]; |
| 272 | 275 | new_mon.pertag.ltidxs[i][1] = new_mon.lt[1]; |
| 273 | 276 | new_mon.pertag.ltidxs[i][2] = new_mon.lt[2]; |
| 274 | 277 | new_mon.pertag.ltidxs[i][3] = new_mon.lt[3]; |
| 275 | 278 | new_mon.pertag.ltidxs[i][4] = new_mon.lt[4]; |
| 279 | + new_mon.pertag.ltidxs[i][5] = new_mon.lt[5]; | |
| 276 | 280 | } |
| 277 | 281 | if (last) |l| { |
| 278 | 282 | l.next = new_mon; |
| @@ -356,6 +360,7 @@ pub const WindowManager = struct { | ||
| 356 | 360 | mon.lt[2] = &floating.layout; |
| 357 | 361 | mon.lt[3] = &scrolling.layout; |
| 358 | 362 | mon.lt[4] = &grid.layout; |
| 363 | + mon.lt[5] = &dwindle.layout; | |
| 359 | 364 | self.monitors = mon; |
| 360 | 365 | self.selected_monitor = mon; |
| 361 | 366 | } |
+5 −1 templates/config.lua
| @@ -112,10 +112,14 @@ oxwm.set_tags(tags) | ||
| 112 | 112 | -- Layouts |
| 113 | 113 | ------------------------------------------------------------------------------- |
| 114 | 114 | -- Set custom symbols for layouts (displayed in the status bar) |
| 115 | --- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed" | |
| 115 | +-- Available layouts: "tiling", "normie" (floating), "grid", "monocle", "tabbed", "dwindle" | |
| 116 | 116 | oxwm.set_layout_symbol("tiling", "[T]") |
| 117 | 117 | oxwm.set_layout_symbol("normie", "[F]") |
| 118 | 118 | oxwm.set_layout_symbol("tabbed", "[=]") |
| 119 | +-- oxwm.set_layout_symbol("dwindle", "[\\]") | |
| 120 | + | |
| 121 | +-- Example: bind dwindle (fibonacci) layout | |
| 122 | +-- oxwm.key.bind({ modkey }, "R", oxwm.layout.set("dwindle")) | |
| 119 | 123 | |
| 120 | 124 | -- Set default layout of specific tag (tag_index, layout_name) |
| 121 | 125 | -- Unset value uses oxwm.set_layout value |
+5 −5 templates/oxwm.lua
| @@ -46,17 +46,17 @@ function oxwm.auto_tile(enabled) end | ||
| 46 | 46 | function oxwm.tiled_resize_mode(enabled) end |
| 47 | 47 | |
| 48 | 48 | ---Set layout symbol override |
| 49 | ----@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle") | |
| 50 | ----@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]") | |
| 49 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "dwindle") | |
| 50 | +---@param symbol string Symbol to display (e.g., "[T]", "[F]", "[=]", "[\\]") | |
| 51 | 51 | function oxwm.set_layout_symbol(name, symbol) end |
| 52 | 52 | |
| 53 | 53 | ---Set default layout for all tags |
| 54 | ----@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases: "tile", "float", "scroll", "normie") | |
| 54 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", "dwindle", or aliases: "tile", "float", "scroll", "normie", "fib", "fibonacci") | |
| 55 | 55 | function oxwm.set_layout(name) end |
| 56 | 56 | |
| 57 | 57 | ---Set default layout for a specific tag |
| 58 | 58 | ---@param tag integer Tag index (1-9) |
| 59 | ----@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", or aliases) | |
| 59 | +---@param name string Layout name ("tiling", "floating", "scrolling", "grid", "monocle", "dwindle", or aliases) | |
| 60 | 60 | function oxwm.set_tag_layout(tag, name) end |
| 61 | 61 | |
| 62 | 62 | ---Set floating window spawn position |
| @@ -213,7 +213,7 @@ oxwm.layout = {} | ||
| 213 | 213 | function oxwm.layout.cycle() end |
| 214 | 214 | |
| 215 | 215 | ---Set specific layout |
| 216 | ----@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "scrolling") | |
| 216 | +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "scrolling", "dwindle") | |
| 217 | 217 | ---@return table Action table for keybinding |
| 218 | 218 | function oxwm.layout.set(name) end |
| 219 | 219 |