From 062f85d0d282162a3e829491ac422b96544215fd Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 28 Mar 2018 10:08:25 +1100 Subject: Split decorations into interface and implementation. --- src/Decoration.h | 84 ++++++++++++++++++++++---------------------------------- 1 file changed, 33 insertions(+), 51 deletions(-) (limited to 'src/Decoration.h') diff --git a/src/Decoration.h b/src/Decoration.h index 86397fde1..76f00ec55 100644 --- a/src/Decoration.h +++ b/src/Decoration.h @@ -9,68 +9,50 @@ namespace Scintilla { -class Decoration { - int indicator; +class IDecoration { public: - RunStyles rs; - - explicit Decoration(int indicator_); - ~Decoration(); - - bool Empty() const; - int Indicator() const { - return indicator; - } + virtual ~IDecoration() {} + virtual bool Empty() const = 0; + virtual int Indicator() const = 0; + virtual Sci::Position Length() const = 0; + virtual int ValueAt(Sci::Position position) const = 0; + virtual Sci::Position StartRun(Sci::Position position) const = 0; + virtual Sci::Position EndRun(Sci::Position position) const = 0; + virtual void SetValueAt(Sci::Position position, int value) = 0; + virtual void InsertSpace(Sci::Position position, Sci::Position insertLength) = 0; + virtual Sci::Position Runs() const = 0; }; -class DecorationList { - int currentIndicator; - int currentValue; - Decoration *current; // Cached so FillRange doesn't have to search for each call. - Sci::Position lengthDocument; - // Ordered by indicator - std::vector> decorationList; - std::vector decorationView; // Read-only view of decorationList - bool clickNotified; - - Decoration *DecorationFromIndicator(int indicator); - Decoration *Create(int indicator, Sci::Position length); - void Delete(int indicator); - void DeleteAnyEmpty(); - void SetView(); +class IDecorationList { public: + virtual ~IDecorationList() {} - DecorationList(); - ~DecorationList(); - - const std::vector &View() const { return decorationView; } + virtual const std::vector &View() const =0; - void SetCurrentIndicator(int indicator); - int GetCurrentIndicator() const { return currentIndicator; } + virtual void SetCurrentIndicator(int indicator) = 0; + virtual int GetCurrentIndicator() const = 0; - void SetCurrentValue(int value); - int GetCurrentValue() const { return currentValue; } + virtual void SetCurrentValue(int value) = 0; + virtual int GetCurrentValue() const = 0; // Returns with changed=true if some values may have changed - FillResult FillRange(Sci::Position position, int value, Sci::Position fillLength); - - void InsertSpace(Sci::Position position, Sci::Position insertLength); - void DeleteRange(Sci::Position position, Sci::Position deleteLength); - - void DeleteLexerDecorations(); + virtual FillResult FillRange(Sci::Position position, int value, Sci::Position fillLength) = 0; + virtual void InsertSpace(Sci::Position position, Sci::Position insertLength) = 0; + virtual void DeleteRange(Sci::Position position, Sci::Position deleteLength) = 0; + virtual void DeleteLexerDecorations() = 0; + + virtual int AllOnFor(Sci::Position position) const = 0; + virtual int ValueAt(int indicator, Sci::Position position) = 0; + virtual Sci::Position Start(int indicator, Sci::Position position) = 0; + virtual Sci::Position End(int indicator, Sci::Position position) = 0; + + virtual bool ClickNotified() const = 0; + virtual void SetClickNotified(bool notified) = 0; +}; - int AllOnFor(Sci::Position position) const; - int ValueAt(int indicator, Sci::Position position); - Sci::Position Start(int indicator, Sci::Position position); - Sci::Position End(int indicator, Sci::Position position); +std::unique_ptr DecorationCreate(int indicator); - bool ClickNotified() const { - return clickNotified; - } - void SetClickNotified(bool notified) { - clickNotified = notified; - } -}; +std::unique_ptr DecorationListCreate(); } -- cgit v1.2.3