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

Method insertText

texteditor/buffer.go:741–754  ·  view source on GitHub ↗

insertText is the primary method for inserting text into the buffer. It inserts new text at given starting position, optionally signaling views after text has been inserted. Sets the timestamp on resulting Edit to now. An Undo record is automatically saved depending on Undo.Off setting.

(st lexer.Pos, text []byte, signal bool)

Source from the content-addressed store, hash-verified

739// views after text has been inserted. Sets the timestamp on resulting Edit to now.
740// An Undo record is automatically saved depending on Undo.Off setting.
741func (tb *Buffer) insertText(st lexer.Pos, text []byte, signal bool) *text.Edit {
742 tb.FileModCheck() // will just revert changes if shouldn't have changed
743 tbe := tb.Lines.InsertText(st, text)
744 if tbe == nil {
745 return tbe
746 }
747 if signal {
748 tb.signalEditors(bufferInsert, tbe)
749 }
750 if tb.Autosave {
751 go tb.autoSave()
752 }
753 return tbe
754}
755
756// insertTextRect inserts a rectangle of text defined in given text.Edit record,
757// (e.g., from RegionRect or DeleteRect), optionally signaling

Callers 2

applyDiffMethod · 0.45
InsertAtCursorMethod · 0.45

Calls 4

FileModCheckMethod · 0.95
signalEditorsMethod · 0.95
autoSaveMethod · 0.95
InsertTextMethod · 0.80

Tested by

no test coverage detected