-- stylua: ignore local SUPPORTED_KEYS = { { on = "0"}, { on = "1"}, { on = "2"}, { on = "3"}, { on = "4"}, { on = "5"}, { on = "6"}, { on = "7"}, { on = "8"}, { on = "9"}, { on = "A"}, { on = "B"}, { on = "C"}, { on = "D"}, { on = "E"}, { on = "F"}, { on = "G"}, { on = "H"}, { on = "I"}, { on = "J"}, { on = "K"}, { on = "L"}, { on = "M"}, { on = "N"}, { on = "O"}, { on = "P"}, { on = "Q"}, { on = "R"}, { on = "S"}, { on = "T"}, { on = "U"}, { on = "V"}, { on = "W"}, { on = "X"}, { on = "Y"}, { on = "Z"}, { on = "a"}, { on = "b"}, { on = "c"}, { on = "d"}, { on = "e"}, { on = "f"}, { on = "g"}, { on = "h"}, { on = "i"}, { on = "j"}, { on = "k"}, { on = "l"}, { on = "m"}, { on = "n"}, { on = "o"}, { on = "p"}, { on = "q"}, { on = "r"}, { on = "s"}, { on = "t"}, { on = "u"}, { on = "v"}, { on = "w"}, { on = "x"}, { on = "y"}, { on = "z"}, } local save_bookmark = ya.sync(function(state, idx) local folder = Folder:by_kind(Folder.CURRENT) state.bookmarks = state.bookmarks or {} state.bookmarks[#state.bookmarks + 1] = { on = SUPPORTED_KEYS[idx].on, desc = tostring(folder.cwd), cursor = folder.cursor, } end) local all_bookmarks = ya.sync(function(state) return state.bookmarks or {} end) local delete_bookmark = ya.sync(function(state, idx) table.remove(state.bookmarks, idx) end) local delete_all_bookmarks = ya.sync(function(state) state.bookmarks = nil end) return { entry = function(_, args) local action = args[1] if not action then return end if action == "save" then local key = ya.which { cands = SUPPORTED_KEYS, silent = true } if key then save_bookmark(key) end return end if action == "delete_all" then return delete_all_bookmarks() end local bookmarks = all_bookmarks() local selected = #bookmarks > 0 and ya.which { cands = bookmarks } if not selected then return end if action == "jump" then ya.manager_emit("cd", { bookmarks[selected].desc }) ya.manager_emit("arrow", { -99999999 }) ya.manager_emit("arrow", { bookmarks[selected].cursor }) elseif action == "delete" then delete_bookmark(selected) end end, }