aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index ffbf8f557..21d492a8e 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -107,6 +107,10 @@ double ActionDuration::Duration() const noexcept {
return duration;
}
+size_t ActionDuration::ActionsInAllowedTime(double secondsAllowed) const noexcept {
+ return std::lround(secondsAllowed / Duration());
+}
+
Document::Document(int options) :
cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0),
durationStyleOneLine(0.00001, 0.000001, 0.0001) {
@@ -474,6 +478,20 @@ Sci::Line Document::LineFromPositionIndex(Sci::Position pos, int lineCharacterIn
return cb.LineFromPositionIndex(pos, lineCharacterIndex);
}
+Sci::Line Document::LineFromPositionAfter(Sci::Line line, Sci::Position length) const noexcept {
+ const Sci::Position posAfter = cb.LineStart(line) + length;
+ if (posAfter >= LengthNoExcept()) {
+ return LinesTotal();
+ }
+ const Sci::Line lineAfter = SciLineFromPosition(posAfter);
+ if (lineAfter > line) {
+ return lineAfter;
+ } else {
+ // Want to make some progress so return next line
+ return lineAfter + 1;
+ }
+}
+
int SCI_METHOD Document::SetLevel(Sci_Position line, int level) {
const int prev = Levels()->SetLevel(line, level, LinesTotal());
if (prev != level) {