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

Method insertTextRect

texteditor/buffer.go:761–782  ·  view source on GitHub ↗

insertTextRect inserts a rectangle of text defined in given text.Edit record, (e.g., from RegionRect or DeleteRect), optionally signaling views after text has been inserted. Returns a copy of the Edit record with an updated timestamp. An Undo record is automatically saved depending on Undo.Off setti

(tbe *text.Edit, signal bool)

Source from the content-addressed store, hash-verified

759// Returns a copy of the Edit record with an updated timestamp.
760// An Undo record is automatically saved depending on Undo.Off setting.
761func (tb *Buffer) insertTextRect(tbe *text.Edit, signal bool) *text.Edit {
762 tb.FileModCheck() // will just revert changes if shouldn't have changed
763 nln := tb.NumLines()
764 re := tb.Lines.InsertTextRect(tbe)
765 if re == nil {
766 return re
767 }
768 if signal {
769 if re.Reg.End.Ln >= nln {
770 ie := &text.Edit{}
771 ie.Reg.Start.Ln = nln - 1
772 ie.Reg.End.Ln = re.Reg.End.Ln
773 tb.signalEditors(bufferInsert, ie)
774 } else {
775 tb.signalMods()
776 }
777 }
778 if tb.Autosave {
779 go tb.autoSave()
780 }
781 return re
782}
783
784// ReplaceText does DeleteText for given region, and then InsertText at given position
785// (typically same as delSt but not necessarily), optionally emitting a signal after the insert.

Callers 1

PasteRectMethod · 0.45

Calls 6

FileModCheckMethod · 0.95
signalEditorsMethod · 0.95
signalModsMethod · 0.95
autoSaveMethod · 0.95
NumLinesMethod · 0.80
InsertTextRectMethod · 0.80

Tested by

no test coverage detected