From 72b5df15f33da27c59efd54eb0c84e173ca8c692 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Jul 2018 15:06:50 +1000 Subject: Backport: Optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units added. Converted instances of C++17 std::string_view to C++11. Also used const_casts where appropriate to fix compile errors. Backport of changeset 7063:0d5edc93e280. --- doc/ScintillaDoc.html | 126 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 87 insertions(+), 39 deletions(-) (limited to 'doc/ScintillaDoc.html') diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 41ece6fa9..69cbd9e35 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -267,136 +267,140 @@ ○ Selection and information - ○ Multiple Selection and Virtual Space + ○ By character or UTF-16 code unit - ○ Scrolling and automatic + ○ Multiple Selection and Virtual Space scrolling + ○ Scrolling and automatic + ○ White spaceCursor - ○ Mouse capture - + ○ Mouse capture + ○ Line endingsWords - ○ Styling - + ○ Styling + ○ Style definitionCaret, selection, and hotspot styles - ○ Character representations - + ○ Character representations + ○ MarginsAnnotations - ○ Other settings - + ○ Other settings + ○ Brace highlightingTabs and Indentation Guides - ○ Markers - + ○ Markers + ○ IndicatorsAutocompletion - ○ User lists - + ○ User lists + ○ Call tipsKeyboard commands - ○ Key bindings - + ○ Key bindings + ○ Popup edit menuMacro recording - ○ Printing - + ○ Printing + ○ Direct accessMultiple views - ○ Background loading and saving - + ○ Background loading and saving + ○ FoldingLine wrapping - ○ Zooming - + ○ Zooming + ○ Long linesAccessibility - ○ Lexer - + ○ Lexer + ○ Lexer objectsNotifications - ○ Images - + ○ Images + ○ GTK+Provisional messages - ○ Deprecated messages - + ○ Deprecated messages + ○ Edit messages never supported by ScintillaRemoved features + + ○ Building Scintilla @@ -1226,8 +1230,6 @@ struct Sci_TextToFind { SCI_MOVECARETINSIDEVIEW
SCI_POSITIONBEFORE(int pos) → position
SCI_POSITIONAFTER(int pos) → position
- SCI_POSITIONRELATIVE(int pos, int relative) → position
- SCI_COUNTCHARACTERS(int start, int end) → int
SCI_TEXTWIDTH(int style, const char *text) → int
SCI_TEXTHEIGHT(int line) → int
SCI_CHOOSECARETX
@@ -1445,15 +1447,6 @@ struct Sci_TextToFind { If called with a position within a multi byte character will return the position of the start/end of that character.

-

SCI_POSITIONRELATIVE(int pos, int relative) → position
- Count a number of whole characters before or after the argument position and return that position. - The minimum position returned is 0 and the maximum is the last position in the document. - If the position goes past the document end then 0 is returned. -

- -

SCI_COUNTCHARACTERS(int start, int end) → int
- Returns the number of whole characters between two positions..

-

SCI_TEXTWIDTH(int style, const char *text) → int
This returns the pixel width of a string drawn in the given style which can be used, for example, to decide how wide to make the line number margin in order to display a @@ -1524,6 +1517,61 @@ struct Sci_TextToFind { When this option is turned off, mouse selections will always stick to the mode the selection was started in. It is off by default.

+

By character or UTF-16 code unit

+ +

Most Scintilla APIs use byte positions but some applications want to use positions based on counting + (UTF-32) characters or (UTF-16) code units + or need to communicate with other code written in terms of characters or code units. + With only byte positions, this may require examining many bytes to count characters or code units in the document + but this may be sped up in some cases by indexing the line starts by character or code unit.

+ + + SCI_POSITIONRELATIVE(int pos, int relative) → position
+ SCI_POSITIONRELATIVECODEUNITS(int pos, int relative) → position
+ SCI_COUNTCHARACTERS(int start, int end) → int
+ SCI_COUNTCODEUNITS(int start, int end) → int
+ SCI_GETLINECHARACTERINDEX → int
+ SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_RELEASELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_LINEFROMINDEXPOSITION(int pos, int lineCharacterIndex) → int
+ SCI_INDEXPOSITIONFROMLINE(int line, int lineCharacterIndex) → int
+
+ +

SCI_POSITIONRELATIVE(int pos, int relative) → position
+ Count a number of whole characters before or after the argument position and return that position. + The minimum position returned is 0 and the maximum is the last position in the document. + If the position goes past the document end then 0 is returned. +

+ +

SCI_COUNTCHARACTERS(int start, int end) → int
+ Returns the number of whole characters between two positions.

+ +

SCI_POSITIONRELATIVECODEUNITS(int pos, int relative) → int
+ SCI_COUNTCODEUNITS(int start, int end) → int
+ These are the UTF-16 versions of SCI_POSITIONRELATIVE and SCI_COUNTCHARACTERS + working in terms of UTF-16 code units.

+ +

SCI_GETLINECHARACTERINDEX → int
+ Returns which if any indexes are active. It may be SC_LINECHARACTERINDEX_NONE(0) or one or more + of SC_LINECHARACTERINDEX_UTF32(1) if whole characters are indexed or + SC_LINECHARACTERINDEX_UTF16(2) if UTF-16 code units are indexed. + Character indexes are currently only supported for UTF-8 documents.

+ +

SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)
+ SCI_RELEASELINECHARACTERINDEX(int lineCharacterIndex)
+ Allocate or release one or more indexes using same enumeration as SCI_GETLINECHARACTERINDEX. + Different aspects of an application may need indexes for different periods and should allocate for those periods. + Indexes use additional memory so releasing them can help minimize memory but they also take time to recalculate. + Scintilla may also allocate indexes to support features like accessibility or input method editors. + Only one index of each type is created for a document at a time.

+ +

SCI_LINEFROMINDEXPOSITION(int pos, int lineCharacterIndex) → int
+ SCI_INDEXPOSITIONFROMLINE(int line, int lineCharacterIndex) → int
+ The document line of a particular character or code unit may be found by calling SCI_LINEFROMINDEXPOSITION with one of + SC_LINECHARACTERINDEX_UTF32(1) or SC_LINECHARACTERINDEX_UTF16(2). + The inverse action, finds the starting position of a document line either in characters or code units from the document start by calling + SCI_INDEXPOSITIONFROMLINE with the same lineCharacterIndex argument.

+

Multiple Selection and Virtual Space

-- cgit v1.2.3