Return the current column number of the terminal cursor.
        Used to figure out if we need to print an extra newline.

        Returns:
            tuple(int): (x, y), (,)  - empty, if an error occurred.

        TODO: needs non-ansi mode for Windows
        Note:
            Checks is_a_tty() first, since function would block if i/o were
            redirected through a pipe.

def get_position(fallback=CURSOR_POS_FALLBACK):
    ''' Return the current column number of the terminal cursor.
        Used to figure out if we need to print an extra newline.

        Returns:
            tuple(int): (x, y), (,)  - empty, if an error occurred.

        TODO: needs non-ansi mode for Windows
        Note:
            Checks is_a_tty() first, since function would block if i/o were
            redirected through a pipe.
    '''
    values = fallback
    if is_a_tty():
        import tty, termios
        try:
            with TermStack() as fd:
                tty.setcbreak(fd, termios.TCSANOW)      # shut off echo
                sys.stdout.write(CSI + '6n')            # screen.dsr, avoid import
                sys.stdout.flush()
                resp = _read_until(maxchars=10, end='R')
        except AttributeError:  # no .fileno()
            return values

        # parse response
        resp = resp.lstrip(CSI)
        try:  # reverse
            values = tuple( int(token) for token in resp.partition(';')[::-2] )
        except Exception as err:
            log.error('parse error: %s on %r', err, resp)

    return values