aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2000-06-08 10:13:35 +0000
committernyamatongwe <devnull@localhost>2000-06-08 10:13:35 +0000
commitff0018fbc36d8c93814b9cb3d0df53bafd4ef6b6 (patch)
treeb6f995d8a0da6e0aced8372b4fd598304fe02437 /src/Document.cxx
parentf3fa55b3b910e4949cb2dda8cf24fb15aec84ecf (diff)
downloadscintilla-mirror-ff0018fbc36d8c93814b9cb3d0df53bafd4ef6b6.tar.gz
Added GetColumn that determines the column of a position.
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 0f71231b6..c5aad504d 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -600,6 +600,25 @@ int Document::GetLineIndentPosition(int line) {
return pos;
}
+int Document::GetColumn(int pos) {
+ int column = 0;
+ int line = LineFromPosition(pos);
+ if ((line >= 0) && (line < LinesTotal())) {
+ for (int i=LineStart(line);i<pos;i++) {
+ char ch = cb.CharAt(i);
+ if (ch == '\t')
+ column = NextTab(column, tabInChars);
+ else if (ch == '\r')
+ return column;
+ else if (ch == '\n')
+ return column;
+ else
+ column++;
+ }
+ }
+ return column;
+}
+
void Document::Indent(bool forwards, int lineBottom, int lineTop) {
// Dedent - suck white space off the front of the line to dedent by equivalent of a tab
for (int line = lineBottom; line >= lineTop; line--) {