use super::*;
#[unsafe(no_mangle)]
pub extern "C" fn kui_set_key_focus(ptr: *mut KuiCtx, key: u64) {
guard((), || {
if let Some(c) = unsafe { ctx(ptr) } {
c.core().set_key_focus((key != 0).then_some(Key(key)));
}
});
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_focus(ptr: *mut KuiCtx, key: u64) {
guard((), || {
if let Some(c) = unsafe { ctx(ptr) } {
c.core().set_focus((key != 0).then_some(Key(key)));
}
});
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_key_of(ptr: *mut KuiCtx, label: KuiStr) -> u64 {
guard(0, || {
unsafe { ctx(ptr) }.map_or(0, |c| c.core().key_of(&kstr(label)).map_or(0, |k| k.0))
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_key_named(ptr: *mut KuiCtx, name: KuiStr) -> u64 {
guard(0, || {
unsafe { ctx(ptr) }.map_or(0, |c| c.core().key_named(&kstr(name)).map_or(0, |k| k.0))
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_focus_next(ptr: *mut KuiCtx, forward: bool) {
guard((), || {
if let Some(c) = unsafe { ctx(ptr) } {
c.core().focus_next(forward);
}
});
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_focused(ptr: *mut KuiCtx) -> u64 {
guard(0, || {
unsafe { ctx(ptr) }.map_or(0, |c| c.core().focus().map_or(0, |k| k.0))
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_focus_visible(ptr: *mut KuiCtx) -> bool {
guard(false, || {
unsafe { ctx(ptr) }.is_some_and(|c| c.core().focus_visible())
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_caret_visible(ptr: *mut KuiCtx) -> bool {
guard(true, || {
unsafe { ctx(ptr) }.is_none_or(|c| c.core().caret_visible())
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_set_caret_visible(ptr: *mut KuiCtx, visible: bool) {
guard((), || {
if let Some(c) = unsafe { ctx(ptr) } {
c.core().set_caret_visible(visible);
}
});
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_has_caret(ptr: *mut KuiCtx) -> bool {
guard(false, || {
unsafe { ctx(ptr) }.is_some_and(|c| c.core().has_caret())
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_caret_stamp(ptr: *mut KuiCtx) -> u64 {
guard(0, || {
unsafe { ctx(ptr) }.map_or(0, |c| c.core().caret_stamp())
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_focus_region(ptr: *mut KuiCtx, key: u64) {
guard((), || {
if let Some(c) = unsafe { ctx(ptr) } {
c.core().focus_region((key != 0).then_some(Key(key)));
}
});
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_region(ptr: *mut KuiCtx) -> u64 {
guard(0, || {
unsafe { ctx(ptr) }.map_or(0, |c| c.core().region().map_or(0, |k| k.0))
})
}
#[unsafe(no_mangle)]
pub extern "C" fn kui_is_focused(ptr: *mut KuiCtx, key: u64) -> bool {
guard(false, || {
unsafe { ctx(ptr) }.is_some_and(|c| c.core().is_focused(Key(key)))
})
}