mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
chore: draft of user_list for java but its broken
This commit is contained in:
parent
db77fce3ab
commit
ba1a53c3a9
2 changed files with 31 additions and 0 deletions
10
dist/java/src/mp/code/Workspace.java
vendored
10
dist/java/src/mp/code/Workspace.java
vendored
|
@ -69,6 +69,16 @@ public final class Workspace {
|
||||||
return get_file_tree(this.ptr, filter.orElse(null), strict);
|
return get_file_tree(this.ptr, filter.orElse(null), strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static native String[] user_list(long self);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get names of all users currently in this workspace
|
||||||
|
* @return an array containing user display names
|
||||||
|
*/
|
||||||
|
public String[] userList() {
|
||||||
|
return user_list(this.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
private static native String[] active_buffers(long self);
|
private static native String[] active_buffers(long self);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,6 +76,27 @@ pub extern "system" fn Java_mp_code_Workspace_get_1file_1tree(
|
||||||
}).jexcept(&mut env).as_raw()
|
}).jexcept(&mut env).as_raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the user list.
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "system" fn Java_mp_code_Workspace_user_1list(
|
||||||
|
mut env: JNIEnv,
|
||||||
|
_class: JClass,
|
||||||
|
self_ptr: jlong,
|
||||||
|
) -> jobjectArray {
|
||||||
|
let workspace = unsafe { Box::leak(Box::from_raw(self_ptr as *mut Workspace)) };
|
||||||
|
|
||||||
|
let user_list = workspace.user_list();
|
||||||
|
env.find_class("java/lang/String")
|
||||||
|
.and_then(|class| env.new_object_array(user_list.len() as i32, class, JObject::null()))
|
||||||
|
.inspect(|arr| {
|
||||||
|
for (idx, path) in user_list.iter().enumerate() {
|
||||||
|
env.new_string(path)
|
||||||
|
.and_then(|path| env.set_object_array_element(arr, idx as i32, path))
|
||||||
|
.jexcept(&mut env)
|
||||||
|
}
|
||||||
|
}).jexcept(&mut env).as_raw()
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets a list of the active buffers.
|
/// Gets a list of the active buffers.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "system" fn Java_mp_code_Workspace_active_1buffers(
|
pub extern "system" fn Java_mp_code_Workspace_active_1buffers(
|
||||||
|
|
Loading…
Reference in a new issue