Restore correct command in nested editor.
This commit is contained in:
parent
8a304d7c5a
commit
db19cbc869
20
editor.lua
20
editor.lua
|
@ -234,6 +234,10 @@ function module.create(data)
|
||||||
else
|
else
|
||||||
current_info = cmd
|
current_info = cmd
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if #open_areas == 0 and not pending_op then
|
||||||
|
current_info = current_info .. " (enter to apply)"
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
@ -377,8 +381,12 @@ function module.create(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if alt then
|
if alt then
|
||||||
local areas = layout.machi_get_areas(screen, tag)
|
if embed_args then
|
||||||
set_cmd(machi_engine.areas_to_command(areas))
|
set_cmd(embed_args.original_cmd or "")
|
||||||
|
else
|
||||||
|
local areas = layout.machi_get_areas(screen, tag)
|
||||||
|
set_cmd(machi_engine.areas_to_command(areas))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
set_cmd(current_cmd:sub(1, #current_cmd - 1))
|
set_cmd(current_cmd:sub(1, #current_cmd - 1))
|
||||||
end
|
end
|
||||||
|
@ -397,13 +405,9 @@ function module.create(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
log(DEBUG, "restore history #" .. tostring(cmd_index) .. ":" .. data.cmds[cmd_index])
|
log(DEBUG, "restore history #" .. tostring(cmd_index) .. ":" .. data.cmds[cmd_index])
|
||||||
if set_cmd(data.cmds[cmd_index]) and #open_areas == 0 then
|
set_cmd(data.cmds[cmd_index])
|
||||||
current_info = current_info .. " (enter to save)"
|
|
||||||
end
|
|
||||||
elseif #open_areas > 0 or pending_op then
|
elseif #open_areas > 0 or pending_op then
|
||||||
if handle_key(key) and #open_areas == 0 and not pending_op then
|
handle_key(key)
|
||||||
current_info = current_info .. " (enter to apply)"
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if key == "Return" then
|
if key == "Return" then
|
||||||
local alt = false
|
local alt = false
|
||||||
|
|
25
engine.lua
25
engine.lua
|
@ -782,8 +782,9 @@ local function areas_from_command(command, workarea, minimum)
|
||||||
return closed_areas, open_areas, pending_op ~= nil
|
return closed_areas, open_areas, pending_op ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function areas_to_command(areas, to_embed)
|
local function areas_to_command(areas, to_embed, root_area)
|
||||||
if #areas == 0 then return nil end
|
root_area = root_area or 1
|
||||||
|
if #areas < root_area then return nil end
|
||||||
|
|
||||||
local function shares_to_arg_str(shares)
|
local function shares_to_arg_str(shares)
|
||||||
local arg_str = ""
|
local arg_str = ""
|
||||||
|
@ -880,7 +881,7 @@ local function areas_to_command(areas, to_embed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if a.parent_id then
|
if area_id ~= root_area then
|
||||||
if a.expansion ~= areas[a.parent_id].expansion - 1 then
|
if a.expansion ~= areas[a.parent_id].expansion - 1 then
|
||||||
r = "t"..tostring(a.expansion)..r
|
r = "t"..tostring(a.expansion)..r
|
||||||
end
|
end
|
||||||
|
@ -900,9 +901,14 @@ local function areas_to_command(areas, to_embed)
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
local r = get_command(1)
|
local r = get_command(root_area)
|
||||||
if not to_embed then
|
if not to_embed then
|
||||||
r = r:gsub("[\\c]+$", ".")
|
if r == "-" then
|
||||||
|
r = "."
|
||||||
|
else
|
||||||
|
-- The last . may be redundant, but it makes sure no pending op.
|
||||||
|
r = r:gsub("[\\c]+$", "").."."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
@ -921,14 +927,15 @@ if not in_module then
|
||||||
assert(false)
|
assert(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
check_transcoded_command("t.", "-")
|
check_transcoded_command(".", ".")
|
||||||
|
check_transcoded_command("3t.", ".")
|
||||||
check_transcoded_command("121h.", "h1,2,1.")
|
check_transcoded_command("121h.", "h1,2,1.")
|
||||||
check_transcoded_command("1_10,2,1h1s131v.", "h1_10,2,1-v1,3,1.")
|
check_transcoded_command("1_10,2,1h1s131v.", "h1_10,2,1-v1,3,1.")
|
||||||
check_transcoded_command("332111w.", "w3,3,2,1,1,1.")
|
check_transcoded_command("332111w.", "w3,3,2,1,1,1.")
|
||||||
check_transcoded_command("1310111d.", ";d1,3,1,,1,1,1.")
|
check_transcoded_command("1310111d.", ";d1,3,1,,1,1,1.")
|
||||||
check_transcoded_command("dw66.", "dw6,6")
|
check_transcoded_command("dw66.", "dw6,6.")
|
||||||
check_transcoded_command(";dw66.", ";dw6,6")
|
check_transcoded_command(";dw66.", ";dw6,6.")
|
||||||
check_transcoded_command("101dw66.", ";dw6,6")
|
check_transcoded_command("101dw66.", ";dw6,6.")
|
||||||
check_transcoded_command("3tdw66.", "t3;dw6,6.")
|
check_transcoded_command("3tdw66.", "t3;dw6,6.")
|
||||||
print("Passed.")
|
print("Passed.")
|
||||||
end
|
end
|
||||||
|
|
|
@ -472,11 +472,10 @@ function module.start(c, exit_keys)
|
||||||
end
|
end
|
||||||
elseif key == "/" and not draft_mode then
|
elseif key == "/" and not draft_mode then
|
||||||
local current_area = selected_area()
|
local current_area = selected_area()
|
||||||
|
local original_cmd = machi.engine.areas_to_command(areas, true, current_area)
|
||||||
areas[current_area].hole = true
|
areas[current_area].hole = true
|
||||||
local prefix, suffix = machi.engine.areas_to_command(
|
local prefix, suffix = machi.engine.areas_to_command(
|
||||||
areas, true):match("(.*)|(.*)")
|
areas, false):match("(.*)|(.*)")
|
||||||
print(prefix, suffix)
|
|
||||||
|
|
||||||
areas[current_area].hole = nil
|
areas[current_area].hole = nil
|
||||||
|
|
||||||
workarea = {
|
workarea = {
|
||||||
|
@ -492,6 +491,7 @@ function module.start(c, exit_keys)
|
||||||
screen,
|
screen,
|
||||||
{
|
{
|
||||||
workarea = workarea,
|
workarea = workarea,
|
||||||
|
original_cmd = original_cmd,
|
||||||
cmd_prefix = prefix,
|
cmd_prefix = prefix,
|
||||||
cmd_suffix = suffix,
|
cmd_suffix = suffix,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue