A timed block to run tasks with titles and success/failure messages.

    Args:
        msg: The header message to print at the beginning of the timed block.

def timed_display(msg):
    """A timed block to run tasks with titles and success/failure messages.

    Args:
        msg: The header message to print at the beginning of the timed block.
    """
    def print_header(msg, newline=True):
        """Print a header line.

        Args:
            msg: A message to be printed in the center of the header line.
            newline: Whether or not to print a newline at the end of the
                header. This can be convenient for allowing the line to
                overwrite another.
        """
        if sys.stdout.isatty():
            print('\r', end=Style.BRIGHT + Fore.BLUE)
        print(' {} '.format(msg).center(_ncols(), '='),
              end='\n{}'.format(Style.RESET_ALL)
              if newline else Style.RESET_ALL)
        sys.stdout.flush()

    def print_message(msg):
        """Print a task title message.

        Args:
            msg: The message to display before running the task.
        """
        if sys.stdout.isatty():
            print('\r', end='')
            msg = msg.ljust(_ncols())
        print(msg, end='')
        sys.stdout.flush()

    start = time.time()
    print_header(msg)
    with hidden_cursor():
        try:
            yield print_message
        finally:
            delta = time.time() - start
            print_header('completed in {:.2f}s'.format(delta), False)