Change to use Shift + Backspace to restore the current command.

This commit is contained in:
Xinhao Yuan 2021-02-25 21:00:33 -05:00
parent 40a20f08d2
commit 7433ddd1ea
2 changed files with 12 additions and 5 deletions

View File

@ -87,9 +87,9 @@ The layout is defined by a sequence of operations as a layout command.
The layout editor allows users to interactively input their commands and shows the resulting layouts on screen, with the following auxiliary functions:
1. `Up`/`Down`: restore to the history command
2. `Backspace`: undo the last command. If the command is already empty, restores to the current (maybe transcoded) command of the layout.
2. `Backspace`: undo the last command. If `Shift` is hold, restores to the current (maybe transcoded) command of the layout.
3. `Escape`: exit the editor without saving the layout.
4. `Enter`: when all areas are defined, hit enter will save the layout. If shift is hold, only applies the command without saving it to the history.
4. `Enter`: when all areas are defined, hit enter will save the layout. If `Shift` is hold, only applies the command without saving it to the history.
### Layout command

View File

@ -369,11 +369,18 @@ function module.create(data)
local ok, err = pcall(
function ()
if key == "BackSpace" then
if #current_cmd > 0 then
set_cmd(current_cmd:sub(1, #current_cmd - 1))
elseif embed_args == nil then
local alt = false
for _, m in ipairs(mod) do
if m == "Shift" then
alt = true
break
end
end
if alt then
local areas = layout.machi_get_areas(screen, tag)
set_cmd(machi_engine.areas_to_command(areas))
else
set_cmd(current_cmd:sub(1, #current_cmd - 1))
end
elseif key == "Escape" then
table.remove(data.cmds, #data.cmds)