예제 #1
0
    def show_items(self, cursor, items, prefix_length=0):
        """ Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        """
        if not items:
            return
        # Move cursor to start of the prefix to replace it
        # when a item is selected
        cursor.movePosition(QtGui.QTextCursor.Left, n=prefix_length)
        self._start_position = cursor.position()
        self._consecutive_tab = 1
        # Calculate the number of characters available.
        width = self._text_edit.document().textWidth()
        char_width = self._console_widget._get_font_width()
        displaywidth = int(max(10, (width / char_width) - 1))
        items_m, ci = text.compute_item_matrix(items,
                                               empty=' ',
                                               displaywidth=displaywidth)
        self._sliding_interval = SlidingInterval(len(items_m) - 1)

        self._items = items_m
        self._size = (ci['rows_numbers'], ci['columns_numbers'])
        self._old_cursor = cursor
        self._index = (0, 0)
        sjoin = lambda x: [
            y.ljust(w, ' ') for y, w in zip(x, ci['columns_width'])
        ]
        self._justified_items = list(map(sjoin, items_m))
        self._update_list(hilight=False)
예제 #2
0
    def show_items(self, cursor, items):
        """ Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        """
        if not items :
            return
        self._start_position = cursor.position()
        self._consecutive_tab = 1
        items_m, ci = text.compute_item_matrix(items, empty=' ')
        self._sliding_interval = SlidingInterval(len(items_m)-1)

        self._items = items_m
        self._size = (ci['rows_numbers'], ci['columns_numbers'])
        self._old_cursor = cursor
        self._index = (0, 0)
        sjoin = lambda x : [ y.ljust(w, ' ') for y, w in zip(x, ci['columns_width'])]
        self._justified_items = list(map(sjoin, items_m))
        self._update_list(hilight=False)
예제 #3
0
    def show_items(self, cursor, items):
        """ Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        """
        if not items:
            return
        self._start_position = cursor.position()
        self._consecutive_tab = 1
        items_m, ci = text.compute_item_matrix(items, empty=' ')
        self._sliding_interval = SlidingInterval(len(items_m) - 1)

        self._items = items_m
        self._size = (ci['rows_numbers'], ci['columns_numbers'])
        self._old_cursor = cursor
        self._index = (0, 0)
        sjoin = lambda x: [
            y.ljust(w, ' ') for y, w in zip(x, ci['columns_width'])
        ]
        self._justified_items = list(map(sjoin, items_m))
        self._update_list(hilight=False)
예제 #4
0
    def show_items(self, cursor, items):
        """ Shows the completion widget with 'items' at the position specified
            by 'cursor'.
        """
        if not items :
            return
        self._start_position = cursor.position()
        self._consecutive_tab = 1
        # Calculate the number of characters available.
        width = self._text_edit.document().textWidth()
        char_width = QtGui.QFontMetrics(self._console_widget.font).width(' ')
        displaywidth = int(max(10, (width / char_width) - 1))
        items_m, ci = text.compute_item_matrix(items, empty=' ',
                                               displaywidth=displaywidth)
        self._sliding_interval = SlidingInterval(len(items_m)-1)

        self._items = items_m
        self._size = (ci['rows_numbers'], ci['columns_numbers'])
        self._old_cursor = cursor
        self._index = (0, 0)
        sjoin = lambda x : [ y.ljust(w, ' ') for y, w in zip(x, ci['columns_width'])]
        self._justified_items = list(map(sjoin, items_m))
        self._update_list(hilight=False)