get("#137") -- string split cursor = otherresults["#434"] or error("Need result of #434, please recalc") screentext = otherresults["#437"] or error("Need result of #437, please recalc") _, _, text = screentext:find("^Screen text on cursor line:\n(.*)") if text == nil then print("Screen text not found") return end _, _, cx, cy = cursor:find("Cursor position: (%d+)/(%d+)") if cx == nil then print("Cursor not found") return end cx, cy = tonumber(cx), tonumber(cy) --lines = split(text, "\n") --print("cy", cy, "lines", #lines) --line = lines[cy] line = text --print("line", line, "cx", cx) leftOfCursor = line:sub(1, cx-1) print("leftOfCursor", leftOfCursor) _, _, cmd = leftOfCursor:find("[#$] *(.*)") if cmd == nil then return end print("Command found: "..cmd) if cmd == "ls- ltr" then return "Suggested command correction: ".."ls -ltr" end