unit ModificationMonitorTextMarks; {$M+} interface uses marks, buffers; type { This is a text mark that will have its "Modified()" called once a change to the right of it (and left of the next mark of the same owner) happens. The buffer knows nothing special about this kind of mark; this is a View feature. } TModificationMonitorTextMark = class(TTextMark, IModificationMonitorTextMark, ITextMark) private fOwner : Pointer; fModified : TTextBufferModified; published { callback based. If you want to signal that something has been modified, call Modified(Self, baInsert, ...). } function GetModified : TTextBufferModified; procedure SetModified(aCallback : TTextBufferModified); property Modified : TTextBufferModified read GetModified write SetModified; constructor Create(aOwner : Pointer{any unique ID}); public { "Owner" is there in order for the buffer to know when it's done notifying all the interested views. The buffer will usually contain ViewModificationMarks of multiple views. However, the only ViewModificationMark per view that should be notified of a modification is the mark that is to the left of the modification point and closest. } function GetOwner : Pointer{TTextView}; property Owner : Pointer{TTextView} read GetOwner; end; implementation { TModificationMonitorTextMark } function TModificationMonitorTextMark.GetModified : TTextBufferModified; begin Result := fModified; end; procedure TModificationMonitorTextMark.SetModified(aCallback : TTextBufferModified); begin fModified := aCallback; end; function TModificationMonitorTextMark.GetOwner : Pointer; begin Result := fOwner; end; constructor TModificationMonitorTextMark.Create(aOwner : Pointer{any unique ID}); begin inherited; fOwner := aOwner; end; end.