mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-21 23:04:49 +01:00
fix(lua): add Delta object
This commit is contained in:
parent
29fde1ad24
commit
b821cdc152
2 changed files with 19 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use crate::api::change::{Acknowledgeable, Delta};
|
||||
use crate::buffer::controller::BufferAck;
|
||||
use mlua::prelude::*;
|
||||
use mlua_codemp_patch as mlua;
|
||||
|
||||
|
@ -59,3 +61,16 @@ impl LuaUserData for CodempTextChange {
|
|||
methods.add_method("apply", |_, this, (txt,): (String,)| Ok(this.apply(&txt)));
|
||||
}
|
||||
}
|
||||
|
||||
impl LuaUserData for Delta<BufferAck> {
|
||||
fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F) {
|
||||
fields.add_field_method_get("change", |_, this| Ok(this.change.clone()));
|
||||
fields.add_field_method_get("ack", |_, this| Ok(this.ack.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
impl LuaUserData for BufferAck {
|
||||
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_method_mut("send", |_, this, ()| Ok(this.send()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
use crate::ext::IgnorableError;
|
||||
use crate::prelude::*;
|
||||
use crate::api::change::Delta;
|
||||
use crate::buffer::controller::BufferAck;
|
||||
use mlua::prelude::*;
|
||||
use mlua_codemp_patch as mlua;
|
||||
|
||||
|
@ -111,4 +113,6 @@ callback_args! {
|
|||
MaybeCursor: Option<CodempCursor>,
|
||||
TextChange: CodempTextChange,
|
||||
MaybeTextChange: Option<CodempTextChange>,
|
||||
Delta: Delta<BufferAck>,
|
||||
MaybeDelta: Option<Delta<BufferAck>>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue