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)
| 759 | // Returns a copy of the Edit record with an updated timestamp. |
| 760 | // An Undo record is automatically saved depending on Undo.Off setting. |
| 761 | func (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. |
no test coverage detected