def _tk_nvim_put(self, data):
# choose a Font instance
font = self._fnormal
if self._attrs.get('bold', False):
font = self._fbold
if self._attrs.get('italic', False):
font = self._fbolditalic if font == self._fbold else self._fitalic
# colors
fg = "#{0:0{1}x}".format(self._attrs.get('foreground', self._fg), 6)
bg = "#{0:0{1}x}".format(self._attrs.get('background', self._bg), 6)
# get the "text" and "rect" which correspond to the current cell
x, y = self._tk_get_coords(self._cursor_row, self._cursor_col)
items = self._canvas.find_overlapping(x, y, x + 1, y + 1)
if len(items) != 2:
# caught part the double-width character in the cell to the left,
# filter items which dont have the same horizontal coordinate as
# "x"
predicate = lambda item: self._canvas.coords(item)[0] == x
items = filter(predicate, items)
# rect has lower id than text, sort to unpack correctly
rect, text = sorted(items)
self._canvas.itemconfig(text, fill=fg, font=font, text=data or ' ')
self._canvas.itemconfig(rect, fill=bg)
self._tk_nvim_cursor_goto(self._cursor_row, self._cursor_col + 1)
评论列表
文章目录