aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface3
-rw-r--r--src/Document.cxx19
-rw-r--r--src/Document.h1
-rw-r--r--src/Editor.cxx5
5 files changed, 29 insertions, 0 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index d1cb759f7..2ae3b03c8 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -235,6 +235,7 @@ extern "C" {
#define SCI_SETLINEINDENTATION SCI_START + 126
#define SCI_GETLINEINDENTATION SCI_START + 127
#define SCI_GETLINEINDENTPOSITION SCI_START + 128
+#define SCI_GETCOLUMN SCI_START + 129
#define SCI_SETHSCROLLBAR SCI_START + 130
#define SCI_GETHSCROLLBAR SCI_START + 131
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index acbad39df..4ddbfe054 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -414,6 +414,9 @@ get int GetLineIndentation=2127(int line,)
# Retrieve the position before the first non indentation character on a line.
get position GetLineIndentPosition=2128(int line,)
+# Retrieve the column number of a position, taking tab width into account.
+get int GetColumn=2129(position pos,)
+
# Show or hide the horizontal scroll bar
set void SetHScrollBar=2130(bool show,)
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--) {
diff --git a/src/Document.h b/src/Document.h
index 92e4ff14f..64955639e 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -124,6 +124,7 @@ public:
int GetLineIndentation(int line);
void SetLineIndentation(int line, int indent);
int GetLineIndentPosition(int line);
+ int GetColumn(int position);
void Indent(bool forwards, int lineBottom, int lineTop);
void ConvertLineEnds(int eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
diff --git a/src/Editor.cxx b/src/Editor.cxx
index f753e35ce..e13fe1a2e 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2995,6 +2995,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
nEnd = pdoc->Length();
if (nStart < 0)
nStart = nEnd; // Remove selection
+ selType = selStream;
SetSelection(nEnd, nStart);
EnsureCaretVisible();
}
@@ -3004,6 +3005,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (lParam == 0)
return 0;
CHARRANGE *pCR = reinterpret_cast<CHARRANGE *>(lParam);
+ selType = selStream;
if (pCR->cpMax == -1) {
SetSelection(pCR->cpMin, pdoc->Length());
} else {
@@ -3409,6 +3411,9 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
case SCI_GETLINEINDENTPOSITION:
return pdoc->GetLineIndentPosition(wParam);
+
+ case SCI_GETCOLUMN:
+ return pdoc->GetColumn(wParam);
case SCI_SETHSCROLLBAR :
horizontalScrollBarVisible = wParam;