8e389c03f8
Реализовать двухпанельный Commander от платформенного PoC до этапов P6-P20: EMM-каталог, сортировку и выбор, операции с файлами и деревьями, транзакционное копирование, метаданные, политику конфликтов и предварительную проверку свободного места. Добавить проектную документацию, HDD/MAME-сценарии и проверенные артефакты. Расширить libc операцией bank_write_page, исправлением режима O_RDONLY и связанными регрессионными проверками.
149 lines
3.9 KiB
Lua
149 lines
3.9 KiB
Lua
-- 0.2/P10: F6 local rename, unchanged name, collision и group guard.
|
||
|
||
local KB = ":kbd:ms_naturl:"
|
||
local HOLD = 0.06
|
||
local events = {}
|
||
|
||
local function add(t, tag, mask, value)
|
||
events[#events + 1] = {t, KB .. tag, mask, value}
|
||
end
|
||
|
||
local function key(t, tag, mask)
|
||
add(t, tag, mask, 1)
|
||
add(t + HOLD, tag, mask, 0)
|
||
end
|
||
|
||
local function chord(t, mod_tag, mod_mask, key_tag, key_mask)
|
||
add(t, mod_tag, mod_mask, 1)
|
||
add(t + 0.02, key_tag, key_mask, 1)
|
||
add(t + 0.08, key_tag, key_mask, 0)
|
||
add(t + 0.10, mod_tag, mod_mask, 0)
|
||
end
|
||
|
||
local chars = {
|
||
a={"P1.6",0x04}, b={"P1.5",0x10}, c={"P1.4",0x08},
|
||
d={"P1.4",0x04}, e={"P1.4",0x20}, f={"P1.5",0x02},
|
||
i={"P1.4",0x01}, l={"P2.2",0x08}, m={"P2.0",0x10},
|
||
n={"P2.0",0x08}, p={"P2.3",0x20}, r={"P1.5",0x01},
|
||
s={"P1.2",0x08}, t={"P1.5",0x20}, x={"P1.2",0x10},
|
||
["."]={"P2.2",0x10}, ["\n"]={"P2.1",0x10},
|
||
[":"]={"P2.3",0x02,true}
|
||
}
|
||
|
||
local function type_text(t, value)
|
||
for i = 1, #value do
|
||
local ch = value:sub(i, i)
|
||
local def = chars[ch] or chars[ch:lower()]
|
||
local shifted = def[3] or ch ~= ch:lower()
|
||
if shifted then
|
||
chord(t, "P1.7", 0x02, def[1], def[2])
|
||
else
|
||
key(t, def[1], def[2])
|
||
end
|
||
t = t + 0.14
|
||
end
|
||
end
|
||
|
||
local function backspaces(t, count)
|
||
for _ = 1, count do
|
||
key(t, "P2.1", 0x20)
|
||
t = t + 0.18
|
||
end
|
||
return t
|
||
end
|
||
|
||
type_text(8.0, "d:\n")
|
||
type_text(9.0, "RENRT.EXE\n")
|
||
type_text(12.0, "SPRCMD.EXE\n")
|
||
|
||
key(18.0, "P2.1", 0x10) -- enter RENTEST.
|
||
key(20.0, "P2.3", 0x10) -- Down x4 -> UIOLD.TXT.
|
||
key(20.5, "P2.3", 0x10)
|
||
key(21.0, "P2.3", 0x10)
|
||
key(21.5, "P2.3", 0x10)
|
||
key(23.0, "P2.1", 0x80) -- F6.
|
||
local t = backspaces(24.0, 9)
|
||
type_text(t, "final.bin")
|
||
key(t + 1.4, "P2.1", 0x10)
|
||
|
||
key(32.0, "P2.1", 0x80) -- F6, имя без изменений.
|
||
key(33.0, "P2.1", 0x10)
|
||
|
||
key(36.0, "P2.1", 0x80) -- F6, collision с EXIST.TXT.
|
||
t = backspaces(37.0, 9)
|
||
type_text(t, "exist.txt")
|
||
key(t + 1.4, "P2.1", 0x10)
|
||
|
||
key(44.0, "P2.5", 0x01) -- Home -> `..`.
|
||
key(45.0, "P2.1", 0x80) -- F6 guard virtual.
|
||
key(48.0, "P2.3", 0x10) -- NEWDIR.
|
||
key(49.0, "P2.6", 0x01) -- Insert dir; cursor -> file.
|
||
key(50.0, "P2.1", 0x80) -- group ambiguity guard.
|
||
|
||
key(54.0, "P2.3", 0x80) -- F10.
|
||
key(56.0, "P2.1", 0x10)
|
||
|
||
table.sort(events, function(left, right) return left[1] < right[1] end)
|
||
|
||
local snap_times = {
|
||
19.0, -- target probe already renamed file and directory;
|
||
23.5, -- dialog default UIOLD.TXT;
|
||
30.5, -- FINAL.BIN created and focused;
|
||
34.0, -- unchanged name skipped;
|
||
42.0, -- existing target rejected;
|
||
46.0, -- virtual `..` rejected;
|
||
51.0, -- selected dir elsewhere makes group action explicit;
|
||
58.0 -- clean DSS prompt.
|
||
}
|
||
local snaps_done = {}
|
||
local start_time = nil
|
||
local ports = nil
|
||
local index = 1
|
||
local field_cache = {}
|
||
|
||
local function now()
|
||
local value = manager.machine.time
|
||
return value.seconds + value.attoseconds / 1e18
|
||
end
|
||
|
||
local function field(tag, mask)
|
||
local cache_key = tag .. "/" .. mask
|
||
if field_cache[cache_key] then return field_cache[cache_key] end
|
||
for _, candidate in pairs(ports[tag].fields) do
|
||
if candidate.mask == mask then
|
||
field_cache[cache_key] = candidate
|
||
return candidate
|
||
end
|
||
end
|
||
error("Не найдено поле " .. cache_key)
|
||
end
|
||
|
||
emu.add_machine_reset_notifier(function()
|
||
start_time = now()
|
||
end)
|
||
|
||
emu.register_periodic(function()
|
||
if not start_time then return end
|
||
if not ports then ports = manager.machine.ioport.ports end
|
||
local elapsed = now() - start_time
|
||
|
||
while index <= #events and elapsed >= events[index][1] do
|
||
local event = events[index]
|
||
field(event[2], event[3]):set_value(event[4])
|
||
index = index + 1
|
||
end
|
||
|
||
for _, snap_time in ipairs(snap_times) do
|
||
if not snaps_done[snap_time] and elapsed >= snap_time then
|
||
snaps_done[snap_time] = true
|
||
manager.machine.video:snapshot()
|
||
print("[p10-rename] snapshot t=" .. elapsed)
|
||
end
|
||
end
|
||
|
||
if elapsed >= 60.0 then
|
||
print("[p10-rename] exit t=" .. elapsed)
|
||
manager.machine:exit()
|
||
end
|
||
end)
|