Merge pull request #2215 from jhannyj/editor-cut
Add cut functionality to text editor
This commit is contained in:
commit
8d21867caf
1 changed files with 12 additions and 0 deletions
|
|
@ -419,6 +419,12 @@ where
|
||||||
clipboard.write(selection);
|
clipboard.write(selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Update::Cut => {
|
||||||
|
if let Some(selection) = self.content.selection() {
|
||||||
|
clipboard.write(selection.clone());
|
||||||
|
shell.publish(on_edit(Action::Edit(Edit::Delete)));
|
||||||
|
}
|
||||||
|
}
|
||||||
Update::Paste => {
|
Update::Paste => {
|
||||||
if let Some(contents) = clipboard.read() {
|
if let Some(contents) = clipboard.read() {
|
||||||
shell.publish(on_edit(Action::Edit(Edit::Paste(
|
shell.publish(on_edit(Action::Edit(Edit::Paste(
|
||||||
|
|
@ -575,6 +581,7 @@ enum Update {
|
||||||
Release,
|
Release,
|
||||||
Action(Action),
|
Action(Action),
|
||||||
Copy,
|
Copy,
|
||||||
|
Cut,
|
||||||
Paste,
|
Paste,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -684,6 +691,11 @@ impl Update {
|
||||||
{
|
{
|
||||||
Some(Self::Copy)
|
Some(Self::Copy)
|
||||||
}
|
}
|
||||||
|
keyboard::Key::Character("x")
|
||||||
|
if modifiers.command() =>
|
||||||
|
{
|
||||||
|
Some(Self::Cut)
|
||||||
|
}
|
||||||
keyboard::Key::Character("v")
|
keyboard::Key::Character("v")
|
||||||
if modifiers.command() && !modifiers.alt() =>
|
if modifiers.command() && !modifiers.alt() =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue