Support different colors per completion column.
Now colors.completion.fg may be set to a list to specify a different color for each completion column. For example: :set colors.completion.fg [black,blue,white] will use black text for the first column, blue for the second, and white for the third. Setting to a single value still works and behaves as before. The default is unchanged from 'white'. Resolves #1794.
This commit is contained in:
parent
0a612db733
commit
57e2d407ce
@ -138,10 +138,10 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
|||||||
|
|
||||||
self._painter.translate(text_rect.left(), text_rect.top())
|
self._painter.translate(text_rect.left(), text_rect.top())
|
||||||
self._get_textdoc(index)
|
self._get_textdoc(index)
|
||||||
self._draw_textdoc(text_rect)
|
self._draw_textdoc(text_rect, index.column())
|
||||||
self._painter.restore()
|
self._painter.restore()
|
||||||
|
|
||||||
def _draw_textdoc(self, rect):
|
def _draw_textdoc(self, rect, col):
|
||||||
"""Draw the QTextDocument of an item.
|
"""Draw the QTextDocument of an item.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -156,7 +156,9 @@ class CompletionItemDelegate(QStyledItemDelegate):
|
|||||||
elif not self._opt.state & QStyle.State_Enabled:
|
elif not self._opt.state & QStyle.State_Enabled:
|
||||||
color = config.val.colors.completion.category.fg
|
color = config.val.colors.completion.category.fg
|
||||||
else:
|
else:
|
||||||
color = config.val.colors.completion.fg
|
colors = config.val.colors.completion.fg
|
||||||
|
# if multiple colors are set, use different colors per column
|
||||||
|
color = colors[col % len(colors)]
|
||||||
self._painter.setPen(color)
|
self._painter.setPen(color)
|
||||||
|
|
||||||
ctx = QAbstractTextDocumentLayout.PaintContext()
|
ctx = QAbstractTextDocumentLayout.PaintContext()
|
||||||
|
@ -1541,8 +1541,14 @@ zoom.text_only:
|
|||||||
|
|
||||||
colors.completion.fg:
|
colors.completion.fg:
|
||||||
default: white
|
default: white
|
||||||
type: QtColor
|
type:
|
||||||
desc: Text color of the completion widget.
|
name: ListOrValue
|
||||||
|
valtype: QtColor
|
||||||
|
desc: >-
|
||||||
|
Text color of the completion widget.
|
||||||
|
|
||||||
|
May be a single value to specify the color for all columns, or a list
|
||||||
|
specifying a different color for each column.
|
||||||
|
|
||||||
colors.completion.odd.bg:
|
colors.completion.odd.bg:
|
||||||
default: '#444444'
|
default: '#444444'
|
||||||
|
Loading…
Reference in New Issue
Block a user