Implement setting of cursor color
This commit is contained in:
@@ -27,7 +27,7 @@ get_zeroes.current_size = None
|
|||||||
|
|
||||||
class Cursor:
|
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):
|
def __init__(self, x: int=0, y: int=0):
|
||||||
self.x = x
|
self.x = x
|
||||||
@@ -35,6 +35,7 @@ class Cursor:
|
|||||||
self.hidden = False
|
self.hidden = False
|
||||||
self.shape = None
|
self.shape = None
|
||||||
self.blink = None
|
self.blink = None
|
||||||
|
self.color = None
|
||||||
self.reset_display_attrs()
|
self.reset_display_attrs()
|
||||||
|
|
||||||
def reset_display_attrs(self):
|
def reset_display_attrs(self):
|
||||||
|
|||||||
@@ -982,6 +982,15 @@ class Screen(QObject):
|
|||||||
else: # DECLL
|
else: # DECLL
|
||||||
pass
|
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):
|
def normal_keypad_mode(self):
|
||||||
pass # Useless for us, since Qt takes care of handling the numpad
|
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)
|
r = QRect(self.cell_positions[x], self.line_positions[y], self.cell_width, self.cell_height)
|
||||||
self.last_drew_cursor_at = x, y
|
self.last_drew_cursor_at = x, y
|
||||||
cc = self.cursor_color
|
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):
|
def width(w=2, vert=True):
|
||||||
dpi = self.logicalDpiX() if vert else self.logicalDpiY()
|
dpi = self.logicalDpiX() if vert else self.logicalDpiY()
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class Stream(object):
|
|||||||
events = frozenset(itertools.chain(
|
events = frozenset(itertools.chain(
|
||||||
basic.values(), escape.values(), sharp.values(), csi.values(),
|
basic.values(), escape.values(), sharp.values(), csi.values(),
|
||||||
["define_charset", "select_other_charset"],
|
["define_charset", "select_other_charset"],
|
||||||
["set_icon", "set_title"], # OSC.
|
["set_icon", "set_title", 'set_cursor_color'], # OSC.
|
||||||
["draw", "debug"]))
|
["draw", "debug"]))
|
||||||
|
|
||||||
#: A regular expression pattern matching everything what can be
|
#: A regular expression pattern matching everything what can be
|
||||||
@@ -321,20 +321,31 @@ class Stream(object):
|
|||||||
csi_dispatch[char](*params)
|
csi_dispatch[char](*params)
|
||||||
break # CSI is finished.
|
break # CSI is finished.
|
||||||
elif char == OSC:
|
elif char == OSC:
|
||||||
code = yield
|
code = bytearray()
|
||||||
param = bytearray()
|
|
||||||
while True:
|
while True:
|
||||||
char = yield
|
char = yield
|
||||||
if char == ST or char == ctrl.BEL:
|
if char == ST or char == ctrl.BEL or char == b';':
|
||||||
break
|
break
|
||||||
else:
|
code.extend(char)
|
||||||
param.extend(char)
|
code = bytes(code)
|
||||||
|
param = bytearray()
|
||||||
|
if char == b';':
|
||||||
|
while True:
|
||||||
|
char = yield
|
||||||
|
if char == ST or char == ctrl.BEL:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
param.extend(char)
|
||||||
|
|
||||||
param = bytes(param[1:]) # Drop the ;.
|
param = bytes(param)
|
||||||
if code in b"01":
|
if code in b"01":
|
||||||
listener.set_icon_name(param)
|
listener.set_icon_name(param)
|
||||||
if code in b"02":
|
if code in b"02":
|
||||||
listener.set_title(param)
|
listener.set_title(param)
|
||||||
|
elif code == b"12":
|
||||||
|
listener.set_cursor_color(param)
|
||||||
|
elif code == b"112":
|
||||||
|
listener.set_cursor_color(b'')
|
||||||
elif char == DCS:
|
elif char == DCS:
|
||||||
# See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Device-Control-functions
|
# See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Device-Control-functions
|
||||||
code = yield
|
code = yield
|
||||||
|
|||||||
Reference in New Issue
Block a user