Provided default value of editor; Changed document.

This commit is contained in:
Xinhao Yuan 2020-03-21 17:01:16 -04:00
parent a1378403c7
commit 00e3e0aba5
4 changed files with 15 additions and 10 deletions

View File

@ -42,10 +42,13 @@ You can change it after loading the module.
Use `local layout = machi.layout.create(args)` to instantiate the layout with an editor object. `args` is a table of arguments, where the followings can be used: Use `local layout = machi.layout.create(args)` to instantiate the layout with an editor object. `args` is a table of arguments, where the followings can be used:
- `name`: the constant name of the layout - `name`: the constant name of the layout.
- `name_func`: a `function(t)` closure that returns a string for tag `t`. `name_func` overrides `name` - `name_func`: a `function(t)` closure that returns a string for tag `t`. `name_func` overrides `name`.
- `persistent`: whether to keep a history of the command for the layout. Default is `true` - `persistent`: whether to keep a history of the command for the layout. The default is `true`.
- `default_cmd`: the command to use if there is no persistent history for this layout. - `default_cmd`: the command to use if there is no persistent history for this layout.
- `editor`: the editor used for the layout. The default is `machi.default_editor` (or `machi.editor.default_editor`).
Either `name` or `name_func` must be set - others are optional.
The function is compatible with the previous `machi.layout.create(name, editor, default_cmd)` calls. The function is compatible with the previous `machi.layout.create(name, editor, default_cmd)` calls.

View File

@ -1,7 +1,3 @@
local machi = {
layout = require((...):match("(.-)[^%.]+$") .. "layout"),
}
local api = { local api = {
beautiful = require("beautiful"), beautiful = require("beautiful"),
wibox = require("wibox"), wibox = require("wibox"),
@ -965,4 +961,6 @@ function module.create(data)
} }
end end
module.default_editor = module.create()
return module return module

View File

@ -9,8 +9,8 @@ local function default_name(tag)
end end
return tag.machi_name_cache return tag.machi_name_cache
end end
local default_editor = editor.create() local default_editor = editor.default_editor
local default_layout = layout.create{ name_func = default_name, editor = default_editor } local default_layout = layout.create{ name_func = default_name }
local gcolor = require("gears.color") local gcolor = require("gears.color")
local beautiful = require("beautiful") local beautiful = require("beautiful")

View File

@ -1,3 +1,7 @@
local machi = {
editor = require((...):match("(.-)[^%.]+$") .. "editor"),
}
local api = { local api = {
screen = screen, screen = screen,
awful = require("awful"), awful = require("awful"),
@ -128,7 +132,7 @@ function module.create(args_or_name, editor, default_cmd)
else else
return nil return nil
end end
args.editor = args.editor or editor args.editor = args.editor or editor or machi.editor.default_editor
args.default_cmd = args.default_cmd or default_cmd or global_default_cmd args.default_cmd = args.default_cmd or default_cmd or global_default_cmd
args.persistent = args.persistent == nil or args.persistent args.persistent = args.persistent == nil or args.persistent