mirror of
https://github.com/hexedtech/codemp-sublime.git
synced 2024-11-25 00:04:49 +01:00
it works, (minor touches still needed)
Former-commit-id: edfad18103da76426b4eb3f62174a9654e8595d8
This commit is contained in:
parent
36085c0639
commit
280d6314c9
1 changed files with 7 additions and 6 deletions
13
plugin.py
13
plugin.py
|
@ -27,7 +27,6 @@ _regions_colors = [
|
||||||
"region.pinkish"
|
"region.pinkish"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
## Initialisation and Deinitialisation
|
## Initialisation and Deinitialisation
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
@ -151,26 +150,27 @@ async def join_workspace(session):
|
||||||
|
|
||||||
async def move_cursor(cursor_controller):
|
async def move_cursor(cursor_controller):
|
||||||
global _regions_colors
|
global _regions_colors
|
||||||
# print("received cursor event", cursor_event.start, cursor_event.end, cursor_event.buffer)
|
|
||||||
|
|
||||||
|
status_log("spinning up cursor worker...")
|
||||||
# TODO: make the matching user/color more solid. now all users have one color cursor.
|
# TODO: make the matching user/color more solid. now all users have one color cursor.
|
||||||
# Maybe make all cursors the same color and only use annotations as a discriminant.
|
# Maybe make all cursors the same color and only use annotations as a discriminant.
|
||||||
# idea: use a user id hash map that maps to a color.
|
# idea: use a user id hash map that maps to a color.
|
||||||
try:
|
try:
|
||||||
while cursor_event := await cursor_controller.recv():
|
while cursor_event := await cursor_controller.recv():
|
||||||
buffer = get_buffer_from_remote_name(cursor_event.buffer)
|
buffer = get_buffer_from_remote_name(cursor_event.buffer)
|
||||||
|
|
||||||
if buffer:
|
if buffer:
|
||||||
view = buffer.buffer.primary_view()
|
reg = rowcol_to_region(buffer.view, cursor_event.start, cursor_event.end)
|
||||||
reg = rowcol_to_region(view, cursor_event.start, cursor_event.end)
|
|
||||||
reg_flags = sublime.RegionFlags.DRAW_EMPTY | sublime.RegionFlags.DRAW_NO_FILL
|
reg_flags = sublime.RegionFlags.DRAW_EMPTY | sublime.RegionFlags.DRAW_NO_FILL
|
||||||
|
|
||||||
view.add_regions(
|
buffer.view.add_regions(
|
||||||
"codemp_cursors",
|
"codemp_cursors",
|
||||||
[reg],
|
[reg],
|
||||||
flags = reg_flags,
|
flags = reg_flags,
|
||||||
scope=_regions_colors[2],
|
scope=_regions_colors[hash(cursor_event.user) % len(_regions_colors)],
|
||||||
annotations = [cursor_event.user],
|
annotations = [cursor_event.user],
|
||||||
annotation_color="#000")
|
annotation_color="#000")
|
||||||
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
status_log("cursor worker stopped...")
|
status_log("cursor worker stopped...")
|
||||||
|
|
||||||
|
@ -252,6 +252,7 @@ class CodempSublimeBuffer():
|
||||||
while text_change := await self.controller.recv():
|
while text_change := await self.controller.recv():
|
||||||
# In case a change arrives to a background buffer, just apply it. We are not listening on it.
|
# In case a change arrives to a background buffer, just apply it. We are not listening on it.
|
||||||
# Otherwise, interrupt the listening to avoid echoing back the change just received.
|
# Otherwise, interrupt the listening to avoid echoing back the change just received.
|
||||||
|
status_log("recieved txt change: ")
|
||||||
active = is_active(self.view)
|
active = is_active(self.view)
|
||||||
if active:
|
if active:
|
||||||
safe_listener_detach(_txt_change_listener)
|
safe_listener_detach(_txt_change_listener)
|
||||||
|
|
Loading…
Reference in a new issue