Skip to content

Commit d40eb89

Browse files
committed
Renamed set/get_contents to set/get_text. Updated the license file structure.
1 parent 07d080b commit d40eb89

13 files changed

+50
-80
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ license = "MIT / Apache-2.0"
88
keywords = ["clipboard"]
99

1010
[target.'cfg(windows)'.dependencies]
11-
clipboard-win = "2.1"
11+
clipboard-win = "3.0"
1212

1313
[target.'cfg(target_os = "macos")'.dependencies]
1414
objc = "0.2"
1515
objc_id = "0.1"
1616
objc-foundation = "0.1"
1717

1818
[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))'.dependencies]
19-
x11-clipboard = "0.3"
19+
x11-clipboard = "0.5"

LICENSE.apache2 LICENSE-APACHE.txt

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Apache License
1+
2+
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
45

@@ -174,28 +175,3 @@ Apache License
174175
of your accepting any such warranty or additional liability.
175176

176177
END OF TERMS AND CONDITIONS
177-
178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright {yyyy} {name of copyright owner}
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
http://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

LICENSE-MIT.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 The arboard contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

LICENSE.mit

-25
This file was deleted.

LICENSE.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Copyright (c) 2020 The arboard contributors
2+
3+
This software is licensed under either the MIT (see LICENSE-MIT.txt) license
4+
or the Apache 2.0 (see LICENSE-APACHE.txt) license at your option.

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# rust-clipboard
1+
# arboard
22

3-
rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard.
4-
It has been tested on Windows, Mac OSX, GNU/Linux, and FreeBSD.
5-
It is used in Mozilla Servo.
6-
7-
[![](http://meritbadge.herokuapp.com/clipboard)](https://crates.io/crates/clipboard)
8-
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/aweinstock314/rust-clipboard)](https://ci.appveyor.com/project/aweinstock314/rust-clipboard)
9-
[![Travis Build Status](https://travis-ci.org/aweinstock314/rust-clipboard.svg?branch=master)](https://travis-ci.org/aweinstock314/rust-clipboard)
3+
This crate is a fork of rust-clipboard and a cross-platform library for getting and setting the contents of the OS-level clipboard.
4+
It adds wayland support
105

116
## Prerequisites
127

@@ -26,8 +21,8 @@ use clipboard::ClipboardContext;
2621

2722
fn example() {
2823
let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
29-
println!("{:?}", ctx.get_contents());
30-
ctx.set_contents("some string".to_owned()).unwrap();
24+
println!("{:?}", ctx.get_text());
25+
ctx.set_text("some string".to_owned()).unwrap();
3126
}
3227
```
3328

@@ -37,8 +32,8 @@ The `ClipboardProvider` trait has the following functions:
3732

3833
```rust
3934
fn new() -> Result<Self, Box<Error>>;
40-
fn get_contents(&mut self) -> Result<String, Box<Error>>;
41-
fn set_contents(&mut self, String) -> Result<(), Box<Error>>;
35+
fn get_text(&mut self) -> Result<String, Box<Error>>;
36+
fn set_text(&mut self, String) -> Result<(), Box<Error>>;
4237
```
4338

4439
`ClipboardContext` is a type alias for one of {`WindowsClipboardContext`, `OSXClipboardContext`, `X11ClipboardContext`, `NopClipboardContext`}, all of which implement `ClipboardProvider`. Which concrete type is chosen for `ClipboardContext` depends on the OS (via conditional compilation).

examples/primary_selection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010

1111
let the_string = "Hello, world!";
1212

13-
ctx.set_contents(the_string.to_owned()).unwrap();
13+
ctx.set_text(the_string.to_owned()).unwrap();
1414
}
1515

1616
#[cfg(not(target_os = "linux"))]

src/common.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
use std::error::Error;
18+
use std::borrow::Cow;
1819

1920
pub fn err(s: &str) -> Box<Error> {
2021
Box::<Error + Send + Sync>::from(s)
@@ -26,9 +27,7 @@ pub trait ClipboardProvider: Sized {
2627
// TODO: consider replacing Box<Error> with an associated type?
2728
fn new() -> Result<Self, Box<Error>>;
2829
/// Method to get the clipboard contents as a String
29-
fn get_contents(&mut self) -> Result<String, Box<Error>>;
30+
fn get_text(&mut self) -> Result<String, Box<Error>>;
3031
/// Method to set the clipboard contents as a String
31-
fn set_contents(&mut self, String) -> Result<(), Box<Error>>;
32-
// TODO: come up with some platform-agnostic API for richer types
33-
// than just strings (c.f. issue #31)
32+
fn set_text(&mut self, text: String) -> Result<(), Box<Error>>;
3433
}

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ pub type ClipboardContext = nop_clipboard::NopClipboardContext;
6161
#[test]
6262
fn test_clipboard() {
6363
let mut ctx = ClipboardContext::new().unwrap();
64-
ctx.set_contents("some string".to_owned()).unwrap();
65-
assert!(ctx.get_contents().unwrap() == "some string");
64+
ctx.set_text("some string".to_owned()).unwrap();
65+
assert!(ctx.get_text().unwrap() == "some string");
6666
}

src/nop_clipboard.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ impl ClipboardProvider for NopClipboardContext {
2323
fn new() -> Result<NopClipboardContext, Box<Error>> {
2424
Ok(NopClipboardContext)
2525
}
26-
fn get_contents(&mut self) -> Result<String, Box<Error>> {
26+
fn get_text(&mut self) -> Result<String, Box<Error>> {
2727
println!("Attempting to get the contents of the clipboard, which hasn't yet been \
2828
implemented on this platform.");
2929
Ok("".to_string())
3030
}
31-
fn set_contents(&mut self, _: String) -> Result<(), Box<Error>> {
31+
fn set_text(&mut self, _: String) -> Result<(), Box<Error>> {
3232
println!("Attempting to set the contents of the clipboard, which hasn't yet been \
3333
implemented on this platform.");
3434
Ok(())

src/osx_clipboard.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ClipboardProvider for OSXClipboardContext {
4040
let pasteboard: Id<Object> = unsafe { Id::from_ptr(pasteboard) };
4141
Ok(OSXClipboardContext { pasteboard: pasteboard })
4242
}
43-
fn get_contents(&mut self) -> Result<String, Box<Error>> {
43+
fn get_text(&mut self) -> Result<String, Box<Error>> {
4444
let string_class: Id<NSObject> = {
4545
let cls: Id<Class> = unsafe { Id::from_ptr(class("NSString")) };
4646
unsafe { transmute(cls) }
@@ -61,7 +61,7 @@ impl ClipboardProvider for OSXClipboardContext {
6161
Ok(string_array[0].as_str().to_owned())
6262
}
6363
}
64-
fn set_contents(&mut self, data: String) -> Result<(), Box<Error>> {
64+
fn set_text(&mut self, data: String) -> Result<(), Box<Error>> {
6565
let string_array = NSArray::from_vec(vec![NSString::from_str(&data)]);
6666
let _: usize = unsafe { msg_send![self.pasteboard, clearContents] };
6767
let success: bool = unsafe { msg_send![self.pasteboard, writeObjects:string_array] };

src/windows_clipboard.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ impl ClipboardProvider for WindowsClipboardContext {
2525
fn new() -> Result<Self, Box<Error>> {
2626
Ok(WindowsClipboardContext)
2727
}
28-
fn get_contents(&mut self) -> Result<String, Box<Error>> {
28+
fn get_text(&mut self) -> Result<String, Box<Error>> {
2929
Ok(get_clipboard_string()?)
3030
}
31-
fn set_contents(&mut self, data: String) -> Result<(), Box<Error>> {
31+
fn set_text(&mut self, data: String) -> Result<(), Box<Error>> {
3232
Ok(set_clipboard_string(&data)?)
3333
}
3434
}

src/x11_clipboard.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ where
5454
Ok(X11ClipboardContext(X11Clipboard::new()?, PhantomData))
5555
}
5656

57-
fn get_contents(&mut self) -> Result<String, Box<Error>> {
57+
fn get_text(&mut self) -> Result<String, Box<Error>> {
5858
Ok(String::from_utf8(self.0.load(
5959
S::atom(&self.0.getter.atoms),
6060
self.0.getter.atoms.utf8_string,
@@ -63,7 +63,7 @@ where
6363
)?)?)
6464
}
6565

66-
fn set_contents(&mut self, data: String) -> Result<(), Box<Error>> {
66+
fn set_text(&mut self, data: String) -> Result<(), Box<Error>> {
6767
Ok(self.0.store(
6868
S::atom(&self.0.setter.atoms),
6969
self.0.setter.atoms.utf8_string,

0 commit comments

Comments
 (0)