local M = {} M.STATE_LIST = "list" M.STATE_QUIT_CONFIRM = "quit_confirm" M.STATE_MODAL_CONFLICT = "modal_conflict" M.EXIT = "exit" function M.next(state, event) if state == M.STATE_LIST then if event == "esc" then return M.STATE_QUIT_CONFIRM end if event == "open_conflict" then return M.STATE_MODAL_CONFLICT end elseif state == M.STATE_QUIT_CONFIRM then if event == "esc" then return M.STATE_LIST end if event == "enter" then return M.EXIT end if event == "click_yes" then return M.EXIT end if event == "click_no" then return M.STATE_LIST end elseif state == M.STATE_MODAL_CONFLICT then if event == "esc" then return M.STATE_LIST end if event == "cancel" then return M.STATE_LIST end if event == "launch_anyway" then return M.STATE_LIST end -- side-effect end return state end return M