diff options
author | nyamatongwe <unknown> | 2011-06-07 11:47:11 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-06-07 11:47:11 +1000 |
commit | d46eab36df50e53cbe423ac5bf938d4c291bf5d2 (patch) | |
tree | 8d45b369f1b244ff022322928316d135b2927f13 /src | |
parent | 5dc8096d70e74e05120806386b0a08387d200045 (diff) | |
download | scintilla-mirror-d46eab36df50e53cbe423ac5bf938d4c291bf5d2.tar.gz |
Add Find method on RunStyles.
Diffstat (limited to 'src')
-rw-r--r-- | src/RunStyles.cxx | 15 | ||||
-rw-r--r-- | src/RunStyles.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx index 93688b3f9..643d2fb2d 100644 --- a/src/RunStyles.cxx +++ b/src/RunStyles.cxx @@ -233,3 +233,18 @@ bool RunStyles::AllSame() const { bool RunStyles::AllSameAs(int value) const { return AllSame() && (styles->ValueAt(0) == value); } + +int RunStyles::Find(int value, int start) const { + if (start < Length()) { + int run = start ? RunFromPosition(start) : 0; + if (styles->ValueAt(run) == value) + return start; + run++; + while (run < starts->Partitions()) { + if (styles->ValueAt(run) == value) + return starts->PositionFromPartition(run); + run++; + } + } + return -1; +} diff --git a/src/RunStyles.h b/src/RunStyles.h index d79e28618..a3efd93c9 100644 --- a/src/RunStyles.h +++ b/src/RunStyles.h @@ -40,6 +40,7 @@ public: int Runs() const; bool AllSame() const; bool AllSameAs(int value) const; + int Find(int value, int start) const; }; #ifdef SCI_NAMESPACE |