--
--   Library code used by the example programs
--   Computercraft version
--

--   Utility for calling a function and printing the
--   error message if it throws an exception

function try(func, ...)
  ok, result = pcall(func, ...)
  if not ok then
    print("Error: " .. result)
  end
end

--   Terminal API compatibility functions

screen_width, screen_height = term.getSize()

function setCursor(col, row)
  term.setCursorPos(col, row)
end

--   Event API compatibility functions

function pull_event()
  return os.pullEvent()
end

key_event_name = "char"

function key_event_char(e)
  return e[2]
end
