Cut cuts any selected text and adds it to the clipboard, also returns cut text
()
| 303 | |
| 304 | // Cut cuts any selected text and adds it to the clipboard, also returns cut text |
| 305 | func (ed *Editor) Cut() *text.Edit { |
| 306 | if !ed.HasSelection() { |
| 307 | return nil |
| 308 | } |
| 309 | org := ed.SelectRegion.Start |
| 310 | cut := ed.deleteSelection() |
| 311 | if cut != nil { |
| 312 | cb := cut.ToBytes() |
| 313 | ed.Clipboard().Write(mimedata.NewTextBytes(cb)) |
| 314 | addEditorClipboardHistory(cb) |
| 315 | } |
| 316 | ed.SetCursorShow(org) |
| 317 | ed.savePosHistory(ed.CursorPos) |
| 318 | ed.NeedsRender() |
| 319 | return cut |
| 320 | } |
| 321 | |
| 322 | // deleteSelection deletes any selected text, without adding to clipboard -- |
| 323 | // returns text deleted as text.Edit (nil if none) |
no test coverage detected