def find_in_line(view, character, forward=True):
    """Find a character in the current line.
    :param view:
        The view where we are performing the search.
    :param character:
        The sought character.
    :param forward:
        If `True`, search forward. If `False`, search backwards.

    Returns 0 or a positive integer if the character was found. The number indicates
    the character position in the view. Returns a negative integer if the character
    wasn't found.
    """
    pt = view.sel()[0].b
    limit = view.line(pt).end() if forward else view.line(pt).begin()
    is_within_limits = (lambda x: x < limit) if forward else (lambda x: x >= limit)
    increment = 1 if forward else -1

    while is_within_limits(pt):
        if view.substr(pt) == character:
            break
        pt += increment
    else:
        return -1

    return pt