def xycenter(scr, text):
    """
    Given a curses window and a string, return the x, y coordinates to pass to
    scr.addstr() for the provided text to be drawn in the horizontal and
    vertical center of the window.
    """
    y, x = scr.getmaxyx()
    nx = x // 2 - len(text) // 2
    ny = y // 2 - len(text.split('\n')) // 2
    return nx, ny
