mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
feat: brought back the manual workspace implementation
This commit is contained in:
parent
07f656cbe5
commit
f743fbcb03
2 changed files with 64 additions and 70 deletions
|
@ -1,82 +1,77 @@
|
||||||
// We no can simply define decorate the pub impl block of workspace with
|
use crate::buffer::Controller as BufferController;
|
||||||
// #[pymethods], which means that this module is not really necessary anymore.
|
use crate::cursor::Controller as CursorController;
|
||||||
// In any case we will leave it here for the time being in case we need to come back to
|
use crate::workspace::Workspace;
|
||||||
// the manual version.
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
// use crate::buffer::Controller as BufferController;
|
#[pymethods]
|
||||||
// use crate::cursor::Controller as CursorController;
|
impl Workspace {
|
||||||
// use crate::workspace::Workspace;
|
// join a workspace
|
||||||
// use pyo3::prelude::*;
|
#[pyo3(name = "create")]
|
||||||
|
async fn pycreate(&self, path: String) -> crate::Result<()> {
|
||||||
|
self.create(path.as_str()).await
|
||||||
|
}
|
||||||
|
|
||||||
// #[pymethods]
|
#[pyo3(name = "attach")]
|
||||||
// impl Workspace {
|
async fn pyattach(&self, path: String) -> crate::Result<BufferController> {
|
||||||
// // join a workspace
|
self.attach(path.as_str()).await
|
||||||
// #[pyo3(name = "create")]
|
}
|
||||||
// async fn pycreate(&self, path: String) -> crate::Result<()> {
|
|
||||||
// self.create(path.as_str()).await
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[pyo3(name = "attach")]
|
#[pyo3(name = "detach")]
|
||||||
// async fn pyattach(&self, path: String) -> crate::Result<BufferController> {
|
fn pydetach(&self, path: String) -> bool {
|
||||||
// Ok(self.attach(path.as_str()).await?)
|
match self.detach(path.as_str()) {
|
||||||
// }
|
crate::workspace::worker::DetachResult::NotAttached => false,
|
||||||
|
crate::workspace::worker::DetachResult::Detaching => true,
|
||||||
|
crate::workspace::worker::DetachResult::AlreadyDetached => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "detach")]
|
#[pyo3(name = "event")]
|
||||||
// fn pydetach(&self, path: String) -> bool {
|
async fn pyevent(&self) -> crate::Result<crate::api::Event> {
|
||||||
// match self.detach(path.as_str()) {
|
self.event().await
|
||||||
// crate::workspace::worker::DetachResult::NotAttached => false,
|
}
|
||||||
// crate::workspace::worker::DetachResult::Detaching => true,
|
|
||||||
// crate::workspace::worker::DetachResult::AlreadyDetached => true,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[pyo3(name = "event")]
|
#[pyo3(name = "fetch_buffers")]
|
||||||
// async fn pyevent(&self) -> crate::Result<crate::api::Event> {
|
async fn pyfetch_buffers(&self) -> crate::Result<()> {
|
||||||
// self.event().await
|
self.fetch_buffers().await
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "fetch_buffers")]
|
#[pyo3(name = "fetch_users")]
|
||||||
// async fn pyfetch_buffers(&self) -> crate::Result<()> {
|
async fn pyfetch_users(&self) -> crate::Result<()> {
|
||||||
// self.fetch_buffers().await
|
self.fetch_users().await
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "fetch_users")]
|
#[pyo3(name = "list_buffer_users")]
|
||||||
// async fn pyfetch_users(&self) -> crate::Result<()> {
|
async fn pylist_buffer_users(&self, path: String) -> crate::Result<Vec<crate::api::User>> {
|
||||||
// self.fetch_users().await
|
self.list_buffer_users(path.as_str()).await
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "list_buffer_users")]
|
#[pyo3(name = "delete")]
|
||||||
// async fn pylist_buffer_users(&self, path: String) -> crate::Result<Vec<crate::api::User>> {
|
async fn pydelete(&self, path: String) -> crate::Result<()> {
|
||||||
// self.list_buffer_users(path.as_str()).await
|
self.delete(path.as_str()).await
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "delete")]
|
#[pyo3(name = "id")]
|
||||||
// async fn pydelete(&self, path: String) -> crate::Result<()> {
|
fn pyid(&self) -> String {
|
||||||
// self.delete(path.as_str()).await
|
self.id()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "id")]
|
#[pyo3(name = "cursor")]
|
||||||
// fn pyid(&self) -> String {
|
fn pycursor(&self) -> CursorController {
|
||||||
// self.id()
|
self.cursor()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "cursor")]
|
#[pyo3(name = "buffer_by_name")]
|
||||||
// fn pycursor(&self) -> CursorController {
|
fn pybuffer_by_name(&self, path: String) -> Option<BufferController> {
|
||||||
// self.cursor()
|
self.buffer_by_name(path.as_str())
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "buffer_by_name")]
|
#[pyo3(name = "buffer_list")]
|
||||||
// fn pybuffer_by_name(&self, path: String) -> Option<BufferController> {
|
fn pybuffer_list(&self) -> Vec<String> {
|
||||||
// self.buffer_by_name(path.as_str())
|
self.buffer_list()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[pyo3(name = "buffer_list")]
|
#[pyo3(name = "filetree")]
|
||||||
// fn pybuffer_list(&self) -> Vec<String> {
|
fn pyfiletree(&self) -> Vec<String> {
|
||||||
// self.buffer_list()
|
self.filetree()
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
// #[pyo3(name = "filetree")]
|
|
||||||
// fn pyfiletree(&self) -> Vec<String> {
|
|
||||||
// self.filetree()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
|
@ -142,7 +142,6 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "python", pyo3::pymethods)] //LMAO it works
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
/// create a new buffer in current workspace
|
/// create a new buffer in current workspace
|
||||||
pub async fn create(&self, path: &str) -> crate::Result<()> {
|
pub async fn create(&self, path: &str) -> crate::Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue