mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-22 21:04:53 +01:00
chore: last consistency fixes in glues
Co-authored-by: zaaarf <me@zaaarf.foo>
This commit is contained in:
parent
96a8b1a88f
commit
6f04c38779
6 changed files with 75 additions and 47 deletions
12
dist/java/src/mp/code/Client.java
vendored
12
dist/java/src/mp/code/Client.java
vendored
|
@ -34,17 +34,17 @@ public final class Client {
|
|||
*/
|
||||
public static native Client connect(Config config) throws ConnectionException;
|
||||
|
||||
private static native User get_user(long self);
|
||||
private static native User current_user(long self);
|
||||
|
||||
/**
|
||||
* Gets information about the current user.
|
||||
* @return a {@link User} object representing the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return get_user(this.ptr);
|
||||
public User currentUser() {
|
||||
return current_user(this.ptr);
|
||||
}
|
||||
|
||||
private static native Workspace join_workspace(long self, String workspaceId) throws ConnectionException;
|
||||
private static native Workspace attach_workspace(long self, String workspaceId) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* Joins a {@link Workspace} and returns it.
|
||||
|
@ -52,8 +52,8 @@ public final class Client {
|
|||
* @return the relevant {@link Workspace}
|
||||
* @throws ConnectionException if an error occurs in communicating with the server
|
||||
*/
|
||||
public Workspace joinWorkspace(String workspaceId) throws ConnectionException {
|
||||
return join_workspace(this.ptr, workspaceId);
|
||||
public Workspace attachWorkspace(String workspaceId) throws ConnectionException {
|
||||
return attach_workspace(this.ptr, workspaceId);
|
||||
}
|
||||
|
||||
private static native void create_workspace(long self, String workspaceId) throws ConnectionRemoteException;
|
||||
|
|
30
dist/java/src/mp/code/Workspace.java
vendored
30
dist/java/src/mp/code/Workspace.java
vendored
|
@ -25,24 +25,24 @@ public final class Workspace {
|
|||
Extensions.CLEANER.register(this, () -> free(ptr));
|
||||
}
|
||||
|
||||
private static native String get_workspace_id(long self);
|
||||
private static native String id(long self);
|
||||
|
||||
/**
|
||||
* Gets the unique identifier of the current workspace.
|
||||
* @return the identifier
|
||||
*/
|
||||
public String getWorkspaceId() {
|
||||
return get_workspace_id(this.ptr);
|
||||
public String id() {
|
||||
return id(this.ptr);
|
||||
}
|
||||
|
||||
private static native CursorController get_cursor(long self);
|
||||
private static native CursorController cursor(long self);
|
||||
|
||||
/**
|
||||
* Gets the {@link CursorController} for the current workspace.
|
||||
* @return the {@link CursorController}
|
||||
*/
|
||||
public CursorController getCursor() {
|
||||
return get_cursor(this.ptr);
|
||||
public CursorController cursor() {
|
||||
return cursor(this.ptr);
|
||||
}
|
||||
|
||||
private static native BufferController get_buffer(long self, String path);
|
||||
|
@ -57,7 +57,7 @@ public final class Workspace {
|
|||
return Optional.ofNullable(get_buffer(this.ptr, path));
|
||||
}
|
||||
|
||||
private static native String[] get_file_tree(long self, String filter, boolean strict);
|
||||
private static native String[] filetree(long self, String filter, boolean strict);
|
||||
|
||||
/**
|
||||
* Gets the file tree for this workspace, optionally filtering it.
|
||||
|
@ -66,8 +66,8 @@ public final class Workspace {
|
|||
* @return an array containing file tree as flat paths
|
||||
*/
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
public String[] getFileTree(Optional<String> filter, boolean strict) {
|
||||
return get_file_tree(this.ptr, filter.orElse(null), strict);
|
||||
public String[] filetree(Optional<String> filter, boolean strict) {
|
||||
return filetree(this.ptr, filter.orElse(null), strict);
|
||||
}
|
||||
|
||||
private static native String[] active_buffers(long self);
|
||||
|
@ -102,7 +102,7 @@ public final class Workspace {
|
|||
create_buffer(this.ptr, path);
|
||||
}
|
||||
|
||||
private static native BufferController attach_to_buffer(long self, String path) throws ConnectionException;
|
||||
private static native BufferController attach_buffer(long self, String path) throws ConnectionException;
|
||||
|
||||
/**
|
||||
* Attaches to an existing buffer with the given path, if present.
|
||||
|
@ -110,19 +110,19 @@ public final class Workspace {
|
|||
* @return the {@link BufferController} associated with that path
|
||||
* @throws ConnectionException if an error occurs in communicating with the server, or if the buffer did not exist
|
||||
*/
|
||||
public BufferController attachToBuffer(String path) throws ConnectionException {
|
||||
return attach_to_buffer(ptr, path);
|
||||
public BufferController attachBuffer(String path) throws ConnectionException {
|
||||
return attach_buffer(ptr, path);
|
||||
}
|
||||
|
||||
private static native boolean detach_from_buffer(long self, String path);
|
||||
private static native boolean detach_buffer(long self, String path);
|
||||
|
||||
/**
|
||||
* Detaches from a given buffer.
|
||||
* @param path the path of the buffer to detach from
|
||||
* @return a boolean, true only if there are still dangling references preventing controller from stopping
|
||||
*/
|
||||
public boolean detachFromBuffer(String path) {
|
||||
return detach_from_buffer(this.ptr, path);
|
||||
public boolean detachBuffer(String path) {
|
||||
return detach_buffer(this.ptr, path);
|
||||
}
|
||||
|
||||
private static native void fetch_buffers(long self) throws ConnectionRemoteException;
|
||||
|
|
44
dist/lua/annotations.lua
vendored
44
dist/lua/annotations.lua
vendored
|
@ -162,12 +162,17 @@ function MaybeBufferUpdatePromise:and_then(cb) end
|
|||
|
||||
|
||||
---@class (exact) Client
|
||||
---@field id string uuid of local user
|
||||
---@field username string name of local user
|
||||
---@field active_workspaces string[] array of all currently active workspace names
|
||||
---the effective local client, handling connecting to codemp server
|
||||
local Client = {}
|
||||
|
||||
---@return User
|
||||
---current logged in user for this client
|
||||
function Client:current_user() end
|
||||
|
||||
---@return string[]
|
||||
---array of all currently active workspace names
|
||||
function Client:active_workspaces() end
|
||||
|
||||
---@return NilPromise
|
||||
---@async
|
||||
---@nodiscard
|
||||
|
@ -179,7 +184,7 @@ function Client:refresh() end
|
|||
---@async
|
||||
---@nodiscard
|
||||
---join requested workspace if possible and subscribe to event bus
|
||||
function Client:join_workspace(ws) end
|
||||
function Client:attach_workspace(ws) end
|
||||
|
||||
---@param ws string workspace id to create
|
||||
---@return NilPromise
|
||||
|
@ -222,26 +227,41 @@ function Client:get_workspace(ws) end
|
|||
|
||||
|
||||
|
||||
---@class User
|
||||
---@field id string user uuid
|
||||
---@field name string user display name
|
||||
|
||||
|
||||
|
||||
---@class (exact) Workspace
|
||||
---@field name string workspace name
|
||||
---@field cursor CursorController workspace cursor controller
|
||||
---@field active_buffers string[] array of all currently active buffer names
|
||||
---a joined codemp workspace
|
||||
local Workspace = {}
|
||||
|
||||
---@return string
|
||||
---workspace id
|
||||
function Workspace:id() end
|
||||
|
||||
---@return string[]
|
||||
---array of all currently active buffer names
|
||||
function Workspace:active_buffers() end
|
||||
|
||||
---@return CursorController
|
||||
---reference to workspace's CursorController
|
||||
function Workspace:cursor() end
|
||||
|
||||
---@param path string relative path ("name") of new buffer
|
||||
---@return NilPromise
|
||||
---@async
|
||||
---@nodiscard
|
||||
---create a new empty buffer
|
||||
function Workspace:create(path) end
|
||||
function Workspace:create_buffer(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to delete
|
||||
---@return NilPromise
|
||||
---@async
|
||||
---@nodiscard
|
||||
---delete buffer from workspace
|
||||
function Workspace:delete(path) end
|
||||
function Workspace:delete_buffer(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to get
|
||||
---@return BufferController?
|
||||
|
@ -253,12 +273,12 @@ function Workspace:get_buffer(path) end
|
|||
---@async
|
||||
---@nodiscard
|
||||
---attach to a remote buffer, synching content and changes and returning its controller
|
||||
function Workspace:attach(path) end
|
||||
function Workspace:attach_buffer(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to detach from
|
||||
---@return boolean success
|
||||
---detach from an active buffer, closing all streams. returns false if there are still dangling references
|
||||
function Workspace:detach(path) end
|
||||
function Workspace:detach_buffer(path) end
|
||||
|
||||
---@param filter? string apply a filter to the return elements
|
||||
---@param strict? boolean whether to strictly match or just check whether it starts with it
|
||||
|
@ -266,7 +286,7 @@ function Workspace:detach(path) end
|
|||
---return the list of available buffers in this workspace, as relative paths from workspace root
|
||||
function Workspace:filetree(filter, strict) end
|
||||
|
||||
---@return string[]
|
||||
---@return User[]
|
||||
---return all names of users currently in this workspace
|
||||
function Workspace:user_list() end
|
||||
|
||||
|
|
25
dist/py/src/codemp/codemp.pyi
vendored
25
dist/py/src/codemp/codemp.pyi
vendored
|
@ -7,6 +7,13 @@ class Driver:
|
|||
"""
|
||||
def stop(self) -> None: ...
|
||||
|
||||
class User:
|
||||
"""
|
||||
A remote user, with uuid and username
|
||||
"""
|
||||
id: str
|
||||
name: str
|
||||
|
||||
class Config:
|
||||
"""
|
||||
Configuration data structure for codemp clients
|
||||
|
@ -40,7 +47,7 @@ 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 attach_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]: ...
|
||||
|
@ -48,8 +55,7 @@ class Client:
|
|||
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 current_user(self) -> User: ...
|
||||
def refresh(self) -> Promise[None]: ...
|
||||
|
||||
class Event:
|
||||
|
@ -60,17 +66,18 @@ 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 create_buffer(self, path: str) -> Promise[None]: ...
|
||||
def attach_buffer(self, path: str) -> Promise[BufferController]: ...
|
||||
def detach_buffer(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 delete_buffer(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 get_buffer(self, path: str) -> Optional[BufferController]: ...
|
||||
def user_list(self) -> list[User]: ...
|
||||
def active_buffers(self) -> list[str]: ...
|
||||
def filetree(self, filter: Optional[str], strict: bool) -> list[str]: ...
|
||||
def recv(self) -> Promise[Event]: ...
|
||||
def try_recv(self) -> Promise[Optional[Event]]: ...
|
||||
|
|
|
@ -6,6 +6,7 @@ use codemp_proto::workspace::workspace_event::Event as WorkspaceEventInner;
|
|||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(any(feature = "py", feature = "py-noabi"), pyo3::pyclass)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serialize", serde(tag = "type"))]
|
||||
pub enum Event {
|
||||
/// Fired when the file tree changes.
|
||||
/// Contains the modified buffer path (deleted, created or renamed).
|
||||
|
|
|
@ -9,13 +9,13 @@ use jni_toolbox::jni;
|
|||
|
||||
/// Get the workspace id.
|
||||
#[jni(package = "mp.code", class = "Workspace")]
|
||||
fn get_workspace_id(workspace: &mut Workspace) -> String {
|
||||
fn id(workspace: &mut Workspace) -> String {
|
||||
workspace.id()
|
||||
}
|
||||
|
||||
/// Get a cursor controller by name and returns a pointer to it.
|
||||
#[jni(package = "mp.code", class = "Workspace")]
|
||||
fn get_cursor(workspace: &mut Workspace) -> crate::cursor::Controller {
|
||||
fn cursor(workspace: &mut Workspace) -> crate::cursor::Controller {
|
||||
workspace.cursor()
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ fn get_buffer(workspace: &mut Workspace, path: String) -> Option<crate::buffer::
|
|||
|
||||
/// Get the filetree.
|
||||
#[jni(package = "mp.code", class = "Workspace")]
|
||||
fn get_file_tree(workspace: &mut Workspace, filter: Option<String>, strict: bool) -> Vec<String> {
|
||||
fn filetree(workspace: &mut Workspace, filter: Option<String>, strict: bool) -> Vec<String> {
|
||||
workspace.filetree(filter.as_deref(), strict)
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ fn create_buffer(workspace: &mut Workspace, path: String) -> Result<(), RemoteEr
|
|||
super::tokio().block_on(workspace.create_buffer(&path))
|
||||
}
|
||||
|
||||
/// Attach to a buffer and return a pointer to its [crate::buffer::Controller].
|
||||
/// Attach to a buffer and return a pointer to its [`crate::buffer::Controller`].
|
||||
#[jni(package = "mp.code", class = "Workspace")]
|
||||
fn attach_to_buffer(
|
||||
fn attach_buffer(
|
||||
workspace: &mut Workspace,
|
||||
path: String,
|
||||
) -> Result<crate::buffer::Controller, ConnectionError> {
|
||||
|
|
Loading…
Reference in a new issue