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

Method deleteTextRectImpl

texteditor/text/lines.go:934–954  ·  view source on GitHub ↗
(st, ed lexer.Pos)

Source from the content-addressed store, hash-verified

932}
933
934func (ls *Lines) deleteTextRectImpl(st, ed lexer.Pos) *Edit {
935 tbe := ls.regionRect(st, ed)
936 if tbe == nil {
937 return nil
938 }
939 tbe.Delete = true
940 for ln := st.Ln; ln <= ed.Ln; ln++ {
941 l := ls.lines[ln]
942 if len(l) > st.Ch {
943 if ed.Ch < len(l)-1 {
944 ls.lines[ln] = append(l[:st.Ch], l[ed.Ch:]...)
945 } else {
946 ls.lines[ln] = l[:st.Ch]
947 }
948 }
949 }
950 ls.linesEdited(tbe)
951 ls.changed = true
952 ls.callChangedFunc()
953 return tbe
954}
955
956// insertText is the primary method for inserting text,
957// at given starting position. Sets the timestamp on resulting Edit to now.

Callers 3

deleteTextRectMethod · 0.95
undoMethod · 0.95
redoMethod · 0.95

Calls 3

regionRectMethod · 0.95
linesEditedMethod · 0.95
callChangedFuncMethod · 0.95

Tested by

no test coverage detected