parent
edda386827
commit
074b6965e2
11 changed files with 131 additions and 106 deletions
|
@ -1,5 +1,5 @@
|
|||
use super::{
|
||||
BoolExt,
|
||||
BoolExt, MacKeyboardLayout,
|
||||
attributed_string::{NSAttributedString, NSMutableAttributedString},
|
||||
events::key_to_native,
|
||||
is_macos_version_at_least, renderer, screen_capture,
|
||||
|
@ -1579,45 +1579,6 @@ impl UTType {
|
|||
}
|
||||
}
|
||||
|
||||
struct MacKeyboardLayout {
|
||||
id: String,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl PlatformKeyboardLayout for MacKeyboardLayout {
|
||||
fn id(&self) -> &str {
|
||||
&self.id
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl MacKeyboardLayout {
|
||||
fn new() -> Self {
|
||||
unsafe {
|
||||
let current_keyboard = TISCopyCurrentKeyboardLayoutInputSource();
|
||||
|
||||
let id: *mut Object = TISGetInputSourceProperty(
|
||||
current_keyboard,
|
||||
kTISPropertyInputSourceID as *const c_void,
|
||||
);
|
||||
let id: *const std::os::raw::c_char = msg_send![id, UTF8String];
|
||||
let id = CStr::from_ptr(id).to_str().unwrap().to_string();
|
||||
|
||||
let name: *mut Object = TISGetInputSourceProperty(
|
||||
current_keyboard,
|
||||
kTISPropertyLocalizedName as *const c_void,
|
||||
);
|
||||
let name: *const std::os::raw::c_char = msg_send![name, UTF8String];
|
||||
let name = CStr::from_ptr(name).to_str().unwrap().to_string();
|
||||
|
||||
Self { id, name }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ClipboardItem;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue