diff options
-rw-r--r-- | doc/ScintillaDoc.html | 6 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 4 | ||||
-rw-r--r-- | src/Document.cxx | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 3 |
5 files changed, 15 insertions, 1 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 8cad4e364..7323caa9d 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -898,6 +898,7 @@ struct TextToFind { <a class="message" href="#SCI_GETLINEENDPOSITION">SCI_GETLINEENDPOSITION(int line)</a><br /> <a class="message" href="#SCI_LINELENGTH">SCI_LINELENGTH(int line)</a><br /> <a class="message" href="#SCI_GETCOLUMN">SCI_GETCOLUMN(int position)</a><br /> + <a class="message" href="#SCI_FINDCOLUMN">SCI_FINDCOLUMN(int line, int column)</a><br /> <a class="message" href="#SCI_POSITIONFROMPOINT">SCI_POSITIONFROMPOINT(int x, int y)</a><br /> <a class="message" href="#SCI_POSITIONFROMPOINTCLOSE">SCI_POSITIONFROMPOINTCLOSE(int x, int y)</a><br /> @@ -1226,6 +1227,11 @@ struct TextToFind { characters up to the position on the line. In both cases, double byte characters count as a single character. This is probably only useful with monospaced fonts.</p> + <p><b id="SCI_FINDCOLUMN">SCI_FINDCOLUMN(int line, int column)</b><br /> + This message returns the position of a <code>column</code> on a <code>line</code> + taking the width of tabs into account. It treats a multi-byte character as a single column. + Column numbers, like lines start at 0.</p> + <p><b id="SCI_POSITIONFROMPOINT">SCI_POSITIONFROMPOINT(int x, int y)</b><br /> <b id="SCI_POSITIONFROMPOINTCLOSE">SCI_POSITIONFROMPOINTCLOSE(int x, int y)</b><br /> <code>SCI_POSITIONFROMPOINT</code> finds the closest character position to a point and diff --git a/include/Scintilla.h b/include/Scintilla.h index 78f3e093e..f20f0de22 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -586,6 +586,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_TARGETASUTF8 2447 #define SCI_SETLENGTHFORENCODE 2448 #define SCI_ENCODEDFROMUTF8 2449 +#define SCI_FINDCOLUMN 2456 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 8fec74f66..d53f9c4e4 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1595,6 +1595,10 @@ fun void SetLengthForEncode=2448(int bytes,) # On error return 0. fun int EncodedFromUTF8=2449(string utf8, stringresult encoded) +# Find the position of a column on a line taking into account tabs and +# multi-byte characters. If beyond end of line, return line end position. +fun int FindColumn=2456(int line, int column) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) diff --git a/src/Document.cxx b/src/Document.cxx index 97abd6254..c06397fa8 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -653,7 +653,7 @@ int Document::FindColumn(int line, int column) { int position = LineStart(line); int columnCurrent = 0; if ((line >= 0) && (line < LinesTotal())) { - while (columnCurrent < column) { + while ((columnCurrent < column) && (position < Length())) { char ch = cb.CharAt(position); if (ch == '\t') { columnCurrent = NextTab(columnCurrent, tabInChars); diff --git a/src/Editor.cxx b/src/Editor.cxx index 81cf3bd47..3b16c9783 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6307,6 +6307,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); + case SCI_FINDCOLUMN: + return pdoc->FindColumn(wParam, lParam); + case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { horizontalScrollBarVisible = wParam != 0; |