Added per layout default command; Fixed README.md.
This commit is contained in:
parent
9fd13172ca
commit
964244d693
|
@ -40,15 +40,17 @@ You can change it after loading the module.
|
|||
|
||||
## Use the layout
|
||||
|
||||
Use `local layout = machi.layout.create(name, editor)` to instantiate the layout with an editor object.
|
||||
Use `local layout = machi.layout.create(name, editor[, default_cmd])` to instantiate the layout with an editor object.
|
||||
|
||||
`name` can be a string or a function returning a string (see `init.lua` and "Advanced" below).
|
||||
This is used for having different actual layout dependent on tags.
|
||||
|
||||
`editor` are used for editing and persisting the layouts.
|
||||
`machi.default_editor` can be used, or see below on creating editors.
|
||||
You can use the exsiting `machi.default_editor`, or see below on creating editors.
|
||||
You can create multiple layouts with different names and share the same editor.
|
||||
|
||||
`default_cmd` is the initial command if no history command exists for the layout.
|
||||
|
||||
## The layout editor and commands
|
||||
|
||||
### Starting editor in lua
|
||||
|
@ -78,7 +80,7 @@ There are three kinds of operations:
|
|||
|
||||
2. Operations taking argument string as a single number.
|
||||
|
||||
`s` shift active region, `p` set the maximum split depth
|
||||
`s` shift active region, `t` set the maximum split depth
|
||||
|
||||
3. Operation not taking argument.
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ local DEBUG = -1
|
|||
|
||||
local module = {
|
||||
log_level = WARNING,
|
||||
default_cmd = "dw66.",
|
||||
global_default_cmd = "dw66.",
|
||||
allowing_shrinking_by_mouse_moving = false,
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ function module.set_geometry(c, region_lu, region_rd, useless_gap, border_width)
|
|||
end
|
||||
end
|
||||
|
||||
function module.create(name, editor)
|
||||
function module.create(name, editor, default_cmd)
|
||||
local instances = {}
|
||||
|
||||
local get_instance_name
|
||||
|
@ -130,13 +130,16 @@ function module.create(name, editor)
|
|||
cmd = persistent and editor.get_last_cmd(name) or nil,
|
||||
regions_cache = {},
|
||||
}
|
||||
if instances[name].cmd == nil then
|
||||
instances[name].cmd = default_cmd
|
||||
end
|
||||
end
|
||||
return instances[name]
|
||||
end
|
||||
|
||||
local function get_regions(workarea, tag)
|
||||
local instance = get_instance_(tag)
|
||||
local cmd = instance.cmd or module.default_cmd
|
||||
local cmd = instance.cmd or module.global_default_cmd
|
||||
if cmd == nil then return {}, false end
|
||||
|
||||
local key = tostring(workarea.width) .. "x" .. tostring(workarea.height) .. "+" .. tostring(workarea.x) .. "+" .. tostring(workarea.y)
|
||||
|
|
Loading…
Reference in New Issue