inv() and inv_type(): selection wraparound