def create_content(self, cli, width, height):
        """
        Create a UIContent object for this menu.
        """
        complete_state = cli.current_buffer.complete_state
        column_width = self._get_column_width(complete_state)
        self._render_pos_to_completion = {}

        def grouper(n, iterable, fillvalue=None):
            " grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx "
            args = [iter(iterable)] * n
            return zip_longest(fillvalue=fillvalue, *args)

        def is_current_completion(completion):
            " Returns True when this completion is the currently selected one. "
            return complete_state.complete_index is not None and c == complete_state.current_completion

        # Space required outside of the regular columns, for displaying the
        # left and right arrow.
        HORIZONTAL_MARGIN_REQUIRED = 3

        if complete_state:
            # There should be at least one column, but it cannot be wider than
            # the available width.
            column_width = min(width - HORIZONTAL_MARGIN_REQUIRED, column_width)

            # However, when the columns tend to be very wide, because there are
            # some very wide entries, shrink it anyway.
            if column_width > self.suggested_max_column_width:
                # `column_width` can still be bigger that `suggested_max_column_width`,
                # but if there is place for two columns, we divide by two.
                column_width //= (column_width // self.suggested_max_column_width)

            visible_columns = max(1, (width - self._required_margin) // column_width)

            columns_ = list(grouper(height, complete_state.current_completions))
            rows_ = list(zip(*columns_))

            # Make sure the current completion is always visible: update scroll offset.
            selected_column = (complete_state.complete_index or 0) // height
            self.scroll = min(selected_column, max(self.scroll, selected_column - visible_columns + 1))

            render_left_arrow = self.scroll > 0
            render_right_arrow = len(rows_[0]) - visible_columns < self.scroll

            # Write completions to screen.
            tokens_for_line = []

            for row_index, row in enumerate(rows_):
                tokens = []
                middle_row = row_index == len(rows_) // 2

                # Draw left arrow if we have hidden completions on the left.
                if render_left_arrow:
                    tokens += [(Token.Scrollbar, '<' if middle_row else ' ')]

                # Draw row content.
                for column_index, c in enumerate(row[self.scroll:][:visible_columns]):
                    if c is not None:
                        tokens += self._get_menu_item_tokens(c, is_current_completion(c), column_width)

                        # Remember render position for mouse click handler.
                        for x in range(column_width):
                            self._render_pos_to_completion[(column_index * column_width + x, row_index)] = c
                    else:
                        tokens += [(self.token.Completion, ' ' * column_width)]

                # Draw trailing padding. (_get_menu_item_tokens only returns padding on the left.)
                tokens += [(self.token.Completion, ' ')]

                # Draw right arrow if we have hidden completions on the right.
                if render_right_arrow:
                    tokens += [(Token.Scrollbar, '>' if middle_row else ' ')]

                # Newline.
                tokens_for_line.append(tokens)

        else:
            tokens = []

        self._rendered_rows = height
        self._rendered_columns = visible_columns
        self._total_columns = len(columns_)
        self._render_left_arrow = render_left_arrow
        self._render_right_arrow = render_right_arrow
        self._render_width = column_width * visible_columns + render_left_arrow + render_right_arrow + 1

        def get_line(i):
            return tokens_for_line[i]

        return UIContent(get_line=get_line, line_count=len(rows_))
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/layout/menus.py/MultiColumnCompletionMenuControl.create_content/swapped operands of `<`