diff --git a/README.md b/README.md index a10264f..6875ed6 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ For `new_placement_cb` the arguments are: - `tag_data`: a mapping from area ids to their fake tag data. This is for nested layouts. - `areas`: the current array of areas produced by `instance.cmd`. Each area is a table with the following fields available: - `id`: self index of the array. - - `inhabitable`: if true, the area is not for placing windows. It could be a parent area, or area disabled by command `/`. + - `habitable`: if true, the area is for placing windows. It could be false for a parent area, or an area disabled by command `/`. - `x`, `y`, `width`, `height`: area geometry. - `layout`: the string used to index the nested layout, if any. - `geometry`: the output table the client geometry. Note that the geometry _includes_ the borders. diff --git a/editor.lua b/editor.lua index b334f12..459e68f 100644 --- a/editor.lua +++ b/editor.lua @@ -262,7 +262,7 @@ function module.create(data) local msg, ext for i, a in ipairs(closed_areas) do - if not a.inhabitable then + if a.habitable then local sa = shrink_area_with_gap(a, gap) local to_highlight = false if pending_op ~= nil then @@ -286,7 +286,7 @@ function module.create(data) end for i, a in ipairs(open_areas) do - if not a.inhabitable then + if a.habitable then local sa = shrink_area_with_gap(a, gap) local to_highlight = false if not pending_op then diff --git a/engine.lua b/engine.lua index cc8e827..7d2aa31 100644 --- a/engine.lua +++ b/engine.lua @@ -4,7 +4,7 @@ -- parent_cid -- parent_x_shares -- parent_y_shares --- inhabitable +-- habitable -- hole (unique) -- } -- @@ -243,6 +243,7 @@ local function areas_from_command(command, workarea, minimum) local i = #closed_areas + 1 closed_areas[i] = a a.id = i + a.habitable = true return a, i end @@ -284,7 +285,7 @@ local function areas_from_command(command, workarea, minimum) end local a, area_index = close_area() - a.inhabitable = true + a.habitable = false a.split = { method = method, x_shares = method == "h" and shares or {{1}}, @@ -396,7 +397,7 @@ local function areas_from_command(command, workarea, minimum) end local a, area_index = close_area() - a.inhabitable = true + a.habitable = false a.split = { method = method, x_shares = x_shares, @@ -561,7 +562,7 @@ local function areas_from_command(command, workarea, minimum) elseif method == "/" then - close_area().inhabitable = true + close_area().habitable = false elseif method == ";" then @@ -761,7 +762,7 @@ local function areas_from_command(command, workarea, minimum) if closed_areas[i].x + closed_areas[i].width > root.x + orig_width or closed_areas[i].y + closed_areas[i].height > root.y + orig_height then - closed_areas[i].inhabitable = true + closed_areas[i].habitable = false end end @@ -769,7 +770,7 @@ local function areas_from_command(command, workarea, minimum) if open_areas[i].x + open_areas[i].width > root.x + orig_width or open_areas[i].y + open_areas[i].height > root.y + orig_height then - open_areas[i].inhabitable = true + open_areas[i].habitable = false end end diff --git a/layout.lua b/layout.lua index a9dda5c..f6f8006 100644 --- a/layout.lua +++ b/layout.lua @@ -49,7 +49,7 @@ local function find_area(c, areas) local choice_value = nil local c_area = c.width * c.height for i, a in ipairs(areas) do - if not a.inhabitable then + if a.habitable then local x_cap = max(0, min(c.x + c.width, a.x + a.width) - max(c.x, a.x)) local y_cap = max(0, min(c.y + c.height, a.y + a.height) - max(c.y, a.y)) local cap = x_cap * y_cap @@ -80,7 +80,7 @@ end local function find_lu(c, areas, rd) local lu = nil for i, a in ipairs(areas) do - if not a.inhabitable then + if a.habitable then if rd == nil or (a.x < areas[rd].x + areas[rd].width and a.y < areas[rd].y + areas[rd].height) then if lu == nil or distance(c.x, c.y, a.x, a.y) < distance(c.x, c.y, areas[lu].x, areas[lu].y) then lu = i @@ -97,7 +97,7 @@ local function find_rd(c, border_width, areas, lu) y = c.y + c.height + (border_width or 0) * 2 local rd = nil for i, a in ipairs(areas) do - if not a.inhabitable then + if a.habitable then if lu == nil or (a.x + a.width > areas[lu].x and a.y + a.height > areas[lu].y) then if rd == nil or distance(x, y, a.x + a.width, a.y + a.height) < distance(x, y, areas[rd].x + areas[rd].width, areas[rd].y + areas[rd].height) then rd = i @@ -267,7 +267,7 @@ function module.create(args_or_name, editor, default_cmd) if in_draft ~= false then if cd[c].lu ~= nil and cd[c].rd ~= nil and cd[c].lu <= #areas and cd[c].rd <= #areas and - not areas[cd[c].lu].inhabitable and not areas[cd[c].rd].inhabitable + areas[cd[c].lu].habitable and areas[cd[c].rd].habitable then if areas[cd[c].lu].x == geo.x and areas[cd[c].lu].y == geo.y and @@ -305,7 +305,7 @@ function module.create(args_or_name, editor, default_cmd) else if cd[c].area ~= nil and cd[c].area <= #areas and - not areas[cd[c].area].inhabitable and + areas[cd[c].area].habitable and areas[cd[c].area].layout == nil and areas[cd[c].area].x == geo.x and areas[cd[c].area].y == geo.y and @@ -435,7 +435,7 @@ function module.create(args_or_name, editor, default_cmd) local choice_value = nil for i, a in ipairs(areas) do - if not a.inhabitable then + if a.habitable then local ac_x = a.x + a.width / 2 local ac_y = a.y + a.height / 2 local dis = (ac_x - center_x) * (ac_x - center_x) + (ac_y - center_y) * (ac_y - center_y) @@ -505,7 +505,7 @@ function module.placement.fair(c, instance, areas, geometry) local choice = nil for i = 1, #areas do local a = areas[i] - if not a.inhabitable then + if a.habitable then local emptyness = a.width * a.height / ((area_client_count[i] or 0) + 1) if emptyness_max == nil or emptyness > emptyness_max then emptyness_max = emptyness diff --git a/switcher.lua b/switcher.lua index 35e1fed..ec628e6 100644 --- a/switcher.lua +++ b/switcher.lua @@ -121,7 +121,7 @@ function module.start(c, exit_keys) if selected_area_ == nil then local min_dis = nil for i, a in ipairs(areas) do - if not a.inhabitable then + if a.habitable then local dis = math.abs(a.x + traverse_radius - traverse_x) + math.abs(a.x + a.width - traverse_radius - traverse_x) - a.width + math.abs(a.y + traverse_radius - traverse_y) + math.abs(a.y + a.height - traverse_radius - traverse_y) - a.height + @@ -191,7 +191,7 @@ function module.start(c, exit_keys) local msg, ext local active_area = selected_area() for i, a in ipairs(areas) do - if not a.inhabitable or i == active_area then + if a.habitable or i == active_area then cr:rectangle(a.x - start_x, a.y - start_y, a.width, a.height) cr:clip() cr:set_source(fill_color) @@ -354,7 +354,7 @@ function module.start(c, exit_keys) current_area = selected_area() for i, a in ipairs(areas) do - if a.inhabitable then goto continue end + if not a.habitable then goto continue end local v if key == "Up" then @@ -530,7 +530,7 @@ function module.start(c, exit_keys) current_area = parent_stack[#parent_stack] if c and ctrl then - if not areas[current_area].inhabitable and cd[c].draft ~= true then + if areas[current_area].habitable and cd[c].draft ~= true then cd[c].lu, cd[c].rd, cd[c].area = nil, nil, current_area end machi.layout.set_geometry(c, areas[current_area], areas[current_area], 0, c.border_width)