2020-03-07 14:35:18 +11:00
|
|
|
//! This module provides some basic wrappers for Pasteboard functionality. It's currently not an
|
|
|
|
//! exhaustive clone, but feel free to pull request accordingly!
|
|
|
|
|
2020-03-18 10:55:09 +11:00
|
|
|
use crate::foundation::NSString;
|
2020-03-07 14:35:18 +11:00
|
|
|
|
|
|
|
/// Constants for the standard system pasteboard names.
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub enum PasteboardName {
|
2020-03-11 14:09:24 +11:00
|
|
|
/// The dragging/dropping pasteboard.
|
2020-03-07 14:35:18 +11:00
|
|
|
Drag,
|
2020-03-11 14:09:24 +11:00
|
|
|
|
|
|
|
/// The find pasteboard.
|
2020-03-07 14:35:18 +11:00
|
|
|
Find,
|
2020-03-11 14:09:24 +11:00
|
|
|
|
|
|
|
/// The font pasteboard.
|
2020-03-07 14:35:18 +11:00
|
|
|
Font,
|
2020-03-11 14:09:24 +11:00
|
|
|
|
|
|
|
/// The general pasteboard.
|
2020-03-07 14:35:18 +11:00
|
|
|
General,
|
2020-03-11 14:09:24 +11:00
|
|
|
|
|
|
|
/// The ruler pasteboard.
|
2020-03-07 14:35:18 +11:00
|
|
|
Ruler
|
|
|
|
}
|
|
|
|
|
2020-03-18 10:55:09 +11:00
|
|
|
impl From<PasteboardName> for NSString {
|
|
|
|
fn from(name: PasteboardName) -> Self {
|
|
|
|
NSString::new(match name {
|
|
|
|
PasteboardName::Drag => "Apple CFPasteboard drag",
|
|
|
|
PasteboardName::Find => "Apple CFPasteboard find",
|
|
|
|
PasteboardName::Font => "Apple CFPasteboard font",
|
|
|
|
PasteboardName::General => "Apple CFPasteboard general",
|
|
|
|
PasteboardName::Ruler => "Apple CFPasteboard ruler"
|
|
|
|
})
|
2020-03-07 14:35:18 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Represents different Pasteboard types that can be referred to.
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub enum PasteboardType {
|
|
|
|
/// URL data for one file or resource.
|
|
|
|
URL,
|
|
|
|
|
|
|
|
/// Color data.
|
|
|
|
Color,
|
|
|
|
|
|
|
|
/// A file URL.
|
|
|
|
FileURL,
|
|
|
|
|
|
|
|
/// Font and character information.
|
|
|
|
Font,
|
|
|
|
|
|
|
|
/// Type for HTML content.
|
|
|
|
HTML,
|
|
|
|
|
|
|
|
/// Multiple text selection.
|
|
|
|
MultipleTextSelection,
|
|
|
|
|
|
|
|
/// PDF data.
|
|
|
|
PDF,
|
|
|
|
|
|
|
|
/// PNG image data.
|
|
|
|
PNG,
|
|
|
|
|
|
|
|
/// Rich Text Format (RTF) data.
|
|
|
|
RTF,
|
|
|
|
|
|
|
|
/// RTFD formatted file contents.
|
|
|
|
RTFD,
|
|
|
|
|
|
|
|
/// Paragraph formatting information.
|
|
|
|
Ruler,
|
|
|
|
|
|
|
|
/// Sound data.
|
|
|
|
Sound,
|
|
|
|
|
|
|
|
/// String data.
|
|
|
|
String,
|
|
|
|
|
|
|
|
/// Tab-separated fields of text.
|
|
|
|
TabularText,
|
|
|
|
|
|
|
|
/// Tag Image File Format (TIFF) data.
|
|
|
|
TIFF
|
|
|
|
}
|
|
|
|
|
2020-03-18 10:55:09 +11:00
|
|
|
impl From<PasteboardType> for NSString {
|
|
|
|
fn from(pboard_type: PasteboardType) -> Self {
|
|
|
|
NSString::new(match pboard_type {
|
|
|
|
PasteboardType::URL => "public.url",
|
|
|
|
PasteboardType::Color => "com.apple.cocoa.pasteboard.color",
|
|
|
|
PasteboardType::FileURL => "public.file-url",
|
|
|
|
PasteboardType::Font => "com.apple.cocoa.pasteboard.character-formatting",
|
|
|
|
PasteboardType::HTML => "public.html",
|
|
|
|
PasteboardType::MultipleTextSelection => "com.apple.cocoa.pasteboard.multiple-text-selection",
|
|
|
|
PasteboardType::PDF => "com.adobe.pdf",
|
|
|
|
PasteboardType::PNG => "public.png",
|
|
|
|
PasteboardType::RTF => "public.rtf",
|
|
|
|
PasteboardType::RTFD => "com.apple.flat-rtfd",
|
|
|
|
PasteboardType::Ruler => "com.apple.cocoa.pasteboard.paragraph-formatting",
|
|
|
|
PasteboardType::Sound => "com.apple.cocoa.pasteboard.sound",
|
|
|
|
PasteboardType::String => "public.utf8-plain-text",
|
|
|
|
PasteboardType::TabularText => "public.utf8-tab-separated-values-text",
|
|
|
|
PasteboardType::TIFF => "public.tiff",
|
|
|
|
})
|
2020-03-07 14:35:18 +11:00
|
|
|
}
|
|
|
|
}
|