diff options
Diffstat (limited to 'src/Document.h')
-rw-r--r-- | src/Document.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Document.h b/src/Document.h index 0ef967e09..19a03ad1d 100644 --- a/src/Document.h +++ b/src/Document.h @@ -190,6 +190,26 @@ struct RegexError : public std::runtime_error { }; /** + * The ActionDuration class stores the average time taken for some action such as styling or + * wrapping a line. It is used to decide how many repetitions of that action can be performed + * on idle to maximize efficiency without affecting application responsiveness. + * The duration changes if the time for the action changes. For example, if a simple lexer is + * changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy + * or difficult processing moving the value too far leading to inefficiency or poor user + * experience. + */ + +class ActionDuration { + double duration; + const double minDuration; + const double maxDuration; +public: + ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept; + void AddSample(size_t numberActions, double durationOfActions) noexcept; + double Duration() const noexcept; +}; + +/** */ class Document : PerLine, public IDocument, public ILoader { @@ -259,7 +279,7 @@ public: bool useTabs; bool tabIndents; bool backspaceUnindents; - double durationStyleOneLine; + ActionDuration durationStyleOneLine; std::unique_ptr<IDecorationList> decorations; |