4#ifndef _Stroika_Frameworks_Led_Marker_h_
5#define _Stroika_Frameworks_Led_Marker_h_ 1
7#include "Stroika/Frameworks/StroikaPreComp.h"
93namespace Stroika::Frameworks::Led {
123 virtual void AboutToUpdateText (
const UpdateInfo& updateInfo);
124 virtual void EarlyDidUpdateText (
const UpdateInfo& updateInfo)
noexcept;
125 virtual void DidUpdateText (
const UpdateInfo& updateInfo)
noexcept;
133 virtual TextStore* PeekAtTextStore ()
const = 0;
136 nonvirtual TextStore& GetTextStore ()
const;
142 nonvirtual
size_t FindNextCharacter (
size_t afterPos)
const;
143 nonvirtual
size_t FindPreviousCharacter (
size_t beforePos)
const;
144 nonvirtual
size_t GetLength ()
const;
145 nonvirtual
size_t GetEnd ()
const;
146 nonvirtual
void CopyOut (
size_t from,
size_t count, Led_tChar* buffer)
const;
154 HookData* fTextStoreHook =
nullptr;
164 class MarkerOwner::HookData {
166 HookData () =
default;
169 virtual ~HookData () =
default;
177 class MarkerOwner::UpdateInfo {
179 UpdateInfo (
size_t from,
size_t to,
const Led_tChar* withWhat,
size_t withWhatCharCount,
bool textModified,
bool realContentUpdate);
183 const Led_tChar* fTextInserted;
187 bool fRealContentUpdate;
191 nonvirtual
size_t GetResultingRHS ()
const;
205 virtual ~Marker () =
default;
206 Marker (
const Marker&) =
delete;
207 Marker& operator= (
const Marker&) =
delete;
211 nonvirtual
size_t GetStart ()
const;
212 nonvirtual
size_t GetEnd ()
const;
213 nonvirtual
size_t GetLength ()
const;
214 nonvirtual MarkerOwner* GetOwner ()
const;
215 nonvirtual
void GetRange (
size_t* start,
size_t* end)
const;
236 using UpdateInfo = MarkerOwner::UpdateInfo;
237 virtual void AboutToUpdateText (
const UpdateInfo& updateInfo);
238 virtual void DidUpdateText (
const UpdateInfo& updateInfo)
noexcept;
246 HookData* fTextStoreHook{
nullptr};
256 class Marker::HookData {
258 HookData () =
default;
261 virtual ~HookData () =
default;
264 virtual MarkerOwner* GetOwner ()
const = 0;
265 virtual size_t GetStart ()
const = 0;
266 virtual size_t GetEnd ()
const = 0;
267 virtual size_t GetLength ()
const = 0;
268 virtual void GetStartEnd (
size_t* start,
size_t* end)
const = 0;
280 template <
typename MARKER>
281 class MarkerMortuary {
283 MarkerMortuary () =
default;
287 nonvirtual
void AccumulateMarkerForDeletion (MARKER* m);
288 nonvirtual
void SafeAccumulateMarkerForDeletion (MARKER* m);
289 nonvirtual
void FinalizeMarkerDeletions () noexcept;
290 nonvirtual
bool IsEmpty () const noexcept;
293 vector<MARKER*> fMarkersToBeDeleted;
296 bool Contains (const Marker& containedMarker, const Marker& containerMarker);
297 bool Contains (
size_t containedMarkerStart,
size_t containedMarkerEnd, const Marker& containerMarker);
298 bool Contains (const Marker& marker,
size_t charPos);
299 bool Contains (
size_t containedMarkerStart,
size_t containedMarkerEnd,
size_t charPos);
316 template <typename MARKER>
318 bool operator() (
const MARKER* lhs,
const MARKER* rhs)
const
322 int diff = int (lhs->GetStart ()) - int (rhs->GetStart ());
324 return (lhs->GetEnd () < rhs->GetEnd ());
339 class TempMarker :
public MarkerOwner {
341 using inherited = MarkerOwner;
344 TempMarker (TextStore& ts,
size_t start,
size_t end);
348 nonvirtual
size_t GetStart ()
const;
349 nonvirtual
size_t GetEnd ()
const;
350 nonvirtual
size_t GetLength ()
const;
351 nonvirtual
void GetLocation (
size_t* from,
size_t* to)
const;
354 virtual TextStore* PeekAtTextStore ()
const override;
357 TextStore& fTextStore;
367 template <
typename MARKER>
368 class TemporaryMarkerSlideDown {
370 TemporaryMarkerSlideDown (TextStore& ts,
const vector<MARKER*>& m, ptrdiff_t slideBy = 1);
371 ~TemporaryMarkerSlideDown ();
374 TextStore& fTextStore;
375 vector<MARKER*> fMarkers;
#define RequireNotNull(p)