diff options
author | nyamatongwe <devnull@localhost> | 2011-11-16 10:43:52 +1100 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2011-11-16 10:43:52 +1100 |
commit | 445cc61d3c5dead15aeca9c363ccbbe57018d744 (patch) | |
tree | 47688bbd73047e85901aec3b576383b621c6ecc8 /src | |
parent | 1def08bb984e864f4d34064bdb38db2e47e7bd86 (diff) | |
download | scintilla-mirror-445cc61d3c5dead15aeca9c363ccbbe57018d744.tar.gz |
Bug #3283519. CountCharacters added to count the number of
characters between two positions. From Andrey Moskalyov.
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 14 | ||||
-rw-r--r-- | src/Document.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 86d5c6077..c721c88ff 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1094,6 +1094,20 @@ int Document::GetColumn(int pos) { return column; } +int Document::CountCharacters(int startPos, int endPos) { + startPos = MovePositionOutsideChar(startPos, 1, false); + endPos = MovePositionOutsideChar(endPos, -1, false); + int count = 0; + int i = startPos; + while (i < endPos) { + count++; + if (IsCrLf(i)) + i++; + i = NextPosition(i, 1); + } + return count; +} + int Document::FindColumn(int line, int column) { int position = LineStart(line); if ((line >= 0) && (line < LinesTotal())) { diff --git a/src/Document.h b/src/Document.h index bd8a58274..ec41603eb 100644 --- a/src/Document.h +++ b/src/Document.h @@ -303,6 +303,7 @@ public: void SetLineIndentation(int line, int indent); int GetLineIndentPosition(int line) const; int GetColumn(int position); + int CountCharacters(int startPos, int endPos); int FindColumn(int line, int column); void Indent(bool forwards, int lineBottom, int lineTop); static char *TransformLineEnds(int *pLenOut, const char *s, size_t len, int eolModeWanted); diff --git a/src/Editor.cxx b/src/Editor.cxx index 4c647b61e..8c939fdb1 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -9259,6 +9259,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTECHNOLOGY: return technology; + case SCI_COUNTCHARACTERS: + return pdoc->CountCharacters(wParam, lParam); + default: return DefWndProc(iMessage, wParam, lParam); } |