2024-08-20 21:09:10 +02:00
|
|
|
from typing import Tuple, Optional, Callable
|
2024-08-06 23:28:09 +02:00
|
|
|
|
2024-08-20 21:09:10 +02:00
|
|
|
class Driver:
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
2024-08-20 21:09:10 +02:00
|
|
|
this is akin to a big red button with a white "STOP" on top of it.
|
2024-08-21 15:02:44 +02:00
|
|
|
it is used to stop the runtime.
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
2024-08-20 21:09:10 +02:00
|
|
|
def stop(self) -> None: ...
|
2024-08-06 23:28:09 +02:00
|
|
|
|
|
|
|
|
2024-08-31 15:23:38 +02:00
|
|
|
def init() -> Driver: ...
|
|
|
|
def set_logger(logger_cb: Callable[[str], None], debug: bool) -> bool: ...
|
|
|
|
def connect(host: str, username: str, password: str) -> Promise[Client]: ...
|
2024-08-20 21:09:10 +02:00
|
|
|
|
2024-08-21 15:02:44 +02:00
|
|
|
class Promise[T]:
|
2024-08-20 21:09:10 +02:00
|
|
|
"""
|
|
|
|
This is a class akin to a future, which wraps a join handle from a spawned
|
|
|
|
task on the rust side. you may call .pyawait() on this promise to block
|
|
|
|
until we have a result, or return immediately if we already have one.
|
|
|
|
This only goes one way rust -> python.
|
2024-08-21 15:02:44 +02:00
|
|
|
|
|
|
|
It can either be used directly or you can wrap it inside a future python side.
|
2024-08-20 21:09:10 +02:00
|
|
|
"""
|
2024-08-22 15:22:51 +02:00
|
|
|
def wait(self) -> T: ...
|
|
|
|
def is_done(self) -> bool: ...
|
2024-08-20 21:09:10 +02:00
|
|
|
|
2024-08-31 15:23:38 +02:00
|
|
|
class Client:
|
|
|
|
"""
|
|
|
|
Handle to the actual client that manages the session. It manages the connection
|
|
|
|
to a server and joining/creating new workspaces
|
|
|
|
"""
|
|
|
|
def join_workspace(self, workspace: str) -> Promise[Workspace]: ...
|
|
|
|
def create_workspace(self, workspace: str) -> Promise[None]: ...
|
|
|
|
def delete_workspace(self, workspace: str) -> Promise[None]: ...
|
|
|
|
def invite_to_workspace(self, workspace: str, username: str) -> Promise[None]: ...
|
|
|
|
def list_workspaces(self, owned: bool, invited: bool) -> Promise[list[str]]: ...
|
|
|
|
def leave_workspace(self, workspace: str) -> bool: ...
|
|
|
|
def get_workspace(self, id: str) -> Workspace: ...
|
|
|
|
def active_workspaces(self) -> list[str]: ...
|
|
|
|
def user_id(self) -> str: ...
|
|
|
|
def user_name(self) -> str: ...
|
|
|
|
def refresh(self) -> Promise[None]: ...
|
|
|
|
|
|
|
|
class Workspace:
|
|
|
|
"""
|
|
|
|
Handle to a workspace inside codemp. It manages buffers.
|
|
|
|
A cursor is tied to the single workspace.
|
|
|
|
"""
|
|
|
|
def create(self, path: str) -> Promise[None]: ...
|
|
|
|
def attach(self, path: str) -> Promise[BufferController]: ...
|
|
|
|
def detach(self, path: str) -> bool: ...
|
|
|
|
def fetch_buffers(self) -> Promise[None]: ...
|
|
|
|
def fetch_users(self) -> Promise[None]: ...
|
|
|
|
def list_buffer_users(self, path: str) -> Promise[list[str]]: ...
|
|
|
|
def delete(self, path: str) -> Promise[None]: ...
|
|
|
|
def id(self) -> str: ...
|
|
|
|
def cursor(self) -> CursorController: ...
|
|
|
|
def buffer_by_name(self, path: str) -> Optional[BufferController]: ...
|
|
|
|
def buffer_list(self) -> list[str]: ...
|
|
|
|
def filetree(self, filter: Optional[str]) -> list[str]: ...
|
|
|
|
|
2024-08-09 09:14:27 +02:00
|
|
|
class TextChange:
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
|
|
|
Editor agnostic representation of a text change, it translate between internal
|
|
|
|
codemp text operations and editor operations
|
|
|
|
"""
|
2024-08-09 09:14:27 +02:00
|
|
|
start: int
|
|
|
|
end: int
|
2024-08-06 23:28:09 +02:00
|
|
|
content: str
|
|
|
|
|
2024-08-22 15:22:51 +02:00
|
|
|
def is_delete(self) -> bool: ...
|
|
|
|
def is_insert(self) -> bool: ...
|
|
|
|
def is_empty(self) -> bool: ...
|
|
|
|
def apply(self, txt: str) -> str: ...
|
2024-08-06 23:28:09 +02:00
|
|
|
|
|
|
|
|
2024-08-09 09:14:27 +02:00
|
|
|
class BufferController:
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
|
|
|
Handle to the controller for a specific buffer, which manages the back and forth
|
|
|
|
of operations to and from other peers.
|
|
|
|
"""
|
2024-09-05 02:33:35 +02:00
|
|
|
def path(self) -> str: ...
|
2024-08-22 15:22:51 +02:00
|
|
|
def content(self) -> Promise[str]: ...
|
2024-08-21 15:02:44 +02:00
|
|
|
def send(self,
|
|
|
|
start: int,
|
|
|
|
end: int,
|
2024-08-22 15:22:51 +02:00
|
|
|
txt: str) -> Promise[None]: ...
|
2024-08-23 20:41:07 +02:00
|
|
|
def try_recv(self) -> Promise[Optional[TextChange]]: ...
|
2024-08-22 15:22:51 +02:00
|
|
|
def recv(self) -> Promise[TextChange]: ...
|
|
|
|
def poll(self) -> Promise[None]: ...
|
|
|
|
def callback(self,
|
|
|
|
cb: Callable[[BufferController], None]) -> None: ...
|
|
|
|
def clear_callback(self) -> None: ...
|
|
|
|
def stop(self) -> bool: ...
|
2024-08-06 23:28:09 +02:00
|
|
|
|
|
|
|
|
2024-08-09 09:14:27 +02:00
|
|
|
|
|
|
|
class Cursor:
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
|
|
|
An Editor agnostic cursor position representation
|
|
|
|
"""
|
2024-08-06 23:28:09 +02:00
|
|
|
start: Tuple[int, int]
|
|
|
|
end: Tuple[int, int]
|
|
|
|
buffer: str
|
2024-08-17 23:47:28 +02:00
|
|
|
user: Optional[str] # can be an empty string
|
2024-08-06 23:28:09 +02:00
|
|
|
|
|
|
|
|
2024-08-09 09:14:27 +02:00
|
|
|
class CursorController:
|
2024-08-17 23:47:28 +02:00
|
|
|
"""
|
|
|
|
Handle to the controller for a workspace, which manages the back and forth of
|
|
|
|
cursor movements to and from other peers
|
|
|
|
"""
|
2024-08-21 15:02:44 +02:00
|
|
|
def send(self,
|
|
|
|
path: str,
|
|
|
|
start: Tuple[int, int],
|
2024-08-22 15:22:51 +02:00
|
|
|
end: Tuple[int, int]) -> Promise[None]: ...
|
2024-08-23 20:41:07 +02:00
|
|
|
def try_recv(self) -> Promise[Optional[Cursor]]: ...
|
2024-08-22 15:22:51 +02:00
|
|
|
def recv(self) -> Promise[Cursor]: ...
|
|
|
|
def poll(self) -> Promise[None]: ...
|
|
|
|
def callback(self,
|
|
|
|
cb: Callable[[CursorController], None]) -> None: ...
|
|
|
|
def clear_callback(self) -> None: ...
|
|
|
|
def stop(self) -> bool: ...
|
2024-08-06 23:28:09 +02:00
|
|
|
|