Auto merge of #23738 - mmiecz:clipboard-cut, r=jdm

Add clipboard cut functionality

<!-- Please describe your changes on the following line: -->
This PR adds clipboard cut functionality. #23735

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #23735 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because manually testing whether cutting works is enough.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23738)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-07-10 19:22:24 -04:00 committed by GitHub
commit 67d38b429b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -877,6 +877,13 @@ impl<T: ClipboardProvider> TextInput<T> {
self.select_all();
KeyReaction::RedrawSelection
})
.shortcut(CMD_OR_CONTROL, 'X', || {
if let Some(text) = self.get_selection_text() {
self.clipboard_provider.set_clipboard_contents(text);
self.delete_char(Direction::Backward);
}
KeyReaction::DispatchInput
})
.shortcut(CMD_OR_CONTROL, 'C', || {
if let Some(text) = self.get_selection_text() {
self.clipboard_provider.set_clipboard_contents(text);