mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 14:04:52 +02:00
Implement setting of cursor color
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user