mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
feat: lua leave, detach, delete
This commit is contained in:
parent
e736646b8c
commit
0aa7690533
1 changed files with 13 additions and 3 deletions
|
@ -3,6 +3,7 @@ use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::api::Cursor;
|
use crate::api::Cursor;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::workspace::DetachResult;
|
||||||
use mlua::prelude::*;
|
use mlua::prelude::*;
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
|
|
||||||
|
@ -61,6 +62,10 @@ impl LuaUserData for CodempClient {
|
||||||
Ok(cursor)
|
Ok(cursor)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
methods.add_method("leave_workspace", |_, this, (session,):(String,)| {
|
||||||
|
Ok(this.leave_workspace(&session))
|
||||||
|
});
|
||||||
|
|
||||||
methods.add_method("get_workspace", |_, this, (session,):(String,)| Ok(this.get_workspace(&session)));
|
methods.add_method("get_workspace", |_, this, (session,):(String,)| Ok(this.get_workspace(&session)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +78,17 @@ impl LuaUserData for CodempWorkspace {
|
||||||
Ok(RT.block_on(async { this.create(&name).await })?)
|
Ok(RT.block_on(async { this.create(&name).await })?)
|
||||||
});
|
});
|
||||||
|
|
||||||
methods.add_method("attach_buffer", |_, this, (name,):(String,)| {
|
methods.add_method("attach", |_, this, (name,):(String,)| {
|
||||||
Ok(RT.block_on(async { this.attach(&name).await })?)
|
Ok(RT.block_on(async { this.attach(&name).await })?)
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO disconnect_buffer
|
methods.add_method("detach", |_, this, (name,):(String,)| {
|
||||||
// TODO leave_workspace:w
|
Ok(matches!(this.detach(&name), DetachResult::Detaching | DetachResult::AlreadyDetached))
|
||||||
|
});
|
||||||
|
|
||||||
|
methods.add_method("delete_buffer", |_, this, (name,):(String,)| {
|
||||||
|
Ok(RT.block_on(this.delete(&name))?)
|
||||||
|
});
|
||||||
|
|
||||||
methods.add_method("get_buffer", |_, this, (name,):(String,)| Ok(this.buffer_by_name(&name)));
|
methods.add_method("get_buffer", |_, this, (name,):(String,)| Ok(this.buffer_by_name(&name)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue