MCPcopy Create free account
hub / github.com/cogentcore/core / Cut

Method Cut

texteditor/select.go:305–320  ·  view source on GitHub ↗

Cut cuts any selected text and adds it to the clipboard, also returns cut text

()

Source from the content-addressed store, hash-verified

303
304// Cut cuts any selected text and adds it to the clipboard, also returns cut text
305func (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)

Callers 2

keyInputMethod · 0.95
contextMenuMethod · 0.95

Calls 10

HasSelectionMethod · 0.95
deleteSelectionMethod · 0.95
SetCursorShowMethod · 0.95
savePosHistoryMethod · 0.95
NewTextBytesFunction · 0.92
ToBytesMethod · 0.80
NeedsRenderMethod · 0.80
WriteMethod · 0.65
ClipboardMethod · 0.65

Tested by

no test coverage detected