Implement setting of cursor color

This commit is contained in:
Kovid Goyal
2016-10-21 09:23:03 +05:30
parent 864106a974
commit 0d51392e66
4 changed files with 34 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ get_zeroes.current_size = None
class Cursor:
__slots__ = ("x", "y", 'shape', 'blink', "hidden", 'fg', 'bg', 'bold', 'italic', 'reverse', 'strikethrough', 'decoration', 'decoration_fg',)
__slots__ = ("x", "y", 'shape', 'blink', "hidden", 'color', 'fg', 'bg', 'bold', 'italic', 'reverse', 'strikethrough', 'decoration', 'decoration_fg',)
def __init__(self, x: int=0, y: int=0):
self.x = x
@@ -35,6 +35,7 @@ class Cursor:
self.hidden = False
self.shape = None
self.blink = None
self.color = None
self.reset_display_attrs()
def reset_display_attrs(self):

View File

@@ -982,6 +982,15 @@ class Screen(QObject):
else: # DECLL
pass
def set_cursor_color(self, color_name):
try:
color_name = color_name.decode('utf-8') if color_name else None
except Exception:
return
old, self.cursor.color = self.cursor.color, color_name
if old != self.cursor.color:
self.cursor_changed(self.cursor)
def normal_keypad_mode(self):
pass # Useless for us, since Qt takes care of handling the numpad

View File

@@ -195,6 +195,11 @@ class TerminalWidget(QWidget):
r = QRect(self.cell_positions[x], self.line_positions[y], self.cell_width, self.cell_height)
self.last_drew_cursor_at = x, y
cc = self.cursor_color
if self.cursor.color:
q = QColor(self.cursor.color)
if q.isValid():
cc = q
cc.setAlphaF(self.opts.cursor_opacity)
def width(w=2, vert=True):
dpi = self.logicalDpiX() if vert else self.logicalDpiY()