feat: floating window max width/height can be percentages (#553)
This commit is contained in:
parent
6290ba1dc2
commit
1df90faf92
4 changed files with 7 additions and 2 deletions
|
|
@ -256,6 +256,7 @@ require("oil").setup({
|
||||||
float = {
|
float = {
|
||||||
-- Padding around the floating window
|
-- Padding around the floating window
|
||||||
padding = 2,
|
padding = 2,
|
||||||
|
-- max_width and max_height can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
||||||
max_width = 0,
|
max_width = 0,
|
||||||
max_height = 0,
|
max_height = 0,
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,7 @@ CONFIG *oil-confi
|
||||||
float = {
|
float = {
|
||||||
-- Padding around the floating window
|
-- Padding around the floating window
|
||||||
padding = 2,
|
padding = 2,
|
||||||
|
-- max_width and max_height can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
||||||
max_width = 0,
|
max_width = 0,
|
||||||
max_height = 0,
|
max_height = 0,
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ local default_config = {
|
||||||
float = {
|
float = {
|
||||||
-- Padding around the floating window
|
-- Padding around the floating window
|
||||||
padding = 2,
|
padding = 2,
|
||||||
|
-- max_width and max_height can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
|
||||||
max_width = 0,
|
max_width = 0,
|
||||||
max_height = 0,
|
max_height = 0,
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
|
|
|
||||||
|
|
@ -115,11 +115,13 @@ M.get_fullscreen_win_opts = function()
|
||||||
width = width - 2 -- The border consumes 1 col on each side
|
width = width - 2 -- The border consumes 1 col on each side
|
||||||
end
|
end
|
||||||
if config.float.max_width > 0 then
|
if config.float.max_width > 0 then
|
||||||
width = math.min(width, config.float.max_width)
|
local max_width = math.floor(calc_float(config.float.max_width, total_width))
|
||||||
|
width = math.min(width, max_width)
|
||||||
end
|
end
|
||||||
local height = total_height - 2 * config.float.padding
|
local height = total_height - 2 * config.float.padding
|
||||||
if config.float.max_height > 0 then
|
if config.float.max_height > 0 then
|
||||||
height = math.min(height, config.float.max_height)
|
local max_height = math.floor(calc_float(config.float.max_height, total_height))
|
||||||
|
height = math.min(height, max_height)
|
||||||
end
|
end
|
||||||
local row = math.floor((total_height - height) / 2)
|
local row = math.floor((total_height - height) / 2)
|
||||||
local col = math.floor((total_width - width) / 2) - 1 -- adjust for border width
|
local col = math.floor((total_width - width) / 2) - 1 -- adjust for border width
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue