mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
Start work on specifying a color for extra cursors
This commit is contained in:
parent
3239cec409
commit
da641982e2
3 changed files with 76 additions and 17 deletions
|
|
@ -1594,13 +1594,15 @@ class TestScreen(BaseTest):
|
|||
s = self.create_screen()
|
||||
c = s.callbacks
|
||||
# Test detection
|
||||
parse_bytes(s, b'\x1b[> q') # ]
|
||||
self.ae(c.wtcbuf, b'\x1b[>-2;-1;1;2;3 q') # ]
|
||||
def ec(payload=''):
|
||||
return f'\x1b[>{payload} q'.encode() # ]
|
||||
parse_bytes(s, ec())
|
||||
self.ae(c.wtcbuf, ec('-5;-4;-3;-2;-1;1;2;3'))
|
||||
|
||||
def current() -> dict[int, tuple[int, int]]:
|
||||
ans = {}
|
||||
c.clear()
|
||||
parse_bytes(s, '\x1b[>-2 q'.encode()) # ]
|
||||
parse_bytes(s, ec('-2'))
|
||||
for entry in c.wtcbuf[6:-2].decode().split(';'):
|
||||
if entry:
|
||||
which, _, y, x = map(int, entry.split(':'))
|
||||
|
|
@ -1615,10 +1617,10 @@ class TestScreen(BaseTest):
|
|||
parse_bytes(s, ''.join(buf).encode() + b' q')
|
||||
if region:
|
||||
if region is True:
|
||||
parse_bytes(s, f'\x1b[>{which};4 q'.encode()) # ]
|
||||
parse_bytes(s, ec(f'{which};4'))
|
||||
else:
|
||||
left, top, right, bottom = region
|
||||
parse_bytes(s, f'\x1b[>{which};4:{top+1}:{left+1}:{bottom+1}:{right+1} q'.encode()) # ]
|
||||
parse_bytes(s, ec(f'{which};4:{top+1}:{left+1}:{bottom+1}:{right+1}'))
|
||||
return current()
|
||||
|
||||
self.ae(a(1, region=True), {1:{(x, y) for x in range(s.columns) for y in range(s.lines)}})
|
||||
|
|
@ -1628,13 +1630,33 @@ class TestScreen(BaseTest):
|
|||
self.ae(a(0, (1, 2), (2, 3)), {-1: {(2, 2)}, 2: {(1, 3)}})
|
||||
self.ae(a(0, region=True), {})
|
||||
s.cursor.x, s.cursor.y = 1, 2
|
||||
parse_bytes(s, b'\x1b[>3;0 q') # ]
|
||||
parse_bytes(s, ec('3;0'))
|
||||
self.ae(current(), {3: {(1, 2)}})
|
||||
parse_bytes(s, b'\x1b[>3;2:3 q') # ]
|
||||
parse_bytes(s, ec('3;2:3'))
|
||||
self.ae(current(), {3: {(1, 2)}})
|
||||
parse_bytes(s, b'\x1b[>0;4:3:1:4 q') # ]
|
||||
parse_bytes(s, ec('0;4:3:1:4'))
|
||||
self.ae(current(), {})
|
||||
|
||||
def sc(op, r=0, g=0, b=0, slot=-3):
|
||||
parse_bytes(s, ec(f'{slot};{op}:{r}:{g}:{b}'))
|
||||
c.clear()
|
||||
parse_bytes(s, ec('-5'))
|
||||
for x in c.wtcbuf[3:-2].decode().split(';')[1:]:
|
||||
parts = x.split(':')
|
||||
if int(parts[0]) == slot:
|
||||
if op < 2:
|
||||
self.ae(op, int(parts[1]))
|
||||
elif op == 2:
|
||||
self.ae((op, r, g, b), tuple(map(int, parts[1:])))
|
||||
else:
|
||||
self.ae((op, r), tuple(map(int, parts[1:])))
|
||||
break
|
||||
for slot in (-3, -4):
|
||||
sc(0, slot=slot)
|
||||
sc(1, slot=slot)
|
||||
sc(2, 1, 2, 3, slot=slot)
|
||||
sc(5, 13, slot=slot)
|
||||
|
||||
|
||||
def detect_url(self, scale=1):
|
||||
s = self.create_screen(cols=30 * scale)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue