diff options
-rw-r--r-- | doc/ScintillaDoc.html | 1042 | ||||
-rw-r--r-- | include/Scintilla.h | 17 | ||||
-rw-r--r-- | include/Scintilla.iface | 233 | ||||
-rw-r--r-- | src/Editor.cxx | 354 | ||||
-rw-r--r-- | src/Editor.h | 21 |
5 files changed, 1013 insertions, 654 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 966d0d4fb..9d7728004 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -46,7 +46,7 @@ </p> <p> The <a href="SciCoding.html">coding style</a> used in Scintilla and SciTE - are worth following if you want to contribute code to Scintilla but are not + are worth following if you want to contribute code to Scintilla but are not compulsory. </p> <p> @@ -55,14 +55,14 @@ </p> <p> The Windows version of Scintilla is a Windows Control. As such, its primary programming - interface is through Windows messages. Early versions of Scintilla emulated much of the - API defined by the standard Windows Edit and Richedit controls but those APIs are now - deprecated in favour of Scintilla's own, more consistent API. - In addition to messages performing the actions of a normal Edit control, Scintilla + interface is through Windows messages. Early versions of Scintilla emulated much of the + API defined by the standard Windows Edit and Richedit controls but those APIs are now + deprecated in favour of Scintilla's own, more consistent API. + In addition to messages performing the actions of a normal Edit control, Scintilla allows control of syntax styling, markers, auto-completion and call tips. </p> The GTK+ version also uses messages in a similar way to the Windows version. This is different - to normal GTK+ practice but made it easier to implement rapidly. + to normal GTK+ practice but made it easier to implement rapidly. <p> The messages are (with wParam and lParam use) </p> @@ -95,10 +95,10 @@ SCI_GETSTYLEBITS indicators. This allows 32 fundamental styles which is enough for most languages and three independent indicators so that, for example, syntax errors, deprecated names and bad indentation could all be displayed at once. Indicators may be displayed as simple underlines, - squiggly underlines, a line of small 'T' shapes, a line of diagonal hatching or as strike-out. - Additional indicators such as blurred could be defined in the future. - The number of bits used for styles can be altered - with SCI_SETSTYLEBITS up to a maximum of 7 bits. + squiggly underlines, a line of small 'T' shapes, a line of diagonal hatching or as strike-out. + Additional indicators such as blurred could be defined in the future. + The number of bits used for styles can be altered + with SCI_SETSTYLEBITS up to a maximum of 7 bits. The remaining bits can be used for indicators. </p> <p> @@ -122,8 +122,8 @@ SCI_GETSTYLEBITS reset the folding state. </p> <pre> -SCI_SETTARGETSTART(int pos) -SCI_GETTARGETSTART +SCI_SETTARGETSTART(int pos) +SCI_GETTARGETSTART SCI_SETTARGETEND(int pos) SCI_GETTARGETEND SCI_REPLACETARGET(int length, char *text) @@ -134,13 +134,13 @@ SCI_SEARCHINTARGET(int length, string text) </pre> <p> Using SCI_REPLACESEL, modifications cause scrolling and other visible changes - which may take some time and cause unwanted display updates. If performing many - changes, such as a replace all command, the target can be used instead. + which may take some time and cause unwanted display updates. If performing many + changes, such as a replace all command, the target can be used instead. First set the range to be replaced. Then call SCI_REPLACETARGET or - SCI_REPLACETARGETRE which returns the length taken by the replacement string. + SCI_REPLACETARGETRE which returns the length taken by the replacement string. The difference between SCI_REPLACETARGET and SCI_REPLACETARGETRE is that SCI_REPLACETARGETRE looks for \d patterns in the replacement text - where d is a digit from 1 to 9 and substitutes in the values of tagged matches from the + where d is a digit from 1 to 9 and substitutes in the values of tagged matches from the most recent regular expression search. </p> <p> @@ -148,9 +148,9 @@ SCI_SEARCHINTARGET(int length, string text) which uses a counted string to allow searching for null characters. Returns length of range or -1 for failure in which case target is not moved. The flags used by SCI_SEARCHINTARGET such as SCFIND_MATCHCASE, - SCFIND_WHOLEWORD, SCFIND_WORDSTART, and SCFIND_REGEXP can - be set with SCI_SETSEARCHFLAGS. The SCI_SEARCHINTARGET call - may be simpler for some clients to use than SCI_FINDTEXT as that requires + SCFIND_WHOLEWORD, SCFIND_WORDSTART, and SCFIND_REGEXP can + be set with SCI_SETSEARCHFLAGS. The SCI_SEARCHINTARGET call + may be simpler for some clients to use than SCI_FINDTEXT as that requires using a pointer to a structure. </p> <pre> @@ -158,7 +158,7 @@ SCI_SETOVERTYPE SCI_GETOVERTYPE </pre> <p> - SCI_GETOVERTYPE returns TRUE if overtyping is active otherwise + SCI_GETOVERTYPE returns TRUE if overtyping is active otherwise FALSE will be returned. Use SCI_GETOVERTYPE to set the overtype node. </p> <h3> @@ -179,7 +179,7 @@ SCI_SETSTATUS SCI_GETSTATUS </pre> <p> - If an error occurs, Scintilla may set an internal error number + If an error occurs, Scintilla may set an internal error number which can be retrieved with SCI_GETSTATUS. Not currently used but will be in the future. To clear the error status call SCI_SETSTATUS(0). @@ -251,7 +251,7 @@ SCI_TEXTHEIGHT(int line) current position. </p> <p> - It is not possible to change the modified status as whether the document is modified is + It is not possible to change the modified status as whether the document is modified is determined by whether the undo position is at the save point. </p> <p> @@ -260,21 +260,21 @@ SCI_TEXTHEIGHT(int line) </p> <p> SCI_POSITIONFROMPOINT finds the closest character position to a point and - SCI_POSITIONFROMPOINTCLOSE is similar but returns -1 if the point is + SCI_POSITIONFROMPOINTCLOSE is similar but returns -1 if the point is outside the window or not close to any characters. </p> <p> SCI_POINTXFROMPOSITION and SCI_POINTYFROMPOSITION - can be used to find the pixel location of text on the display. - SCI_TEXTWIDTH can be used to find the pixel width of a string which + can be used to find the pixel location of text on the display. + SCI_TEXTWIDTH can be used to find the pixel width of a string which can be used, for example, to decide how wide to make the line number margin in order to display a given number of numerals. SCI_TEXTHEIGHT - returns the height in pixels of a particular line. Currently all lines are the + returns the height in pixels of a particular line. Currently all lines are the same height. </p> <p> - SCI_WORDENDPOSITION and SCI_WORDSTARTPOSITION can be used to find - the start and end of words using the same definition of words as used internally + SCI_WORDENDPOSITION and SCI_WORDSTARTPOSITION can be used to find + the start and end of words using the same definition of words as used internally within Scintilla. </p> <h3> @@ -283,8 +283,9 @@ SCI_TEXTHEIGHT(int line) <pre> SCI_LINESCROLL(int column, int line) SCI_SCROLLCARET -SCI_SETCARETPOLICY(int policy, int slop) -SCI_SETVISIBLEPOLICY(int policy, int slop) +SCI_SETXCARETPOLICY(int caretPolicy, int caretSlop) +SCI_SETYCARETPOLICY(int caretPolicy, int caretSlop) +SCI_SETVISIBLEPOLICY(int caretPolicy, int caretSlop) SCI_SETHSCROLLBAR(bool visible) SCI_GETHSCROLLBAR SCI_GETXOFFSET @@ -295,20 +296,149 @@ SCI_SETENDATLASTLINE(bool endAtLastLine) SCI_GETENDATLASTLINE </pre> <p> - SCI_SETCARETPOLICY can be set to a combination of the flags CARET_SLOP - and CARET_STRICT to change the automatic vertical positioning of the view - when ensuring a position is visible. If CARET_SLOP is on then the slop value - determines the number of line at top and bottom of the view where the caret should not - go. If CARET_SLOP is off then the caret is centred within the view. When - CARET_STRICT is set then caret policy is rechecked even if the caret is completely - visible. If CARET_XEVEN is set then both the left and right margins are treated - equally whereas if it is not set then displaying text to the left is preferred. - CARET_XJUMPS causes the display to move in jumps and then stay still - rather than in a series of smaller movements. - SCI_SETVISIBLEPOLICY is a similar function that - determines how the vertical positioning is determined when + SCI_SETXCARETPOLICY and SCI_SETYCARETPOLICY set the caret policy.<br /> + The value of caretPolicy is a combination of CARET_SLOP, CARET_STRICT, + CARET_JUMPS and CARET_EVEN.<br /> + - If CARET_SLOP is set, we can define a slop value: caretSlop.<br /> + This value defines an unwanted zone (UZ) where the caret is... unwanted.<br /> + This zone is defined as a number of pixels near the vertical margins, + and as a number of lines near the horizontal margins.<br /> + By keeping the caret away from the edges, it is seen within its context, + so it is likely that the identifier that the caret is on can be completely seen, + and that the current line is seen with some of the lines following it which are + often dependent on that line.<br /> + - If CARET_STRICT is set, the policy is enforced... strictly.<br /> + The caret is centred on the display if slop is not set, + and cannot go in the UZ if slop is set.<br /> + - If CARET_JUMPS is set, the display is moved more energetically + so the caret can move in the same direction longer before the policy is applied again.<br /> + '3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin.<br /> + - If CARET_EVEN is not set, instead of having symmetrical UZs, + the left and bottom UZs are extended up to right and top UZs respectively.<br /> + This way, we favour the displaying of useful information: the begining of lines, + where most code reside, and the lines after the caret, eg. the body of a function.<br /> + <table cellpadding="1" cellspacing="0" border="1"> + <tr> + <th>slop</th> + <th>strict</th> + <th>jumps</th> + <th>even</th> + <th>Caret can go to the margin</th> + <th>When reaching limit<br /> + (going out of visibility or<br /> + going into the UZ)<br /> + display is...</th> + </tr> + <tr> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">0</td> + <td>Yes</td> + <td>moved to put caret on top/on right</td> + </tr> + <tr> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">1</td> + <td>Yes</td> + <td>moved by one position</td> + </tr> + <tr> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">0</td> + <td>Yes</td> + <td>moved to put caret on top/on right</td> + </tr> + <tr> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">1</td> + <td>Yes</td> + <td>centred on the caret</td> + </tr> + <tr> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">-</td> + <td align="center">0</td> + <td>Caret is always on top/on right of display</td> + <td>-</td> + </tr> + <tr> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">-</td> + <td align="center">1</td> + <td>No, caret is always centred</td> + <td>-</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">0</td> + <td>Yes</td> + <td>moved to put caret out of the asymmetrical UZ</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">0</td> + <td align="center">0</td> + <td align="center">1</td> + <td>Yes</td> + <td>moved to put caret out of the UZ</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">0</td> + <td>Yes</td> + <td>moved to put caret at 3UZ of the top or right margin</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">0</td> + <td align="center">1</td> + <td align="center">1</td> + <td>Yes</td> + <td>moved to put caret at 3UZ of the margin</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">1</td> + <td align="center">-</td> + <td align="center">0</td> + <td>Caret is always at UZ of top/right margin</td> + <td>-</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">1</td> + <td align="center">0</td> + <td align="center">1</td> + <td>No, kept out of UZ</td> + <td>moved by one position</td> + </tr> + <tr> + <td align="center">1</td> + <td align="center">1</td> + <td align="center">1</td> + <td align="center">0</td> + <td>No, kept out of UZ</td> + <td>moved to put caret at 3UZ of the margin</td> + </tr> + </table> + + SCI_SETVISIBLEPOLICY is a similar function that + determines how the vertical positioning is determined when SCI_ENSUREVISIBLEENFORCEPOLICY is - called. It takes VISIBLE_SLOP and VISIBLE_STRICT flags + called. It takes VISIBLE_SLOP and VISIBLE_STRICT flags for the policy parameter. </p> <p> @@ -318,8 +448,8 @@ SCI_GETENDATLASTLINE SCI_SETSCROLLWIDTH sets the document width assumed for scrolling. </p> <p> - SCI_SETENDATLASTLINE sets the scroll range so that maximum - scroll position has the last line at the bottom of the view (default). + SCI_SETENDATLASTLINE sets the scroll range so that maximum + scroll position has the last line at the bottom of the view (default). Setting this to false allows scrolling one page below the last line. </p> <h3> @@ -329,22 +459,22 @@ SCI_GETENDATLASTLINE SCI_FINDTEXT(int flags, TextToFind *ttf) </pre> <p> - Scintilla can find where a string is present in the document. + Scintilla can find where a string is present in the document. There are several option flags including a simple regular expression search. - SCFIND_MATCHCASE indicates that a match only occurs with a - string that matches the case of the search string. + SCFIND_MATCHCASE indicates that a match only occurs with a + string that matches the case of the search string. SCFIND_WHOLEWORD indicates that a match only occurs if the characters before and after are not word characters. SCFIND_WORDSTART indicates that a match only occurs if the character before is not a word character. </p> <p> - SCFIND_REGEXP indicates that the search string should be interpreted as a regular + SCFIND_REGEXP indicates that the search string should be interpreted as a regular expression. Special characters interpreted are '.' for any character, '\(' and '\)' to tag parts of the match, '\1' .. '\9' to refer to tagged parts, '\<' to match the start of a word, - '\>' to match the end of a word, + '\>' to match the end of a word, '\' as a quote character, '[' and ']' to indicate a set of characters, ^ within a set to complement the set, ^ outside a set - to match the start of line, $ to match the end of line, * to match 0 or more times, + to match the start of line, $ to match the end of line, * to match 0 or more times, + to match 1 or more times </p> <p> @@ -372,7 +502,7 @@ SCWS_VISIBLEALWAYS) <p> White space can be made visible which may useful for languages in which whitespace is significant, such as Python. Space characters appear as small centred dots and tab characters - as light arrows pointing to the right. With the SCWS_VISIBLEAFTERINDENT option, + as light arrows pointing to the right. With the SCWS_VISIBLEAFTERINDENT option, white space used for indentation is invisible but after the first visible character, it is visible. </p> <h3> @@ -385,7 +515,7 @@ SCI_GETCURSOR <p> The cursor is normally chosen in a context sensitive way so will be different over the margin than when over the text. When performing a slow action, a wait cursor - can be shown by calling SCI_SETCURSOR(SC_CURSORWAIT) and restored + can be shown by calling SCI_SETCURSOR(SC_CURSORWAIT) and restored with SCI_SETCURSOR(SC_CURSORNORMAL). </p> <h3> @@ -397,7 +527,7 @@ SCI_GETMOUSEDOWNCAPTURES </pre> <p> When the mouse is pressed inside Scintilla, it is captured so future mouse movement - events are sent to Scintilla. This behaviour may be turned off with + events are sent to Scintilla. This behaviour may be turned off with SCI_SETMOUSEDOWNCAPTURES(false). </p> <h3> @@ -454,7 +584,7 @@ SCI_GETMAXLINESTATE SCI_SETSTYLING messages are sent for each lexical entity to be styled. </p> <p> - As well as the 8 bits of lexical state stored for each character there is also an integer stored + As well as the 8 bits of lexical state stored for each character there is also an integer stored for each line. This can be used for longer lived parse states such as what the current scripting language is in an ASP page. </p> @@ -481,52 +611,52 @@ SCI_STYLESETCASE(int stylenumber, SC_CASE_MIXED or SC_CASE_UPPER or SC_CASE_LOWE SCI_STYLESETCHANGEABLE(int stylenumber, bool changeable) </pre> <p> - While the style setting messages mentioned above, change the style - numbers associated with text, these messages define how those style - numbers are interpreted visually. The STYLE_DEFAULT style defines - the attributes that all styles will receive when SCI_STYLECLEARALL - is called. SCI_STYLERESETDEFAULT resets STYLE_DEFAULT to its state + While the style setting messages mentioned above, change the style + numbers associated with text, these messages define how those style + numbers are interpreted visually. The STYLE_DEFAULT style defines + the attributes that all styles will receive when SCI_STYLECLEARALL + is called. SCI_STYLERESETDEFAULT resets STYLE_DEFAULT to its state when Scintilla was initialised. </p> <p> The EOLFILLED style uses the background colour at the end of the line to colour from the last character of the line to the right side of the window. - This is useful when a document contains embedded sections in another - language such as HTML pages with embedded JavaScript. By setting both - the EOLFILLED style and a consistent background colour to all JavaScript + This is useful when a document contains embedded sections in another + language such as HTML pages with embedded JavaScript. By setting both + the EOLFILLED style and a consistent background colour to all JavaScript styles then JavaScript sections will be easily distinguished from HTML. </p> <p> - SCI_STYLESETCHARACTERSET can set a style to use a different + SCI_STYLESETCHARACTERSET can set a style to use a different character set than the default. - For example, SCI_STYLESETCHARACTERSET(SCE_C_STRING, - SC_CHARSET_RUSSIAN) would ensure that strings in Russian would - display correctly. - This feature currently only works fully on Windows. + For example, SCI_STYLESETCHARACTERSET(SCE_C_STRING, + SC_CHARSET_RUSSIAN) would ensure that strings in Russian would + display correctly. + This feature currently only works fully on Windows. </p> <p> The character sets supported on Windows are: SC_CHARSET_ANSI, SC_CHARSET_ARABIC, SC_CHARSET_BALTIC, -SC_CHARSET_CHINESEBIG5, SC_CHARSET_DEFAULT, -SC_CHARSET_EASTEUROPE, SC_CHARSET_GB2312, SC_CHARSET_GREEK, -SC_CHARSET_HANGUL, SC_CHARSET_HEBREW, SC_CHARSET_JOHAB, -SC_CHARSET_MAC, SC_CHARSET_OEM, SC_CHARSET_SHIFTJIS, +SC_CHARSET_CHINESEBIG5, SC_CHARSET_DEFAULT, +SC_CHARSET_EASTEUROPE, SC_CHARSET_GB2312, SC_CHARSET_GREEK, +SC_CHARSET_HANGUL, SC_CHARSET_HEBREW, SC_CHARSET_JOHAB, +SC_CHARSET_MAC, SC_CHARSET_OEM, SC_CHARSET_SHIFTJIS, SC_CHARSET_SYMBOL, SC_CHARSET_THAI, SC_CHARSET_TURKISH, and -SC_CHARSET_VIETNAMESE. +SC_CHARSET_VIETNAMESE. </p> <p> The character sets supported on GTK+ are SC_CHARSET_ANSI, - SC_CHARSET_EASTEUROPE, SC_CHARSET_GB2312, + SC_CHARSET_EASTEUROPE, SC_CHARSET_GB2312, SC_CHARSET_HANGUL, and SC_CHARSET_SHIFTJIS. </p> <p> - As well as the 32 fundamental lexer styles, there are also some - predefined numbered styles starting at 32, STYLE_DEFAULT, - STYLE_LINENUMBER, STYLE_BRACELIGHT, STYLE_BRACEBAD, - STYLE_CONTROLCHAR, and STYLE_INDENTGUIDE. + As well as the 32 fundamental lexer styles, there are also some + predefined numbered styles starting at 32, STYLE_DEFAULT, + STYLE_LINENUMBER, STYLE_BRACELIGHT, STYLE_BRACEBAD, + STYLE_CONTROLCHAR, and STYLE_INDENTGUIDE. These can be defined with the SCI_STYLESET* messages. - To make it easier for client code to discover the range of styles - that are predefined, STYLE_LASTPREDEFINED is set to the style + To make it easier for client code to discover the range of styles + that are predefined, STYLE_LASTPREDEFINED is set to the style number of the last predefined style. </p> <p> @@ -534,12 +664,12 @@ SC_CHARSET_VIETNAMESE. (SC_CASE_UPPER) or lower case (SC_CASE_LOWER). </p> <p> - SCI_STYLESETCHANGEABLE is an experimental and incompletely - implemented style attribute. - The default setting is changeable but when turned off it makes text + SCI_STYLESETCHANGEABLE is an experimental and incompletely + implemented style attribute. + The default setting is changeable but when turned off it makes text read-only. - Currently only stops caret from being within not-changeable text - and does not yet stop deleting a range that contains not-changeable + Currently only stops caret from being within not-changeable text + and does not yet stop deleting a range that contains not-changeable text. </p> <h3> @@ -562,30 +692,30 @@ SCI_SETCONTROLCHARSYMBOL(int symbol) SCI_GETCONTROLCHARSYMBOL </pre> <p> - The selection is shown by changing the foreground and / or - background colours. - If one of these is not set then that attribute is not changed for - the selection. The default is to show the selection by changing the - background to light grey and leaving the foreground the same as + The selection is shown by changing the foreground and / or + background colours. + If one of these is not set then that attribute is not changed for + the selection. The default is to show the selection by changing the + background to light grey and leaving the foreground the same as when it was not selected. </p> <p> - The colour of the caret can be set with SCI_SETCARETFORE. - The background colour of the line containing the caret can be - changed to override the styles on that line with - SCI_GETCARETLINEVISIBLE and the colour used set with - SCI_SETCARETLINEBACK. - The caret line background colour is overridden by any background + The colour of the caret can be set with SCI_SETCARETFORE. + The background colour of the line containing the caret can be + changed to override the styles on that line with + SCI_GETCARETLINEVISIBLE and the colour used set with + SCI_SETCARETLINEBACK. + The caret line background colour is overridden by any background colour used to display markers. - The rate at which the caret blinks can be set with - SCI_SETCARETPERIOD which determines the time in milliseconds that - the caret is visible or invisible before changing state. - Setting the period to 0 stops the caret blinking. + The rate at which the caret blinks can be set with + SCI_SETCARETPERIOD which determines the time in milliseconds that + the caret is visible or invisible before changing state. + Setting the period to 0 stops the caret blinking. The width of the caret can be set with SCI_SETCARETWIDTH to a value of 1, 2 or 3 pixels. </p> <p> - SCI_SETCONTROLCHARSYMBOL specifies a character to use to indicate + SCI_SETCONTROLCHARSYMBOL specifies a character to use to indicate control characters rather than having them displayed as mnemonics. </p> <h3> @@ -593,13 +723,13 @@ SCI_GETCONTROLCHARSYMBOL </h3> <pre> SCI_SETMARGINLEFT(int width) -SCI_GETMARGINLEFT +SCI_GETMARGINLEFT SCI_SETMARGINRIGHT(int width) SCI_GETMARGINRIGHT </pre> <p> - Gets or sets the width of the blank margin on both sides of the - text. This defaults to one pixel on each side. + Gets or sets the width of the blank margin on both sides of the + text. This defaults to one pixel on each side. </p> <pre> SCI_SETMARGINTYPEN(int margin, SC_MARGIN_SYMBOL | SC_MARGIN_NUMBER) @@ -612,18 +742,18 @@ SCI_SETMARGINSENSITIVEN(int margin, bool sensitive) SCI_GETMARGINSENSITIVEN(int margin) </pre> <p> - There may be up to three margins to the left of the text display. - Each margin may contain marker symbols and some may be set to - display line numbers (with SCI_SETMARGINTYPEN). The markers - displayed in each margin are set withSCI_SETMARGINMASKN. Any - markers not associated with a visible margin will be displayed as + There may be up to three margins to the left of the text display. + Each margin may contain marker symbols and some may be set to + display line numbers (with SCI_SETMARGINTYPEN). The markers + displayed in each margin are set withSCI_SETMARGINMASKN. Any + markers not associated with a visible margin will be displayed as changes in background colour in the text. - A width in pixels can be set for each margin. Margins with a zero - width are ignored completely. Each margin may be made sensitive to - mouse clicks. A click in a sensitive margin will result in a - SCN_MARGINCLICK notification being sent to the container. Margins - that are not sensitive act as selection margins which make it - easy to select ranges of lines. + A width in pixels can be set for each margin. Margins with a zero + width are ignored completely. Each margin may be made sensitive to + mouse clicks. A click in a sensitive margin will result in a + SCN_MARGINCLICK notification being sent to the container. Margins + that are not sensitive act as selection margins which make it + easy to select ranges of lines. </p> <h3> Other settings @@ -633,24 +763,24 @@ SCI_SETUSEPALETTE(bool allowPaletteUse) SCI_GETUSEPALETTE </pre> <p> - On 8 bit displays, which can only display a maximum of 256 colours, - the graphics environment mediates between the colour needs of - applications through the use of palettes. On GTK+, Scintilla always - uses a palette. On Windows, there are some problems with visual - flashing when switching between applications with palettes and it - is also necessary for the application containing the Scintilla - control to forward some messages to Scintilla for its palette code + On 8 bit displays, which can only display a maximum of 256 colours, + the graphics environment mediates between the colour needs of + applications through the use of palettes. On GTK+, Scintilla always + uses a palette. On Windows, there are some problems with visual + flashing when switching between applications with palettes and it + is also necessary for the application containing the Scintilla + control to forward some messages to Scintilla for its palette code to work. </p> <p> - Because of these issues, the application must tell Scintilla to use - a palette. If Scintilla is not using a palette, then it will only - be able to display in those colours already available, which are + Because of these issues, the application must tell Scintilla to use + a palette. If Scintilla is not using a palette, then it will only + be able to display in those colours already available, which are often the 20 Windows system colours. </p> <p> - To see an example of how to enable palette support in Scintilla, - search the text of SciTE for WM_PALETTECHANGED, WM_QUERYNEWPALETTE + To see an example of how to enable palette support in Scintilla, + search the text of SciTE for WM_PALETTECHANGED, WM_QUERYNEWPALETTE and SCI_SETUSEPALETTE. </p> <pre> @@ -658,9 +788,9 @@ SCI_SETBUFFEREDDRAW(bool isbuffered) SCI_GETBUFFEREDDRAW </pre> <p> - Turns on or off buffered drawing. Buffered drawing draws each line - into a bitmap rather than directly to the screen and then copies - the bitmap to the screen. This avoids flickering although it does + Turns on or off buffered drawing. Buffered drawing draws each line + into a bitmap rather than directly to the screen and then copies + the bitmap to the screen. This avoids flickering although it does take longer. The default is for drawing to be buffered. </p> <pre> @@ -676,16 +806,16 @@ SCI_SETBACKSPACEUNINDENTS(bool bsUnIndents) SCI_GETBACKSPACEUNINDENTS </pre> <p> - SCI_SETTABWIDTH sets the size of a tab as a multiple of the size - of a space character in the style of the first style definition. - SCI_SETINDENT sets the size of indentation in terms of characters. - SCI_SETUSETABS determines whether indentation should be created out + SCI_SETTABWIDTH sets the size of a tab as a multiple of the size + of a space character in the style of the first style definition. + SCI_SETINDENT sets the size of indentation in terms of characters. + SCI_SETUSETABS determines whether indentation should be created out of a mixture of tabs and space or be based purely on spaces. </p> <p> - Inside indentation whitespace the tab and backspace keys can be - made to indent and unindent rather than insert a tab character or - delete a character with the SCI_SETTABINDENTS and + Inside indentation whitespace the tab and backspace keys can be + made to indent and unindent rather than insert a tab character or + delete a character with the SCI_SETTABINDENTS and SCI_GETBACKSPACEUNINDENTS functions. </p> <pre> @@ -695,13 +825,13 @@ SCI_GETLINEINDENTPOSITION(int line) SCI_GETCOLUMN(int position) </pre> <p> - The amount of indentation on a line can be discovered and set with - SCI_GETLINEINDENTATION and SCI_SETLINEINDENTATION. The indentation - is measured in character columns which correspond to the width of - space characters. - SCI_GETLINEINDENTPOSITION returns the position at the end of - indentation of a line. - SCI_GETCOLUMN returns the column number of a position within the + The amount of indentation on a line can be discovered and set with + SCI_GETLINEINDENTATION and SCI_SETLINEINDENTATION. The indentation + is measured in character columns which correspond to the width of + space characters. + SCI_GETLINEINDENTPOSITION returns the position at the end of + indentation of a line. + SCI_GETCOLUMN returns the column number of a position within the document taking the width of tabs into account. </p> <pre> @@ -709,22 +839,22 @@ SCI_SETCODEPAGE(int codepage) SCI_GETCODEPAGE </pre> <p> - Scintilla has some very simple Japanese DBCS (and probably Chinese - and Korean) support. Use this message with argument set to the - code page number to set Scintilla to use code page information to - ensure double byte characters are treated as one character rather - than two. This also stops the caret from moving between the two - bytes in a double byte character. Call with argument set to zero + Scintilla has some very simple Japanese DBCS (and probably Chinese + and Korean) support. Use this message with argument set to the + code page number to set Scintilla to use code page information to + ensure double byte characters are treated as one character rather + than two. This also stops the caret from moving between the two + bytes in a double byte character. Call with argument set to zero to disable DBCS support. </p> <p> - On Windows, code page SC_CP_UTF8 (65001) sets Scintilla into - Unicode mode with the document treated as a sequence of characters - expressed in UTF-8. The text is converted to UCS-2 before being - drawn by the OS and can thus display Hebrew, Arabic, Cyrillic, and + On Windows, code page SC_CP_UTF8 (65001) sets Scintilla into + Unicode mode with the document treated as a sequence of characters + expressed in UTF-8. The text is converted to UCS-2 before being + drawn by the OS and can thus display Hebrew, Arabic, Cyrillic, and Han characters. Languages which can use two characters stacked vertically in one horizontal space such as Thai will mostly work - but there are som eissues where the characters are drawn + but there are som eissues where the characters are drawn separately leading to visual glitches. Bidirectional text is not supported. </p> @@ -732,10 +862,10 @@ SCI_GETCODEPAGE SCI_SETWORDCHARS(<unused>, char *chars) </pre> <p> - Scintilla has several functions that operate on words which are - defined to be contiguous sequences of characters from a particular - set of characters. This message defines which characters are - members of that set. If chars is null then the default set, + Scintilla has several functions that operate on words which are + defined to be contiguous sequences of characters from a particular + set of characters. This message defines which characters are + members of that set. If chars is null then the default set, alphanumeric and '_', is used. </p> <pre> @@ -744,13 +874,13 @@ SCI_SETFOCUS(bool focus) SCI_GETFOCUS </pre> <p> - On GTK+, focus handling is more complicated than on Windows, + On GTK+, focus handling is more complicated than on Windows, so Scintilla can be told with this message to grab the focus. </p> <p> The internal focus flag can be set with SCI_SETFOCUS. - This is used by clients which have complex focus requirements such - as having their own window which gets the real focus but with the + This is used by clients which have complex focus requirements such + as having their own window which gets the real focus but with the need to indicate that Scintilla has the logical focus. </p> <h3> @@ -762,19 +892,19 @@ SCI_BRACEBADLIGHT(int pos1) SCI_BRACEMATCH(int position, int maxReStyle) </pre> <p> - Up to two characters can be highlighted in a 'brace highlighting - style' which is defined as style number 34. If there is no matching - brace then the 'brace badlighting style', style number 35, can be + Up to two characters can be highlighted in a 'brace highlighting + style' which is defined as style number 34. If there is no matching + brace then the 'brace badlighting style', style number 35, can be used to show the brace that is unmatched. Using a position of INVALID_POSITION removes the highlight. </p> <p> - The SCI_BRACEMATCH message finds a corresponding matching brace - given the position of one brace. The brace characters handled are - '(', ')', '[', ']', '{', '}', '<', and '>'. - A match only occurs if the style of the matching brace is the same - as the starting brace or the matching brace is beyond the end of - styling. Nested braces are handled correctly. The maxReStyle + The SCI_BRACEMATCH message finds a corresponding matching brace + given the position of one brace. The brace characters handled are + '(', ')', '[', ']', '{', '}', '<', and '>'. + A match only occurs if the style of the matching brace is the same + as the starting brace or the matching brace is beyond the end of + styling. Nested braces are handled correctly. The maxReStyle parameter must currently be 0. </p> <h3> @@ -787,15 +917,15 @@ SCI_SETHIGHLIGHTGUIDE(int column) SCI_GETHIGHLIGHTGUIDE </pre> <p> - Indentation guides are dotted vertical lines that appear within - indentation whitespace every indent size columns. They make it - easy to see which constructs line up especially when they extend + Indentation guides are dotted vertical lines that appear within + indentation whitespace every indent size columns. They make it + easy to see which constructs line up especially when they extend over multiple pages. Style 37 is used to specify the foreground and background colour of the indentation guides. </p> <p> - When brace highlighting occurs, the indentation guide corresponding - to the braces may be highlighted with the brace highlighting style, + When brace highlighting occurs, the indentation guide corresponding + to the braces may be highlighted with the brace highlighting style, 34. </p> <h3> @@ -815,47 +945,47 @@ SCI_MARKERLINEFROMHANDLE(int handle) SCI_MARKERDELETEHANDLE(int handle) </pre> <p> - Markers appear in the selection margin to the left of the text. - They are small geometric symbols often used in debuggers to - indicate breakpoints and the current line. If the selection margin - is set to zero width then the background colour of the whole line - is changed instead. There may be up to 32 marker symbols defined - and each line has a set of these markers associated with it. The - markers are drawn in the order of their numbers. Markers try to - move with their text by tracking where the start of their line - moves. When a line is deleted, its markers are combined, by an or - operation, with the markers of the previous line. The - SCI_MARKERDELETEALL removes markers of the given number from all - lines, and treats a parameter of -1 as meaning delete all markers + Markers appear in the selection margin to the left of the text. + They are small geometric symbols often used in debuggers to + indicate breakpoints and the current line. If the selection margin + is set to zero width then the background colour of the whole line + is changed instead. There may be up to 32 marker symbols defined + and each line has a set of these markers associated with it. The + markers are drawn in the order of their numbers. Markers try to + move with their text by tracking where the start of their line + moves. When a line is deleted, its markers are combined, by an or + operation, with the markers of the previous line. The + SCI_MARKERDELETEALL removes markers of the given number from all + lines, and treats a parameter of -1 as meaning delete all markers from all lines.<br /> - SCI_MARKERADD returns a marker handle number which may be used to - find out where a marker has moved to with the - SCI_MARKERLINEFROMHANDLE message. SCI_MARKERDELETEHANDLE can be + SCI_MARKERADD returns a marker handle number which may be used to + find out where a marker has moved to with the + SCI_MARKERLINEFROMHANDLE message. SCI_MARKERDELETEHANDLE can be used to delete a marker based upon its handle. </p> <p> - SCI_MARKERGET retrieves the set of markers associated with a line. - SCI_MARKERNEXT and SCI_MARKERPREVIOUS can be used to efficiently - search for lines that contain markers. They return the next / - previous line with a set of markers that includes some of the bits + SCI_MARKERGET retrieves the set of markers associated with a line. + SCI_MARKERNEXT and SCI_MARKERPREVIOUS can be used to efficiently + search for lines that contain markers. They return the next / + previous line with a set of markers that includes some of the bits set in the markermask parameter.<br /> - The markermask is equal to a OR of (1 << markernumber) for + The markermask is equal to a OR of (1 << markernumber) for each marker of the desired / retrieved set. </p> <p> - The marker symbols currently available are SC_MARK_CIRCLE, - SC_MARK_ROUNDRECT, SC_MARK_ARROW, SC_MARK_SMALLRECT, - SC_MARK_SHORTARROW, SC_MARK_EMPTY, SC_MARK_ARROWDOWN, - SC_MARK_MINUS, SC_MARK_PLUS. + The marker symbols currently available are SC_MARK_CIRCLE, + SC_MARK_ROUNDRECT, SC_MARK_ARROW, SC_MARK_SMALLRECT, + SC_MARK_SHORTARROW, SC_MARK_EMPTY, SC_MARK_ARROWDOWN, + SC_MARK_MINUS, SC_MARK_PLUS. The SC_MARK_BACKGROUND marker changes the background colour of the line only. The SC_MARK_EMPTY symbol is invisible, - allowing client code to track the movement of lines. - Characters can be used as markers by adding + allowing client code to track the movement of lines. + Characters can be used as markers by adding the ASCII value of the character to SC_MARK_CHARACTER. </p> <p> - There are also marker symbols available for the folding margin in a + There are also marker symbols available for the folding margin in a flattened tree style: SC_MARK_BOXMINUS, SC_MARK_BOXMINUSCONNECTED, @@ -873,19 +1003,19 @@ SCI_MARKERDELETEHANDLE(int handle) </p> <p> The marker numbers SC_MARKNUM_FOLDER and SC_MARKNUM_FOLDEROPEN are - used for showing that a fold is present and open or closed. Any - symbols may be assigned for this purpose although the - (SC_MARK_PLUS, SC_MARK_MINUS) pair or the (SC_MARK_ARROW, + used for showing that a fold is present and open or closed. Any + symbols may be assigned for this purpose although the + (SC_MARK_PLUS, SC_MARK_MINUS) pair or the (SC_MARK_ARROW, SC_MARK_ARROWDOWN) pair are good choices. - As well as these two, more assignments are needed for the + As well as these two, more assignments are needed for the flattened tree style: SC_MARKNUM_FOLDEREND, SC_MARKNUM_FOLDERMIDTAIL, SC_MARKNUM_FOLDEROPENMID, SC_MARKNUM_FOLDERSUB, and SC_MARKNUM_FOLDERTAIL. - The bits used for folding is specified by SC_MASK_FOLDERS which is - commonly used as an argument to SCI_SETMARGINMASKN when defining a + The bits used for folding is specified by SC_MASK_FOLDERS which is + commonly used as an argument to SCI_SETMARGINMASKN when defining a margin to be used for folding. </p> <h3> @@ -898,16 +1028,16 @@ SCI_INDICSETFORE(int indicatornumber, int colour) SCI_INDICGETFORE(int indicatornumber) </pre> <p> - These messages allow setting the visual appearance of the three + These messages allow setting the visual appearance of the three (0, 1, and 2) available indicators. </p> <p> - The indicator styles currently available are INDIC_PLAIN, + The indicator styles currently available are INDIC_PLAIN, INDIC_SQUIGGLE, INDIC_TT, INDIC_DIAGONAL, and INDIC_STRIKE. </p> <p> - The indicators are set using SCI_STARTSTYLING with a INDICS_MASK - mask and SCI_SETSTYLING with the values INDIC0_MASK, INDIC1_MASK + The indicators are set using SCI_STARTSTYLING with a INDICS_MASK + mask and SCI_SETSTYLING with the values INDIC0_MASK, INDIC1_MASK and INDIC2_MASK. </p> <h3> @@ -936,48 +1066,48 @@ SCI_AUTOCSETDROPRESTOFWORD(bool dropRestOfWord) SCI_AUTOCGETDROPRESTOFWORD </pre> <p> - Auto completion displays a list box based upon the users typing - showing likely identifiers. - The user chooses the currently selected item by pressing the tab character + Auto completion displays a list box based upon the users typing + showing likely identifiers. + The user chooses the currently selected item by pressing the tab character or another character that is a member of the fillup character set defined with SCI_AUTOCSETFILLUPS. </p> <p> - The SCI_AUTOCSHOW message causes this list to be displayed, with - its argument being a list of words separated by separator - characters. The initial separator character is a space but this can - be set or got with SCI_AUTOCSETSEPARATOR and + The SCI_AUTOCSHOW message causes this list to be displayed, with + its argument being a list of words separated by separator + characters. The initial separator character is a space but this can + be set or got with SCI_AUTOCSETSEPARATOR and SCI_AUTOCGETSEPARATOR. - SCI_AUTOCPOSSTART returns the value of the current position when + SCI_AUTOCPOSSTART returns the value of the current position when SCI_AUTOCSHOW started display of the list. An entry can be selected SCI_AUTOCSELECT. The list of words should be in sorted order. </p> <p> - The current selection can be triggered with the SCI_AUTOCCOMPLETE - message. This has the same effect as the tab key. When in + The current selection can be triggered with the SCI_AUTOCCOMPLETE + message. This has the same effect as the tab key. When in autocompletion mode, the list should disappear when the user - types a character that can not be part of the autocompletion, - such as '.', '(' or '[' when typing an identifier. A set of + types a character that can not be part of the autocompletion, + such as '.', '(' or '[' when typing an identifier. A set of characters which will cancel autocompletion can be specified with the SCI_AUTOCSTOPS. </p> <p> - If set to ignore case mode with SCI_AUTOCSETIGNORECASE, + If set to ignore case mode with SCI_AUTOCSETIGNORECASE, then strings are matched after being converted to upper case. - One result of this is that the list should be sorted with the punctuation + One result of this is that the list should be sorted with the punctuation characters '[', '\', ']', '^', '_', and '`' sorted after letters. </p> <p> - The default behaviour is for the list to be cancelled if the caret - moves before the location it was at when the list was displayed. - By calling SCI_AUTOCSETCANCELATSTART with a false argument, the - list is not cancelled until the caret moves before the first + The default behaviour is for the list to be cancelled if the caret + moves before the location it was at when the list was displayed. + By calling SCI_AUTOCSETCANCELATSTART with a false argument, the + list is not cancelled until the caret moves before the first character of the word being completed. </p> <p> - The list will also be cancelled if there are no viable matches. - To avoid this behaviour call SCI_AUTOCSETAUTOHIDE with a false + The list will also be cancelled if there are no viable matches. + To avoid this behaviour call SCI_AUTOCSETAUTOHIDE with a false argument. </p> <p> @@ -991,11 +1121,11 @@ SCI_AUTOCGETDROPRESTOFWORD SCI_USERLISTSHOW(int listType,char *list) </pre> <p> - User lists are similar to auto completion but do not insert text - when an item is selected, instead notifying the container with a - SCN_USERLISTSELECTION. - The listType parameter is returned to the container and can be used - to differentiate between different types of list such as between a + User lists are similar to auto completion but do not insert text + when an item is selected, instead notifying the container with a + SCN_USERLISTSELECTION. + The listType parameter is returned to the container and can be used + to differentiate between different types of list such as between a list of buffers and a list of keywords. </p> <h3> @@ -1010,17 +1140,17 @@ SCI_CALLTIPSETHLT(int highlightstart, int highlightend) SCI_CALLTIPSETBACK(int colour) </pre> <p> - Call tips are small windows displaying the arguments to a function - and are displayed after the user has typed the name of the + Call tips are small windows displaying the arguments to a function + and are displayed after the user has typed the name of the function. As the user types values for each argument, the name of the argument currently being entered is highlighted. </p> <p> - SCI_CALLTIPSHOW starts the process by displaying the calltip - window, with the definition argument containing the text to + SCI_CALLTIPSHOW starts the process by displaying the calltip + window, with the definition argument containing the text to display. SCI_CALLTIPPOSSTART returns the value of the current - position when SCI_CALLTIPSHOW started display of the list. - SCI_CALLTIPSETHLT sets the region of the calltip text displayed in + position when SCI_CALLTIPSHOW started display of the list. + SCI_CALLTIPSETHLT sets the region of the calltip text displayed in a highlighted style. The background colour of calltips can be set with SCI_CALLTIPSETBACK with the default being white. </p> @@ -1079,12 +1209,12 @@ SCI_WORDPARTRIGHT SCI_WORDPARTRIGHTEXTEND </pre> <p> - To allow the container application to perform any of the actions - available to the user with keyboard, all the keyboard actions are + To allow the container application to perform any of the actions + available to the user with keyboard, all the keyboard actions are messages. They do not take any parameters. </p> <p> - These commands are also used when redefining the key bindings with + These commands are also used when redefining the key bindings with the SCI_ASSIGNCMDKEY message. </p> <p> @@ -1102,19 +1232,19 @@ SCI_CLEARALLCMDKEYS SCI_NULL </pre> <p> - There is a default binding of keys to commands in Scintilla which - can be overridden with these messages. - To fit the parameters into a message, the first argument contains - the key code in the low word and the key modifiers (possibly shift - and control) in the high word. The key code is a visible or control - character or a key from the SCK_* enumeration, + There is a default binding of keys to commands in Scintilla which + can be overridden with these messages. + To fit the parameters into a message, the first argument contains + the key code in the low word and the key modifiers (possibly shift + and control) in the high word. The key code is a visible or control + character or a key from the SCK_* enumeration, which contains SCK_ADD, SCK_BACK, SCK_DELETE, SCK_DIVIDE, SCK_DOWN, SCK_END, SCK_ESCAPE, SCK_HOME, SCK_INSERT, - SCK_LEFT, SCK_NEXT, SCK_PRIOR, SCK_RETURN, SCK_RIGHT, + SCK_LEFT, SCK_NEXT, SCK_PRIOR, SCK_RETURN, SCK_RIGHT, SCK_SUBTRACT, SCK_TAB, and SCK_UP. The modifiers are a combination of zero or more of - SCMOD_ALT, SCMOD_CTRL, and SCMOD_SHIFT. - SCI_NULL does nothing and is the value assigned to keys that + SCMOD_ALT, SCMOD_CTRL, and SCMOD_SHIFT. + SCI_NULL does nothing and is the value assigned to keys that perform no action. </p> <h3> @@ -1124,7 +1254,7 @@ SCI_NULL SCI_USEPOPUP </pre> <p> - Clicking the wrong button on the mouse pops up a short default + Clicking the wrong button on the mouse pops up a short default editing menu. This may be turned off with SCI_USEPOPUP(0). </p> @@ -1136,9 +1266,9 @@ SCI_STARTRECORD SCI_STOPRECORD </pre> <p> - Start and stop macro recording mode. - In macro recording mode, actions are reported to the container through - SCN_MACRORECORD notifications. It is then up to the container to + Start and stop macro recording mode. + In macro recording mode, actions are reported to the container through + SCN_MACRORECORD notifications. It is then up to the container to record these actions for future replay. </p> <h3> @@ -1152,22 +1282,22 @@ SCI_SETPRINTCOLOURMODE(int mode) SCI_GETPRINTCOLOURMODE </pre> <p> - On Windows SCI_FORMATRANGE can be used to draw the text onto a + On Windows SCI_FORMATRANGE can be used to draw the text onto a display context which can include a printer display context. </p> <p> - To print at a different size than drawing on screen use - SCI_SETPRINTMAGNIFICATION with a value which is the number of + To print at a different size than drawing on screen use + SCI_SETPRINTMAGNIFICATION with a value which is the number of points to add to each style. -3 or -4 gives reasonable small print. </p> <p> - If a black background is used on the screen then it is best to - invert the light value of all colours with - SCI_SETPRINTCOLOURMODE(SC_PRINT_INVERTLIGHT) when printing to give - a white background. - If intermediate tones are used on screen then black on white print + If a black background is used on the screen then it is best to + invert the light value of all colours with + SCI_SETPRINTCOLOURMODE(SC_PRINT_INVERTLIGHT) when printing to give + a white background. + If intermediate tones are used on screen then black on white print can be chosen with SCI_SETPRINTCOLOURMODE(SC_PRINT_BLACKONWHITE). - Other options are the default, SC_PRINT_NORMAL, and + Other options are the default, SC_PRINT_NORMAL, and SC_PRINT_COLOURONWHITE and SC_PRINT_COLOURONWHITEDEFAULTBG. </p> <h3> @@ -1178,24 +1308,24 @@ SCI_GETDIRECTFUNCTION SCI_GETDIRECTPOINTER </pre> <p> - On Windows, the message passing scheme used to communicate between - the container and Scintilla is mediated by the operating system - SendMessage function which can lead to bad performance when - calling intensively. - To avoid this overhead a pointer to a message handling function - inside Scintilla can be retrieved with SCI_GETDIRECTFUNCTION. - The first argument to use when calling the returned function is the - value retrieved from SCI_GETDIRECTPOINTER. After that go the - message number, wParam, and lParam. + On Windows, the message passing scheme used to communicate between + the container and Scintilla is mediated by the operating system + SendMessage function which can lead to bad performance when + calling intensively. + To avoid this overhead a pointer to a message handling function + inside Scintilla can be retrieved with SCI_GETDIRECTFUNCTION. + The first argument to use when calling the returned function is the + value retrieved from SCI_GETDIRECTPOINTER. After that go the + message number, wParam, and lParam. </p> <p> - While faster, this direct calling will cause problems if performed - from a different thread to the native thread of the Scintilla + While faster, this direct calling will cause problems if performed + from a different thread to the native thread of the Scintilla window in which case SendMessage should be used to synchronize with the window's thread. </p> <p> - This feature also works on GTK+ but has no significant impact on + This feature also works on GTK+ but has no significant impact on speed. </p> <h3> @@ -1209,23 +1339,23 @@ SCI_ADDREFDOCUMENT(<unused>,document *pdoc) SCI_RELEASEDOCUMENT(<unused>,document *pdoc) </pre> <p> - This is to allow simple split views of documents and so - applications may maintain multiple buffer which may be - individually selected into the editor. Each Scintilla has a pointer - to a used document. - Initially the used document is a default one created when the - Scintilla was created. - The SCI_GETDOCPOINTER call returns a pointer to the used document. - SCI_SETDOCPOINTER sets the used document. + This is to allow simple split views of documents and so + applications may maintain multiple buffer which may be + individually selected into the editor. Each Scintilla has a pointer + to a used document. + Initially the used document is a default one created when the + Scintilla was created. + The SCI_GETDOCPOINTER call returns a pointer to the used document. + SCI_SETDOCPOINTER sets the used document. SCI_SETDOCPOINTER(0) switches to a new empty document. - Before closing down Scintilla make sure all document pointers - retrieved are released to avoid memory leaks. + Before closing down Scintilla make sure all document pointers + retrieved are released to avoid memory leaks. </p> <p> - A new document may be created by SCI_CREATEDOCUMENT which returns a - pointer to the document. This document is not selected into the - editor and starts with a reference count of 1. A document may be - released with SCI_RELEASEDOCUMENT and have its reference count + A new document may be created by SCI_CREATEDOCUMENT which returns a + pointer to the document. This document is not selected into the + editor and starts with a reference count of 1. A document may be + released with SCI_RELEASEDOCUMENT and have its reference count incremented with SCI_ADDREFDOCUMENT. </p> <h3> @@ -1249,60 +1379,60 @@ SCI_ENSUREVISIBLE(int line) SCI_ENSUREVISIBLEENFORCEPOLICY(int line) </pre> <p> - The fundamental operation in folding is making lines invisible or - visible. - Line visibility is a property of the view rather than the document - so each view may be displaying a different set of lines. - SCI_SHOWLINES and SCI_HIDELINES show or hide a range of lines. - SCI_GETLINEVISIBLE determines whether a line is visible. - When some lines are hidden, then a particular line in the document - may be displayed at a different position to its document position. - SCI_VISIBLEFROMDOCLINE and SCI_DOCLINEFROMVISIBLE map from + The fundamental operation in folding is making lines invisible or + visible. + Line visibility is a property of the view rather than the document + so each view may be displaying a different set of lines. + SCI_SHOWLINES and SCI_HIDELINES show or hide a range of lines. + SCI_GETLINEVISIBLE determines whether a line is visible. + When some lines are hidden, then a particular line in the document + may be displayed at a different position to its document position. + SCI_VISIBLEFROMDOCLINE and SCI_DOCLINEFROMVISIBLE map from document line to display line and back. </p> <p> - Generally the fold points of a document are based on the - hierarchical structure of the contents of the document. - In Python, the hierarchy is determined by indentation and in C++ - by brace characters. This hierarchy can be represented within a - Scintilla document object by attaching a numeric level to each - line. - The initial level of a file is SC_FOLDLEVELBASE to allow unsigned - arithmetic on levels. The SC_FOLDLEVELNUMBERMASK constant can be + Generally the fold points of a document are based on the + hierarchical structure of the contents of the document. + In Python, the hierarchy is determined by indentation and in C++ + by brace characters. This hierarchy can be represented within a + Scintilla document object by attaching a numeric level to each + line. + The initial level of a file is SC_FOLDLEVELBASE to allow unsigned + arithmetic on levels. The SC_FOLDLEVELNUMBERMASK constant can be used to mask out the other bits to reveal the fold level number. - There are also two bit flags associated with each line. - SC_FOLDLEVELWHITEFLAG indicates that the line is blank and allows - it to be treated slightly different then its level may indicate. - For example, blank lines should generally not be fold points. - SC_FOLDLEVELHEADERFLAG indicates that the line is a header or fold + There are also two bit flags associated with each line. + SC_FOLDLEVELWHITEFLAG indicates that the line is blank and allows + it to be treated slightly different then its level may indicate. + For example, blank lines should generally not be fold points. + SC_FOLDLEVELHEADERFLAG indicates that the line is a header or fold point. </p> <p> - The hierarchy can be navigated just through SCI_GETFOLDLEVEL, but - it is often useful to find the parent of a line (SCI_GETFOLDPARENT) + The hierarchy can be navigated just through SCI_GETFOLDLEVEL, but + it is often useful to find the parent of a line (SCI_GETFOLDPARENT) or the line that is the last child of a line (SCI_GETLASTCHILD). </p> <p> - Each fold point may be either expanded, displaying all its child - lines, or contracted, hiding all the child lines. This is per view - state and can be manipulated with SCI_SETFOLDEXPANDED and - SCI_GETFOLDEXPANDED. Using SCI_SETFOLDEXPANDED does not show or - hide any lines but only changes a state flag and the margin markers - that show the contraction state. SCI_TOGGLEFOLD performs the - expansion or contraction of a fold point in the manner normally - expected. + Each fold point may be either expanded, displaying all its child + lines, or contracted, hiding all the child lines. This is per view + state and can be manipulated with SCI_SETFOLDEXPANDED and + SCI_GETFOLDEXPANDED. Using SCI_SETFOLDEXPANDED does not show or + hide any lines but only changes a state flag and the margin markers + that show the contraction state. SCI_TOGGLEFOLD performs the + expansion or contraction of a fold point in the manner normally + expected. </p> <p> - A hidden line may be hidden because more than one of its parent - lines is contracted. SCI_ENSUREVISIBLE travels up the fold - hierarchy, expanding any contracted folds until it reaches the top + A hidden line may be hidden because more than one of its parent + lines is contracted. SCI_ENSUREVISIBLE travels up the fold + hierarchy, expanding any contracted folds until it reaches the top level. The line will then be visible. </p> <p> - The fold flags is a set of bit flags set with the SCI_SETFOLDFLAGS - message to determine where folding lines are drawn. 2 is draw above - if expanded, 4 is draw above if not expanded. 8 is draw below if - expanded and 16 is draw below if not expanded. + The fold flags is a set of bit flags set with the SCI_SETFOLDFLAGS + message to determine where folding lines are drawn. 2 is draw above + if expanded, 4 is draw above if not expanded. 8 is draw below if + expanded and 16 is draw below if not expanded. 64 is display hexadecimal fold levels in line margin to aid debugging folding. This feature needs to be redesigned to be sensible. </p> @@ -1314,11 +1444,11 @@ SCI_SETWRAPMODE(SC_WRAP_NONE or SC_WRAP_WORD) SCI_GETWRAPMODE </pre> <p> - When the wrap mode is set to SC_WRAP_WORD lines wider than the - window width are continued on the following lines. Lines are + When the wrap mode is set to SC_WRAP_WORD lines wider than the + window width are continued on the following lines. Lines are broken after space or tab characters or between runs of different - styles. If this is not possible because a word in one style is - wider than the window then the break occurs before after the last + styles. If this is not possible because a word in one style is + wider than the window then the break occurs before after the last character that completely fits on the line. The horizontal scroll bar does not appear when wrap mode is on. </p> @@ -1329,21 +1459,21 @@ SCI_GETLAYOUTCACHE <p> Much of the time used by Scintilla is spent on laying out and drawing text. The same text layout calculations may be performed many times - even when the data used in these calculations does not change. + even when the data used in these calculations does not change. To avoid these unnecessary calculations in some circumstances, the line - layout cache can store the results of the calculations. - The cache in invalidated whenever the underlying data, such as the contents + layout cache can store the results of the calculations. + The cache in invalidated whenever the underlying data, such as the contents or styling of the document changes. Caching the layout of the whole document has the most effect, making dynamic - line wrap as much as 20 times faster but this requires 7 times the memory + line wrap as much as 20 times faster but this requires 7 times the memory required by the document contents. </p> <p> SC_CACHE_NONE performs no caching and is the default. SC_CACHE_CARET caches the layout information for the line containing the - caret. + caret. SC_CACHE_PAGE caches the layout of the visible lines and the caret - line. + line. SC_CACHE_DOCUMENT caches the layout of the entire document. </p> <h3> @@ -1356,32 +1486,32 @@ SCI_SETZOOM SCI_GETZOOM </pre> <p> - The text can be made larger and smaller by using SCI_ZOOMIN and + The text can be made larger and smaller by using SCI_ZOOMIN and SCI_ZOOMOUT. - The zoom level can be retrieved by SCI_GETZOOM and set by - SCI_SETZOOM. - The zoom factors may range from -10 to + 20 and is added to each + The zoom level can be retrieved by SCI_GETZOOM and set by + SCI_SETZOOM. + The zoom factors may range from -10 to + 20 and is added to each styles point size. The calculated point size never goes below 2. </p> <h3> Long Lines </h3> <pre> -SCI_GETEDGECOLUMN +SCI_GETEDGECOLUMN SCI_SETEDGECOLUMN(int column) SCI_GETEDGEMODE SCI_SETEDGEMODE(int mode) -SCI_GETEDGECOLOUR +SCI_GETEDGECOLOUR SCI_SETEDGECOLOUR(int colour) </pre> <p> - This mechanism marks lines that are longer than a specified length - in one of two ways. A vertical line can be displayed at the - specified column number (EDGE_LINE) or characters after that - column can be displayed with a specified background colour - (EDGE_BACKGROUND). The vertical line works well for monospaced - fonts but not for proportional fonts which should use - EDGE_BACKGROUND. The default is to not have any form of long line + This mechanism marks lines that are longer than a specified length + in one of two ways. A vertical line can be displayed at the + specified column number (EDGE_LINE) or characters after that + column can be displayed with a specified background colour + (EDGE_BACKGROUND). The vertical line works well for monospaced + fonts but not for proportional fonts which should use + EDGE_BACKGROUND. The default is to not have any form of long line marking (EDGE_NONE). </p> <h3> @@ -1396,44 +1526,44 @@ SCI_SETPROPERTY(char *key, char *value) SCI_SETKEYWORDS(int keywordset, char *keywordlist) </pre> <p> - If the SciLexer version of Scintilla is used, then lexing support - for some programming languages is included. A particular lexer may - be chosen from the SCLEX* enumeration and it is invoked - automatically to style the document as required. Lexers can also + If the SciLexer version of Scintilla is used, then lexing support + for some programming languages is included. A particular lexer may + be chosen from the SCLEX* enumeration and it is invoked + automatically to style the document as required. Lexers can also be chosen by string name rather than by integer ID. - If the lexer is set to SCLEX_CONTAINER then the container is - notified to perform styling as is the case with the standard - Scintilla.DLL version. Styling may be requested for a range of the + If the lexer is set to SCLEX_CONTAINER then the container is + notified to perform styling as is the case with the standard + Scintilla.DLL version. Styling may be requested for a range of the document by using SCI_COLOURISE. </p> <p> - Settings can be communicated to the lexers using SCI_SETPROPERTY. - Currently the "fold" property is defined for most of the lexers to - set the fold structure if set to "1". SCLEX_PYTHON understands - "tab.timmy.whinge.level" as a setting that determines how to + Settings can be communicated to the lexers using SCI_SETPROPERTY. + Currently the "fold" property is defined for most of the lexers to + set the fold structure if set to "1". SCLEX_PYTHON understands + "tab.timmy.whinge.level" as a setting that determines how to indicate bad indentation. Many languages style a set of keywords - distinctly from other words. Some languages, such as HTML may - contain embedded languages, VBScript and Javascript are common for - HTML. SCI_SETKEYWORDS specifies the keywords separated by spaces. - For HTML, key word set is for HTML, 1 is for Javascript and 2 is + distinctly from other words. Some languages, such as HTML may + contain embedded languages, VBScript and Javascript are common for + HTML. SCI_SETKEYWORDS specifies the keywords separated by spaces. + For HTML, key word set is for HTML, 1 is for Javascript and 2 is for VBScript. </p> <h3> Notifications </h3> <p> - Notifications are sent (fired) from the Scintilla control to its - container when an event has occurred that may interest the - container. Notifications are sent using the WM_NOTIFY message on - Windows and the "notify" signal on GTK+ with a structure containing + Notifications are sent (fired) from the Scintilla control to its + container when an event has occurred that may interest the + container. Notifications are sent using the WM_NOTIFY message on + Windows and the "notify" signal on GTK+ with a structure containing information about the event. </p> <pre> SCN_STYLENEEDED(int endstyleneeded) </pre> <p> - Before displaying a page or printing, this message is sent to the - container. It is a good opportunity for the container to ensure + Before displaying a page or printing, this message is sent to the + container. It is a good opportunity for the container to ensure that syntax styling information for the visible text. </p> <pre> @@ -1441,20 +1571,20 @@ SCN_UPDATEUI SCN_CHECKBRACE </pre> <p> - Either the text or styling of the document has changed or the - selection range has changed. Now would be a good time to update - any container UI elements that depend on document or view state. - Was previously called SCN_CHECKBRACE because a common use is to - check whether the caret is next to a brace and set highlights on + Either the text or styling of the document has changed or the + selection range has changed. Now would be a good time to update + any container UI elements that depend on document or view state. + Was previously called SCN_CHECKBRACE because a common use is to + check whether the caret is next to a brace and set highlights on this brace and its corresponding matching brace. </p> <pre> SCN_CHARADDED(int charadded) </pre> <p> - Fired when the user types an ordinary text character (as opposed - to a command character) which is entered into the text. - Can be used by the container to decide to display a call tip or + Fired when the user types an ordinary text character (as opposed + to a command character) which is entered into the text. + Can be used by the container to decide to display a call tip or auto completion list. </p> <pre> @@ -1470,24 +1600,24 @@ SCN_SAVEPOINTLEFT SCI_SETSAVEPOINT </pre> <p> - Sent to the container when the savepoint is entered or left, - allowing the container to display a dirty indicator and change its - menus. + Sent to the container when the savepoint is entered or left, + allowing the container to display a dirty indicator and change its + menus. </p> <p> - The container tells Scintilla where the save point is by sending - the SCI_SETSAVEPOINT message. This is usually done when the file - is saved or loaded. As Scintilla performs undo and redo - operations, it will notify the container that it has entered or - left the save point, allowing the container to know if the file + The container tells Scintilla where the save point is by sending + the SCI_SETSAVEPOINT message. This is usually done when the file + is saved or loaded. As Scintilla performs undo and redo + operations, it will notify the container that it has entered or + left the save point, allowing the container to know if the file should be considered dirty or not. </p> <pre> SCN_MODIFYATTEMPTRO </pre> <p> - When in read-only mode, this notification is sent to the container - should the user try to edit the document. This can be used to + When in read-only mode, this notification is sent to the container + should the user try to edit the document. This can be used to check the document out of a version control system. </p> <pre> @@ -1500,7 +1630,7 @@ SCN_DOUBLECLICK SCN_KEY </pre> <p> - Reports all keys pressed. Used on GTK+ because of some problems + Reports all keys pressed. Used on GTK+ because of some problems with keyboard focus. Not sent by Windows version. </p> <pre> @@ -1508,10 +1638,10 @@ SCEN_SETFOCUS SCEN_KILLFOCUS </pre> <p> - SCEN_SETFOCUS is fired when Scintilla receives focus and + SCEN_SETFOCUS is fired when Scintilla receives focus and SCEN_KILLFOCUS when it loses focus. - These notifications are sent using the WM_COMMAND message on - Windows and the "Command" signal on GTK+ as this is the behaviour + These notifications are sent using the WM_COMMAND message on + Windows and the "Command" signal on GTK+ as this is the behaviour of the standard edit control. The SET and KILL values are flipped over from the Windows edit control and as clients depend on these constants, this will not be changed @@ -1524,91 +1654,91 @@ SCI_SETMODEVENTMASK(int eventmask) SCI_GETMODEVENTMASK </pre> <p> - SCN_MODIFIED is fired when the document has been changed including - changes to both the text and styling. The notification structure - contains information about what changed, how the change occurred - and whether this changed the number of lines in the document. No + SCN_MODIFIED is fired when the document has been changed including + changes to both the text and styling. The notification structure + contains information about what changed, how the change occurred + and whether this changed the number of lines in the document. No modifications may be performed while in a SCN_MODIFIED event. </p> <p> - SCEN_CHANGE is fired when the text of the document has been changed - for any reason. This notification is sent using the WM_COMMAND - message on Windows and the "Command" signal on GTK+ as this is the + SCEN_CHANGE is fired when the text of the document has been changed + for any reason. This notification is sent using the WM_COMMAND + message on Windows and the "Command" signal on GTK+ as this is the behaviour of the standard edit control. </p> <p> - Both these notifications can be masked by the SCI_SETMODEVENTMASK - function which sets which notification types are sent to the + Both these notifications can be masked by the SCI_SETMODEVENTMASK + function which sets which notification types are sent to the container. For example, a container may decide to see only - notifications about changes to text and not styling changes by + notifications about changes to text and not styling changes by calling SCI_SETMODEVENTMASK(SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT). </p> <p> The possible notification types are SC_MOD_INSERTTEXT, - SC_MOD_DELETETEXT, - SC_MOD_CHANGESTYLE, - SC_MOD_CHANGEFOLD, - SC_PERFORMED_USER, - SC_PERFORMED_UNDO, - SC_PERFORMED_REDO, - SC_LASTSTEPINUNDOREDO, - SC_MOD_CHANGEMARKER, - SC_MOD_BEFOREINSERT, - SC_MOD_BEFOREDELETE, and + SC_MOD_DELETETEXT, + SC_MOD_CHANGESTYLE, + SC_MOD_CHANGEFOLD, + SC_PERFORMED_USER, + SC_PERFORMED_UNDO, + SC_PERFORMED_REDO, + SC_LASTSTEPINUNDOREDO, + SC_MOD_CHANGEMARKER, + SC_MOD_BEFOREINSERT, + SC_MOD_BEFOREDELETE, and SC_MODEVENTMASKALL. </p> <pre> SCN_MACRORECORD </pre> <p> - Tells the container that an operation is being performed so that - the container may choose to record the fact if it is in a macro - recording mode. + Tells the container that an operation is being performed so that + the container may choose to record the fact if it is in a macro + recording mode. The fields set in this notification are message, wParam, and lParam. </p> <pre> SCN_MARGINCLICK </pre> <p> - Tells the container that the mouse was clicked inside a margin - marked sensitive. Can be used to perform folding or to place + Tells the container that the mouse was clicked inside a margin + marked sensitive. Can be used to perform folding or to place breakpoints. </p> <pre> SCN_NEEDSHOWN </pre> <p> - Scintilla has determined that a range of lines that is currently - invisible should be made visible. - An example of where this may be needed is if the end of line of a - contracted fold point is deleted. This message is sent to the - container in case it wants to make the line visible in some - unusual way such as making the whole document visible. - Most containers will just ensure each line in the range is + Scintilla has determined that a range of lines that is currently + invisible should be made visible. + An example of where this may be needed is if the end of line of a + contracted fold point is deleted. This message is sent to the + container in case it wants to make the line visible in some + unusual way such as making the whole document visible. + Most containers will just ensure each line in the range is visible by calling SCI_ENSUREVISIBLE. </p> <pre> SCN_PAINTED </pre> <p> - Painting has just been done. Useful when you want to update some - other widgets based on a change in Scintilla, but want to have the + Painting has just been done. Useful when you want to update some + other widgets based on a change in Scintilla, but want to have the paint occur first to appear more responsive. </p> <pre> SCN_USERLISTSELECTION </pre> <p> - User has selected an item in a user list. + User has selected an item in a user list. The list type is available in wParam and the text chosen in text. </p> <pre> SCN_URIDROPPED </pre> <p> - Only on the GTK+ version. Indicates that the user has dragged a URI - such as a file name or web address onto Scintilla. + Only on the GTK+ version. Indicates that the user has dragged a URI + such as a file name or web address onto Scintilla. The container could interpret this as a request to open the file. </p> <pre> @@ -1619,16 +1749,16 @@ SCI_GETMOUSEDWELLTIME SC_TIME_FOREVER </pre> <p> - SCN_DWELLSTART is generated when the user hold the - mouse still in one spot for the dwell period. + SCN_DWELLSTART is generated when the user hold the + mouse still in one spot for the dwell period. SCN_DWELLEND is generated after a SCN_DWELLSTART and the mouse is moved or other activity such as key press indicates the dwell is over. </p> <p> - The time the mouse must sit still, in milliseconds, to generate a + The time the mouse must sit still, in milliseconds, to generate a SCI_DWELLSTART. - If set to SC_TIME_FOREVER, the default, no dwell events will be + If set to SC_TIME_FOREVER, the default, no dwell events will be generated. </p> <pre> @@ -1642,7 +1772,7 @@ SCN_ZOOM rather than pixels. </p> <h3> - Edit messages currently supported by Scintilla which will be + Edit messages currently supported by Scintilla which will be removed in the future. </h3> <pre> @@ -1684,7 +1814,7 @@ EM_SELECTIONTYPE EM_HIDESELECTION(bool hide) EM_FINDTEXT(int flags, FINDTEXTEX *ft) EM_FINDTEXTEX(int flags, FINDTEXTEX *ft) -EM_GETMARGINS +EM_GETMARGINS EM_SETMARGINS(EC_LEFTMARGIN or EC_RIGHTMARGIN or EC_USEFONTINFO, int val) EM_FORMATRANGE </pre> @@ -1721,8 +1851,8 @@ EM_DISPLAYBAND EM_SETTARGETDEVICE </pre> <p> - Scintilla tries to be a superset of the standard windows Edit and - Richedit controls wherever that makes sense. As it is not + Scintilla tries to be a superset of the standard windows Edit and + Richedit controls wherever that makes sense. As it is not intended for use in a word processor, some edit messages can not be sensibly handled. Unsupported messages have no effect. </p> @@ -1730,10 +1860,10 @@ EM_SETTARGETDEVICE Building Scintilla </h3> <p> - To build Scintilla or SciTE, see the README file present in both - the scintilla and scite directories. For Windows, GCC 2.95.3, - Borland C++ or Microsoft Visual C++ can be used for building. - For GTK+, GCC 2.95.2 should be used. Only GTK+ 1.2x is + To build Scintilla or SciTE, see the README file present in both + the scintilla and scite directories. For Windows, GCC 2.95.3, + Borland C++ or Microsoft Visual C++ can be used for building. + For GTK+, GCC 2.95.2 should be used. Only GTK+ 1.2x is supported. </p> <h3> @@ -1741,11 +1871,11 @@ EM_SETTARGETDEVICE </h3> <p> On Windows, Scintilla is normally used as a dynamic library as a .DLL file. - If you want to link Scintilla directly into your application .EXE or .DLL file, - then the STATIC_BUILD preprocessor symbol should be defined and - Scintilla_RegisterClasses called. STATIC_BUILD prevents compiling the + If you want to link Scintilla directly into your application .EXE or .DLL file, + then the STATIC_BUILD preprocessor symbol should be defined and + Scintilla_RegisterClasses called. STATIC_BUILD prevents compiling the DllMain function which will conflict with any DllMain defined in your code. - Scintilla_RegisterClasses takes the HINSTANCE of your application and + Scintilla_RegisterClasses takes the HINSTANCE of your application and ensures that the "Scintilla" window class is registered. To make sure that the right pointing arrow cursor used in the margin is displayed by Scintilla add the scintilla/win32/Margin.cur file to your application's resources with @@ -1756,9 +1886,9 @@ EM_SETTARGETDEVICE </h3> <p> Depending on the compiler and linker used, the lexers may be stripped - out. This is most often caused when building a static library. To ensure - the lexers are linked in, the Scintilla_LinkLexers() function may be - called. + out. This is most often caused when building a static library. To ensure + the lexers are linked in, the Scintilla_LinkLexers() function may be + called. </p> <h3> Changing set of lexers diff --git a/include/Scintilla.h b/include/Scintilla.h index b583ab746..4b8ccd23f 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -440,12 +440,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SEARCHANCHOR 2366 #define SCI_SEARCHNEXT 2367 #define SCI_SEARCHPREV 2368 -#define CARET_SLOP 0x01 -#define CARET_CENTER 0x02 -#define CARET_STRICT 0x04 -#define CARET_XEVEN 0x08 -#define CARET_XJUMPS 0x10 -#define SCI_SETCARETPOLICY 2369 #define SCI_LINESONSCREEN 2370 #define SCI_USEPOPUP 2371 #define SCI_SELECTIONISRECTANGLE 2372 @@ -479,6 +473,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETXOFFSET 2397 #define SCI_GETXOFFSET 2398 #define SCI_GRABFOCUS 2400 +#define CARET_SLOP 0x01 +#define CARET_STRICT 0x04 +#define CARET_JUMPS 0x10 +#define CARET_EVEN 0x08 +#define SCI_SETXCARETPOLICY 2402 +#define SCI_SETYCARETPOLICY 2403 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 @@ -613,6 +613,11 @@ struct SCNotification { #ifdef INCLUDE_DEPRECATED_FEATURES +#define SCI_SETCARETPOLICY 2369 +#define CARET_CENTER 0x02 +#define CARET_XEVEN 0x08 +#define CARET_XJUMPS 0x10 + #define SCN_POSCHANGED 2012 #define SCN_CHECKBRACE 2007 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 8a65463fe..11f197ca6 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -35,11 +35,11 @@ ## Features may be removed but they will go through a period of deprecation ## before removal which is signalled by moving them into the Deprecated category. ## -## enu has the syntax enu<ws><enumeration>=<prefix>[<ws><prefix>]* where all the val -## features in this file starting with a given <prefix> are considered part of the +## enu has the syntax enu<ws><enumeration>=<prefix>[<ws><prefix>]* where all the val +## features in this file starting with a given <prefix> are considered part of the ## enumeration. ## -## lex has the syntax lex<ws><name>=<lexerVal><ws><prefix>[<ws><prefix>]* +## lex has the syntax lex<ws><name>=<lexerVal><ws><prefix>[<ws><prefix>]* ## where name is a reasonably capitalised (Python, XML) identifier or UI name, ## lexerVal is the val used to specify the lexer, and the list of prefixes is similar ## to enu. The name may not be the same as that used within the lexer so the lexerVal @@ -86,37 +86,37 @@ val SCI_START=2000 val SCI_OPTIONAL_START=3000 val SCI_LEXER_START=4000 -# Add text to the document +# Add text to the document. fun void AddText=2001(int length, string text) -# Add array of cells to document +# Add array of cells to document. fun void AddStyledText=2002(int length, cells c) -# Insert string at a position +# Insert string at a position. fun void InsertText=2003(position pos, string text) -# Delete all text in the document +# Delete all text in the document. fun void ClearAll=2004(,) -# Set all style bytes to 0, remove all folding information +# Set all style bytes to 0, remove all folding information. fun void ClearDocumentStyle=2005(,) -# The number of characters in the document +# The number of characters in the document. get int GetLength=2006(,) -# Returns the character byte at the position +# Returns the character byte at the position. get int GetCharAt=2007(position pos,) -# Returns the position of the caret +# Returns the position of the caret. get position GetCurrentPos=2008(,) -# Returns the position of the opposite end of the selection to the caret +# Returns the position of the opposite end of the selection to the caret. get position GetAnchor=2009(,) -# Returns the style byte at the position +# Returns the style byte at the position. get int GetStyleAt=2010(position pos,) -# Redoes the next action on the undo history +# Redoes the next action on the undo history. fun void Redo=2011(,) # Choose between collecting actions into the undo @@ -134,10 +134,10 @@ fun void SetSavePoint=2014(,) # Returns the number of bytes in the buffer not including terminating nulls. fun int GetStyledText=2015(, textrange tr) -# Are there any redoable actions in the undo history. +# Are there any redoable actions in the undo history? fun bool CanRedo=2016(,) -# Retrieve the line number at which a particular marker is located +# Retrieve the line number at which a particular marker is located. fun int MarkerLineFromHandle=2017(int handle,) # Delete a marker. @@ -197,23 +197,21 @@ get int GetEOLMode=2030(,) set void SetEOLMode=2031(int eolMode,) # Set the current styling position to pos and the styling mask to mask. -# The styling mask can be used to protect some bits in each styling byte from -# modification. +# The styling mask can be used to protect some bits in each styling byte from modification. fun void StartStyling=2032(position pos, int mask) # Change style from current styling position for length characters to a style # and move the current styling position to after this newly styled segment. fun void SetStyling=2033(int length, int style) -# Is drawing done first into a buffer or direct to the screen. +# Is drawing done first into a buffer or direct to the screen? get bool GetBufferedDraw=2034(,) # If drawing is buffered then each line of text is drawn into a bitmap buffer # before drawing it to the screen to avoid flicker. set void SetBufferedDraw=2035(bool buffered,) -# Change the visible size of a tab to be a multiple of the width of a space -# character. +# Change the visible size of a tab to be a multiple of the width of a space character. set void SetTabWidth=2036(int tabWidth,) # Retrieve the visible size of a tab. @@ -227,7 +225,7 @@ val SC_CP_UTF8=65001 # The SC_CP_UTF8 value can be used to enter Unicode mode. set void SetCodePage=2037(int codePage,) -# In palette mode, Scintilla uses the environments palette calls to display +# In palette mode, Scintilla uses the environment's palette calls to display # more colours. This may lead to ugly displays. set void SetUsePalette=2039(bool usePalette,) @@ -243,7 +241,7 @@ val SC_MARK_ARROWDOWN=6 val SC_MARK_MINUS=7 val SC_MARK_PLUS=8 -# Shapes used for outlining column +# Shapes used for outlining column. val SC_MARK_VLINE=9 val SC_MARK_LCORNER=10 val SC_MARK_TCORNER=11 @@ -258,13 +256,13 @@ val SC_MARK_CIRCLEPLUSCONNECTED=19 val SC_MARK_CIRCLEMINUS=20 val SC_MARK_CIRCLEMINUSCONNECTED=21 -# Invisible mark that only sets the line background color +# Invisible mark that only sets the line background color. val SC_MARK_BACKGROUND=22 val SC_MARK_CHARACTER=10000 enu MarkerOutline=SC_MARKNUM_ -# Markers used for outlining column +# Markers used for outlining column. val SC_MARKNUM_FOLDEREND=25 val SC_MARKNUM_FOLDEROPENMID=26 val SC_MARKNUM_FOLDERMIDTAIL=27 @@ -287,10 +285,10 @@ fun void MarkerSetBack=2042(int markerNumber, colour back) # Add a marker to a line, returning an ID which can be used to find or delete the marker. fun int MarkerAdd=2043(int line, int markerNumber) -# Delete a marker from a line +# Delete a marker from a line. fun void MarkerDelete=2044(int line, int markerNumber) -# Delete all markers with a particular number from all lines +# Delete all markers with a particular number from all lines. fun void MarkerDeleteAll=2045(int markerNumber,) # Get a bit mask of all the markers set on a line. @@ -435,8 +433,7 @@ get int GetCaretPeriod=2075(,) # Get the time in milliseconds that the caret is on and off. 0 = steady on. set void SetCaretPeriod=2076(int periodMilliseconds,) -# Set the set of characters making up words for when moving or selecting -# by word. +# Set the set of characters making up words for when moving or selecting by word. set void SetWordChars=2077(, string characters) # Start a sequence of actions that is undone and redone as a unit. @@ -470,8 +467,8 @@ set void IndicSetFore=2082(int indic, colour fore) # Retrieve the foreground colour of an indicator. get colour IndicGetFore=2083(int indic,) -# Divide each styling byte into lexical class bits (default:5) and indicator -# bits (default:3). If a lexer requires more than 32 lexical states, then this +# Divide each styling byte into lexical class bits (default: 5) and indicator +# bits (default: 3). If a lexer requires more than 32 lexical states, then this # is used to expand the possible states. set void SetStyleBits=2090(int bits,) @@ -490,7 +487,7 @@ get int GetMaxLineState=2094(,) # Is the background of the line containing the caret in a different colour? get bool GetCaretLineVisible=2095(,) -# Dsplay the background of the line containing the caret in a different colour. +# Display the background of the line containing the caret in a different colour. set void SetCaretLineVisible=2096(bool show,) # Get the colour of the background of the line containing the caret. @@ -514,8 +511,7 @@ fun void AutoCCancel=2101(,) # Is there an auto-completion list visible? fun bool AutoCActive=2102(,) -# Retrieve the position of the caret when the auto-completion list was -# displayed. +# Retrieve the position of the caret when the auto-completion list was displayed. fun position AutoCPosStart=2103(,) # User has selected an item so remove the list and insert the selection. @@ -524,8 +520,8 @@ fun void AutoCComplete=2104(,) # Define a set of character that when typed cancel the auto-completion list. fun void AutoCStops=2105(, string characterSet) -# Change the separator character in the string setting up an auto-completion -# list. Default is space but can be changed if items contain space. +# Change the separator character in the string setting up an auto-completion list. +# Default is space but can be changed if items contain space. set void AutoCSetSeparator=2106(int separatorCharacter,) # Retrieve the auto-completion list separator character. @@ -541,7 +537,7 @@ set void AutoCSetCancelAtStart=2110(bool cancel,) # Retrieve whether auto-completion cancelled by backspacing before start. get bool AutoCGetCancelAtStart=2111(,) -# Define a set of characters that when typed will cause the autocompletion to +# Define a set of characters that when typed will cause the autocompletion to # choose the selected item. set void AutoCSetFillUps=2112(, string characterSet) @@ -560,16 +556,18 @@ get bool AutoCGetIgnoreCase=2116(,) # Display a list of strings and send notification when user chooses one. fun void UserListShow=2117(int listType, string itemList) -# Set whether or not autocompletion is hidden automatically when nothing matches +# Set whether or not autocompletion is hidden automatically when nothing matches. set void AutoCSetAutoHide=2118(bool autoHide,) -# Retrieve whether or not autocompletion is hidden automatically when nothing matches +# Retrieve whether or not autocompletion is hidden automatically when nothing matches. get bool AutoCGetAutoHide=2119(,) -# Set whether or not autocompletion deletes any word characters after the inserted text upon completion +# Set whether or not autocompletion deletes any word characters +# after the inserted text upon completion. set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,) -# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion +# Retrieve whether or not autocompletion deletes any word characters +# after the inserted text upon completion. get bool AutoCGetDropRestOfWord=2271(,) # Set the number of spaces used for one level of indentation. @@ -679,7 +677,7 @@ val SCFIND_REGEXP=0x00200000 # Find some text in the document. fun position FindText=2150(int flags, findtext ft) -# On Windows will draw the document into a display context such as a printer. +# On Windows, will draw the document into a display context such as a printer. fun void FormatRange=2151(bool draw, formatrange fr) # Retrieve the line at the top of the display. @@ -751,7 +749,7 @@ fun void Null=2172(,) # Will a paste succeed? fun bool CanPaste=2173(,) -# Are there any undoable actions in the undo history. +# Are there any undoable actions in the undo history? fun bool CanUndo=2174(,) # Delete the undo history. @@ -798,7 +796,7 @@ get bool GetOvertype=2187(,) # Set the width of the insert mode caret. set void SetCaretWidth=2188(int pixelWidth,) -# Returns the width of the insert mode caret +# Returns the width of the insert mode caret. get int GetCaretWidth=2189(,) # Sets the position that starts the target which is used for updating the @@ -833,10 +831,10 @@ fun int ReplaceTargetRE=2195(int length, string text) # Returns length of range or -1 for failure in which case target is not moved. fun int SearchInTarget=2197(int length, string text) -# Set the search flags used by SearchInTarget +# Set the search flags used by SearchInTarget. set void SetSearchFlags=2198(int flags,) -# Get the search flags used by SearchInTarget +# Get the search flags used by SearchInTarget. get int GetSearchFlags=2199(,) # Show a call tip containing a definition near position pos. @@ -904,20 +902,20 @@ fun void ToggleFold=2231(int line,) # Ensure a particular line is visible by expanding any header line hiding it. fun void EnsureVisible=2232(int line,) -# Set some debugging options for folding +# Set some debugging options for folding. fun void SetFoldFlags=2233(int flags,) # Ensure a particular line is visible by expanding any header line hiding it. # Use the currently set visibility policy to determine which range to display. fun void EnsureVisibleEnforcePolicy=2234(int line,) -# Sets whether a tab pressed when caret is within indentation indents +# Sets whether a tab pressed when caret is within indentation indents. set void SetTabIndents=2260(bool tabIndents,) # Does a tab pressed when caret is within indentation indent? get bool GetTabIndents=2261(,) -# Sets whether a backspace pressed when caret is within indentation unindents +# Sets whether a backspace pressed when caret is within indentation unindents. set void SetBackSpaceUnIndents=2262(bool bsUnIndents,) # Does a backspace pressed when caret is within indentation unindent? @@ -966,20 +964,20 @@ set void SetScrollWidth=2274(int pixelWidth,) get int GetScrollWidth=2275(,) # Measure the pixel width of some text in a particular style. -# Nul terminated text argument. +# Nul terminated text argument. # Does not handle tab or control characters. fun int TextWidth=2276(int style, string text) -# Sets the scroll range so that maximum scroll position has -# the last line at the bottom of the view (default). +# Sets the scroll range so that maximum scroll position has +# the last line at the bottom of the view (default). # Setting this to false allows scrolling one page below the last line. set void SetEndAtLastLine=2277(bool endAtLastLine,) -# Retrieve whether the maximum scroll position has the last -# line at the bottom of the view. +# Retrieve whether the maximum scroll position has the last +# line at the bottom of the view. get int GetEndAtLastLine=2278(,) -# Retrieve the height of a particular line of text in pixels. +# Retrieve the height of a particular line of text in pixels. fun int TextHeight=2279(int line,) ## Start of key messages @@ -1064,8 +1062,7 @@ fun void Cancel=2325(,) # Delete the selection or if no selection, the character before the caret. fun void DeleteBack=2326(,) -# If selection is empty or all on one line replace the selection with a tab -# character. +# If selection is empty or all on one line replace the selection with a tab character. # If more than one line selected, indent the lines. fun void Tab=2327(,) @@ -1119,17 +1116,17 @@ fun void LineScrollDown=2342(,) fun void LineScrollUp=2343(,) # Delete the selection or if no selection, the character before the caret. -# Will not delete the chraacter before at the start of a line. +# Will not delete the character before at the start of a line. fun void DeleteBackNotLine=2344(,) -# Move the caret inside current view if it's not there already +# Move the caret inside current view if it's not there already. fun void MoveCaretInsideView=2401(,) -# How many characters are on a line, not including end of line characters. +# How many characters are on a line, not including end of line characters? fun int LineLength=2350(int line,) # Highlight the characters at two positions. -fun void BraceHighlight=2351(position pos1,position pos2) +fun void BraceHighlight=2351(position pos1, position pos2) # Highlight the character at a position indicating there is no matching brace. fun void BraceBadLight=2352(position pos,) @@ -1137,10 +1134,10 @@ fun void BraceBadLight=2352(position pos,) # Find the position of a matching brace or INVALID_POSITION if no match. fun position BraceMatch=2353(position pos,) -# Are the end of line characters visible. +# Are the end of line characters visible? get bool GetViewEOL=2355(,) -# Make the end of line characters visible or invisible +# Make the end of line characters visible or invisible. set void SetViewEOL=2356(bool visible,) # Retrieve a pointer to the document object. @@ -1188,24 +1185,6 @@ fun int SearchNext=2367(int flags, string text) # Does not ensure the selection is visible. fun int SearchPrev=2368(int flags, string text) -# Show caret within N lines of edge when it's scrolled to view -# If CARET_SLOP not set then centre caret on screen when it's -# scrolled to view -val CARET_SLOP=0x01 -# Value not used -val CARET_CENTER=0x02 -# If CARET_SLOP also set then reposition whenever outside slop border -# If CARET_SLOP not set then recentre even when visible -val CARET_STRICT=0x04 -# If CARET_XEVEN set then both left and right margins are given equal weight -# rather than favouring left following behaviour. -val CARET_XEVEN=0x08 -# If CARET_XJUMPS set then when caret reaches the margin the display jumps -# enough to leave the caret solidly within the display. -val CARET_XJUMPS=0x10 -# Set the way the line the caret is on is kept visible. -fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop) - # Retrieves the number of lines completely visible. get int LinesOnScreen=2370(,) @@ -1213,7 +1192,7 @@ get int LinesOnScreen=2370(,) # the wrong mouse button. fun void UsePopUp=2371(bool allowPopUp,) -# Is the selection a rectangular. The alternative is the more common stream selection. +# Is the selection rectangular? The alternative is the more common stream selection. get bool SelectionIsRectangle=2372(,) # Set the zoom level. This number of points is added to the size of all fonts. @@ -1233,64 +1212,99 @@ fun void ReleaseDocument=2377(, int doc) # Get which document modification events are sent to the container. get int GetModEventMask=2378(,) -# Change internal focus flag +# Change internal focus flag. set void SetFocus=2380(bool focus,) -# Get internal focus flag +# Get internal focus flag. get bool GetFocus=2381(,) -# Change error status - 0 = OK +# Change error status - 0 = OK. set void SetStatus=2382(int statusCode,) -# Get error status +# Get error status. get int GetStatus=2383(,) -# Set whether the mouse is captured when its button is pressed +# Set whether the mouse is captured when its button is pressed. set void SetMouseDownCaptures=2384(bool captures,) -# Get whether mouse gets captured +# Get whether mouse gets captured. get bool GetMouseDownCaptures=2385(,) enu CursorShape=SC_CURSOR val SC_CURSORNORMAL=-1 val SC_CURSORWAIT=3 -# Sets the cursor to one of the SC_CURSOR* values +# Sets the cursor to one of the SC_CURSOR* values. set void SetCursor=2386(int cursorType,) -# Get cursor type +# Get cursor type. get int GetCursor=2387(,) # Change the way control characters are displayed: -# If symbol is < 32, keep the drawn way, else, use the given character +# If symbol is < 32, keep the drawn way, else, use the given character. set void SetControlCharSymbol=2388(int symbol,) -# Get the way control characters are displayed +# Get the way control characters are displayed. get int GetControlCharSymbol=2389(,) -# Move to the previous change in capitalistion +# Move to the previous change in capitalisation. fun void WordPartLeft=2390(,) -# Move to the previous change in capitalistion extending selection to new caret position. +# Move to the previous change in capitalisation extending selection +# to new caret position. fun void WordPartLeftExtend=2391(,) -# Move to the change next in capitalistion +# Move to the change next in capitalisation. fun void WordPartRight=2392(,) -# Move to the next change in capitalistion extending selection to new caret position. +# Move to the next change in capitalisation extending selection +# to new caret position. fun void WordPartRightExtend=2393(,) -# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy +# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy. val VISIBLE_SLOP=0x01 val VISIBLE_STRICT=0x04 -# Set the way the display area is determined when a particular line is to be moved to. +# Set the way the display area is determined when a particular line +# is to be moved to by Find, FindNext, GotoLine, etc. fun void SetVisiblePolicy=2394(int visiblePolicy, int visibleSlop) -# Delete back from the current position to the start of the line +# Delete back from the current position to the start of the line. fun void DelLineLeft=2395(,) -# Delete forwards from the current position to the end of the line +# Delete forwards from the current position to the end of the line. fun void DelLineRight=2396(,) -# Get and Set the xOffset (ie, horizonal scroll position) +# Get and Set the xOffset (ie, horizonal scroll position). set void SetXOffset=2397(int newOffset,) get int GetXOffset=2398(,) # Set the focus to this Scintilla widget. -# GTK+ Specific +# GTK+ Specific. fun void GrabFocus=2400(,) +enu CaretPolicy = CARET_ +# Caret policy, used by SetXCaretPolicy and SetYCaretPolicy. +# If CARET_SLOP is set, we can define a slop value: caretSlop. +# This value defines an unwanted zone (UZ) where the caret is... unwanted. +# This zone is defined as a number of pixels near the vertical margins, +# and as a number of lines near the horizontal margins. +# By keeping the caret away from the edges, it is seen within its context, +# so it is likely that the identifier that the caret is on can be completely seen, +# and that the current line is seen with some of the lines following it which are +# often dependent on that line. +val CARET_SLOP=0x01 +# If CARET_STRICT is set, the policy is enforced... strictly. +# The caret is centred on the display if slop is not set, +# and cannot go in the UZ if slop is set. +val CARET_STRICT=0x04 +# If CARET_JUMPS is set, the display is moved more energetically +# so the caret can move in the same direction longer before the policy is applied again. +val CARET_JUMPS=0x10 +# If CARET_EVEN is not set, instead of having symmetrical UZs, +# the left and bottom UZs are extended up to right and top UZs respectively. +# This way, we favour the displaying of useful information: the begining of lines, +# where most code reside, and the lines after the caret, eg. the body of a function. +val CARET_EVEN=0x08 + +# Set the way the caret is kept visible when going sideway. +# The exclusion zone is given in pixels. +fun void SetXCaretPolicy=2402(int caretPolicy, int caretSlop) + +# Set the way the line the caret is on is kept visible. +# The exclusion zone is given in lines. +fun void SetYCaretPolicy=2403(int caretPolicy, int caretSlop) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) @@ -1316,7 +1330,7 @@ set void SetKeyWords=4005(int keywordSet, string keyWords) set void SetLexerLanguage=4006(, string language) # Notifications -# Type of modification and the action which caused the modification +# Type of modification and the action which caused the modification. # These are defined as a bit mask to make it easy to specify which notifications are wanted. # One bit is set from each of SC_MOD_* and SC_PERFORMED_*. enu ModificationFlags=SC_MOD_ SC_PERFORMED_ SC_LAST @@ -1341,9 +1355,9 @@ val SCEN_CHANGE=768 val SCEN_SETFOCUS=512 val SCEN_KILLFOCUS=256 -# Symbolic key codes and modifier flags -# ASCII and other printable characters below 256 -# Extended keys above 300 +# Symbolic key codes and modifier flags. +# ASCII and other printable characters below 256. +# Extended keys above 300. enu Keys=SCK_ val SCK_DOWN=300 @@ -1818,6 +1832,13 @@ evt void Zoom=2018(void) cat Deprecated +# CARET_POLICY changed in 1.47 +fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop) +val CARET_CENTER=0x02 +val CARET_XEVEN=0x08 +val CARET_XJUMPS=0x10 + # The old name for SCN_UPDATEUI val SCN_CHECKBRACE=2007 evt void PosChanged=2012(int position) + diff --git a/src/Editor.cxx b/src/Editor.cxx index cc7b1b40d..11f7a161b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -93,7 +93,7 @@ void LineLayout::SetLineStart(int line, int start) { if ((line >= lenLineStarts) && (line != 0)) { int newMaxLines = line + 20; int *newLineStarts = new int[newMaxLines]; - if (!newLineStarts) + if (!newLineStarts) return; for (int i=0; i<newMaxLines; i++) { if (i < lenLineStarts) @@ -108,7 +108,7 @@ void LineLayout::SetLineStart(int line, int start) { lineStarts[line] = start; } -void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], +void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], char bracesMatchStyle, int xHighlight) { if (rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; @@ -146,8 +146,8 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) { xHighlightGuide = 0; } -LineLayoutCache::LineLayoutCache() : - level(0), length(0), size(0), cache(0), +LineLayoutCache::LineLayoutCache() : + level(0), length(0), size(0), cache(0), allInvalidated(false), styleClock(-1) { Allocate(0); } @@ -224,7 +224,7 @@ void LineLayoutCache::SetLevel(int level_) { } } -LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, +LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, int linesOnScreen, int linesInDoc) { AllocateForLevel(linesOnScreen, linesInDoc); if (styleClock != styleClock_) { @@ -317,11 +317,11 @@ Editor::Editor() { xEndSelect = 0; primarySelection = true; - caretPolicy = CARET_SLOP; - caretSlop = 0; + caretXPolicy = CARET_SLOP | CARET_EVEN; + caretXSlop = 50; - visiblePolicy = VISIBLE_SLOP; - visibleSlop = 0; + caretYPolicy = CARET_EVEN; + caretYSlop = 0; searchAnchor = 0; @@ -621,8 +621,10 @@ int Editor::PositionFromLocationClose(Point pt) { return INVALID_POSITION; } -// Find the document position corresponding to an x coordinate on a particular document line. -// Ensure is between whole characters when document is in multi-byte or UTF-8 mode. +/** + * Find the document position corresponding to an x coordinate on a particular document line. + * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. + */ int Editor::PositionFromLineX(int lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) @@ -930,76 +932,263 @@ int Editor::DisplayFromPosition(int pos) { return lineDisplay; } +/** + * Ensure the caret is reasonably visible in context. + * +Caret policy in SciTE + +If slop is set, we can define a slop value. +This value defines an unwanted zone (UZ) where the caret is... unwanted. +This zone is defined as a number of pixels near the vertical margins, +and as a number of lines near the horizontal margins. +By keeping the caret away from the edges, it is seen within its context, +so it is likely that the identifier that the caret is on can be completely seen, +and that the current line is seen with some of the lines following it which are +often dependent on that line. + +If strict is set, the policy is enforced... strictly. +The caret is centred on the display if slop is not set, +and cannot go in the UZ if slop is set. + +If jumps is set, the display is moved more energetically +so the caret can move in the same direction longer before the policy is applied again. +'3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin. + +If even is not set, instead of having symmetrical UZs, +the left and bottom UZs are extended up to right and top UZs respectively. +This way, we favour the displaying of useful information: the begining of lines, +where most code reside, and the lines after the caret, eg. the body of a function. + + | | | | | +slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of + | | | | | visibility or going into the UZ) display is... +-----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- + 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right + 0 | 0 | 0 | 1 | Yes | moved by one position + 0 | 0 | 1 | 0 | Yes | moved to put caret on top/on right + 0 | 0 | 1 | 1 | Yes | centred on the caret + 0 | 1 | - | 0 | Caret is always on top/on right of display | - + 0 | 1 | - | 1 | No, caret is always centred | - + 1 | 0 | 0 | 0 | Yes | moved to put caret out of the asymmetrical UZ + 1 | 0 | 0 | 1 | Yes | moved to put caret out of the UZ + 1 | 0 | 1 | 0 | Yes | moved to put caret at 3UZ of the top or right margin + 1 | 0 | 1 | 1 | Yes | moved to put caret at 3UZ of the margin + 1 | 1 | - | 0 | Caret is always at UZ of top/right margin | - + 1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position + 1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin +*/ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { //Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " "); PRectangle rcClient = GetTextRectangle(); //int rcClientFullWidth = rcClient.Width(); int posCaret = currentPos; - if (posDrag >= 0) + if (posDrag >= 0) { posCaret = posDrag; + } Point pt = LocationFromPosition(posCaret); - Point ptEOL = LocationFromPosition(pdoc->LineEndPosition(posCaret)); Point ptBottomCaret = pt; - int lineCaret = DisplayFromPosition(posCaret); ptBottomCaret.y += vs.lineHeight - 1; - - // Ensure the caret is reasonably visible in context: - // xMargin must equal to xCaretMargin, with a minimum of 2 and a maximum of - // slightly less than half the width of the text area. - int xMargin = Platform::Clamp(xCaretMargin, 2, Platform::Maximum(rcClient.Width() - 10, 4) / 2); - if (!useMargin) - xMargin = 2; - - // If we scroll the display, we use a minimum amount of xMargin. - int offsetLeft = rcClient.left + xMargin; - int offsetRight = rcClient.right - xMargin; - // If we are in XJUMPS mode, then when the margin is reached, the - // offset jumps so that it won't need to move agin for a while. - if (!(caretPolicy & CARET_XJUMPS)) { - rcClient.left = offsetLeft; - rcClient.right = offsetRight; - } + int lineCaret = DisplayFromPosition(posCaret); + bool bSlop, bStrict, bJump, bEven; // Vertical positioning - if (vert && (!rcClient.Contains(pt) || !rcClient.Contains(ptBottomCaret) || (caretPolicy & CARET_STRICT))) { - //Platform::DebugPrintf("EnsureCaretVisible move, (%d,%d)(%d,%d)\n", pt.x, pt.y, rcClient.left, rcClient.right); + if (vert && (pt.y < rcClient.top || ptBottomCaret.y > rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { + int linesOnScreen = LinesOnScreen(); + int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; + int newTopLine = topLine; + bSlop = (caretYPolicy & CARET_SLOP) != 0; + bStrict = (caretYPolicy & CARET_STRICT) != 0; + bJump = (caretYPolicy & CARET_JUMPS) != 0; + bEven = (caretYPolicy & CARET_EVEN) != 0; + // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ - if (caretPolicy & CARET_SLOP) { - if ((topLine > lineCaret) || ((caretPolicy & CARET_STRICT) && (topLine + caretSlop > lineCaret))) { - SetTopLine(Platform::Clamp(lineCaret - caretSlop, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); - } else if ((lineCaret > topLine + LinesOnScreen() - 1) || - ((caretPolicy & CARET_STRICT) && (lineCaret > topLine + LinesOnScreen() - 1 - caretSlop))) { - SetTopLine(Platform::Clamp(lineCaret - LinesOnScreen() + 1 + caretSlop, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); + if (bSlop) { // A margin is defined + int yMoveT, yMoveB; + if (bStrict) { + int yMarginT, yMarginB; + if (!useMargin) { + // In drag mode, avoid moves + // otherwise, a double click will select several lines. + yMarginT = yMarginB = 0; + } else { + // yMarginT must equal to caretYSlop, with a minimum of 1 and + // a maximum of slightly less than half the heigth of the text area. + yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen); + if (bEven) { + yMarginB = yMarginT; + } else { + yMarginB = linesOnScreen - yMarginT - 1; + } + } + if (bJump) { + yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); + } + yMoveT = yMarginT; + if (bEven) { + if (bJump) { + yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); + } + yMoveB = yMoveT; + } else { + yMoveB = linesOnScreen - yMoveT - 1; + } + if (lineCaret < topLine + yMarginT) { + // Caret goes too high + newTopLine = lineCaret - yMoveT; + } else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) { + // Caret goes too low + newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; + } + } else { // Not strict + yMoveT = bJump ? caretYSlop * 3 : caretYSlop; + yMoveT = Platform::Clamp(yMoveT, 1, halfScreen); + if (bEven) { + yMoveB = yMoveT; + } else { + yMoveB = linesOnScreen - yMoveT - 1; + } + if (lineCaret < topLine) { + // Caret goes too high + newTopLine = lineCaret - yMoveT; + } else if (lineCaret > topLine + linesOnScreen - 1) { + // Caret goes too low + newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; + } } - } else { - if ((topLine > lineCaret) || (lineCaret > topLine + LinesOnScreen() - 1) || (caretPolicy & CARET_STRICT)) { - SetTopLine(Platform::Clamp(lineCaret - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); - SetVerticalScrollPos(); - Redraw(); + } else { // No slop + if (!bStrict && !bJump) { + // Minimal move + if (lineCaret < topLine) { + // Caret goes too high + newTopLine = lineCaret; + } else if (lineCaret > topLine + linesOnScreen - 1) { + // Caret goes too low + if (bEven) { + newTopLine = lineCaret - linesOnScreen + 1; + } else { + newTopLine = lineCaret; + } + } + } else { // Strict or going out of display + if (bEven) { + // Always center caret + newTopLine = lineCaret - halfScreen; + } else { + // Always put caret on top of display + newTopLine = lineCaret; + } } } + newTopLine = Platform::Clamp(newTopLine, 0, MaxScrollPos()); + if (newTopLine != topLine) { + SetTopLine(newTopLine); + SetVerticalScrollPos(); + Redraw(); + } } // Horizontal positioning if (horiz && (wrapState == eWrapNone)) { + int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; int xOffsetNew = xOffset; - if (pt.x < rcClient.left) { - xOffsetNew = xOffset - (offsetLeft - pt.x); - } else if ((!(caretPolicy & CARET_XEVEN) && ((xOffset > 0) && useMargin)) || pt.x >= rcClient.right) { - xOffsetNew = xOffset + (pt.x - offsetRight); - int xOffsetEOL = xOffset + (ptEOL.x - offsetRight) - xMargin + 2; - //Platform::DebugPrintf("Margin %d %d\n", xOffsetNew, xOffsetEOL); - // Ensure don't scroll out into empty space - if (xOffsetNew > xOffsetEOL) - xOffsetNew = xOffsetEOL; - } - if (xOffsetNew < 0) + bSlop = (caretXPolicy & CARET_SLOP) != 0; + bStrict = (caretXPolicy & CARET_STRICT) != 0; + bJump = (caretXPolicy & CARET_JUMPS) != 0; + bEven = (caretXPolicy & CARET_EVEN) != 0; + + if (bSlop) { // A margin is defined + int xMoveL, xMoveR; + if (bStrict) { + int xMarginL, xMarginR; + if (!useMargin) { + // In drag mode, avoid moves unless very near of the margin + // otherwise, a simple click will select text. + xMarginL = xMarginR = 2; + } else { + // xMargin must equal to caretXSlop, with a minimum of 2 and + // a maximum of slightly less than half the width of the text area. + xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen); + if (bEven) { + xMarginL = xMarginR; + } else { + xMarginL = rcClient.Width() - xMarginR - 4; + } + } + if (bJump && bEven) { + // Jump is used only in even mode + xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen); + } else { + xMoveL = xMoveR = 0; // Not used, avoid a warning + } + if (pt.x < rcClient.left + xMarginL) { + // Caret is on the left of the display + if (bJump && bEven) { + xOffsetNew -= xMoveL; + } else { + // Move just enough to allow to display the caret + xOffsetNew -= (rcClient.left + xMarginL) - pt.x; + } + } else if (pt.x >= rcClient.right - xMarginR) { + // Caret is on the right of the display + if (bJump && bEven) { + xOffsetNew += xMoveR; + } else { + // Move just enough to allow to display the caret + xOffsetNew += pt.x - (rcClient.right - xMarginR) + 1; + } + } + } else { // Not strict + xMoveR = bJump ? caretXSlop * 3 : caretXSlop; + xMoveR = Platform::Clamp(xMoveR, 1, halfScreen); + if (bEven) { + xMoveL = xMoveR; + } else { + xMoveL = rcClient.Width() - xMoveR - 4; + } + if (pt.x < rcClient.left) { + // Caret is on the left of the display + xOffsetNew -= xMoveL; + } else if (pt.x >= rcClient.right) { + // Caret is on the right of the display + xOffsetNew += xMoveR; + } + } + } else { // No slop + if (bStrict || + (bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) { + // Strict or going out of display + if (bEven) { + // Center caret + xOffsetNew += pt.x - rcClient.left - halfScreen; + } else { + // Put caret on right + xOffsetNew += pt.x - rcClient.right + 1; + } + } else { + // Move just enough to allow to display the caret + if (pt.x < rcClient.left) { + // Caret is on the left of the display + if (bEven) { + xOffsetNew -= rcClient.left - pt.x; + } else { + xOffsetNew += pt.x - rcClient.right + 1; + } + } else if (pt.x >= rcClient.right) { + // Caret is on the right of the display + xOffsetNew += pt.x - rcClient.right + 1; + } + } + } + // In case of a jump (find result) largely out of display, adjust the offset to display the caret + if (pt.x + xOffset < rcClient.left + xOffsetNew) { + xOffsetNew = pt.x + xOffset - rcClient.left; + } else if (pt.x + xOffset >= rcClient.right + xOffsetNew) { + xOffsetNew = pt.x + xOffset - rcClient.right + 1; + } + if (xOffsetNew < 0) { xOffsetNew = 0; + } if (xOffset != xOffsetNew) { xOffset = xOffsetNew; SetHorizontalScrollPos(); @@ -1316,7 +1505,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { int posLineStart = pdoc->LineStart(lineNumber); int posLineEnd = pdoc->LineStart(lineNumber + 1); int lineCaret = pdoc->LineFromPosition(currentPos); - return llc.Retrieve(lineNumber, lineCaret, + return llc.Retrieve(lineNumber, lineCaret, posLineEnd - posLineStart, pdoc->GetStyleClock(), LinesOnScreen() + 1, pdoc->LinesTotal()); } @@ -1342,7 +1531,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } else { ll->edgeColumn = -1; } - + int posLineEnd = pdoc->LineStart(line + 1); Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font; char styleByte = 0; @@ -1371,7 +1560,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character ll->styles[numCharsInLine] = styleByte; // For eolFilled ll->indicators[numCharsInLine] = 0; - + // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. int startseg = 0; // Start of the current segment, in char. number @@ -1379,7 +1568,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->positions[0] = 0; unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars; bool lastSegItalics = false; - + for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) { if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) || IsControlCharacter(ll->chars[charInLine]) || IsControlCharacter(ll->chars[charInLine + 1])) { @@ -1840,7 +2029,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Abandoning paint\n"); if (wrapState != eWrapNone) { if (paintAbandonedByStyling) { - // Styling has spilled over a line end, such as occurs by starting a multiline + // Styling has spilled over a line end, such as occurs by starting a multiline // comment. The width of subsequent text may have changed, so rewrap. NeedWrapping(cs.DocFromDisplay(topLine)); } @@ -1908,7 +2097,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll->selEnd = -1; ll->containsCaret = false; } - + PRectangle rcLine = rcClient; rcLine.top = ypos; rcLine.bottom = ypos + vs.lineHeight; @@ -1917,11 +2106,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle), highlightGuideColumn * vs.spaceWidth); - + // Draw the line DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); //durPaint += et.Duration(true); - + // Restore the precvious styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, braces); @@ -1940,7 +2129,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } } - + // Draw the Caret if (lineDoc == lineCaret) { int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength); @@ -1979,7 +2168,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } } } - + if (bufferedDraw) { Point from(vs.fixedColumnWidth, 0); PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen, @@ -1988,7 +2177,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } //durCopy += et.Duration(true); } - + if (!bufferedDraw) { ypos += vs.lineHeight; } @@ -2016,7 +2205,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } } //Platform::DebugPrintf( - //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", + //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration()); NotifyPainted(); } @@ -2249,7 +2438,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { SetLastXChosen(); if (treatAsDBCS) { - NotifyChar((static_cast<unsigned char>(s[0]) << 8) | + NotifyChar((static_cast<unsigned char>(s[0]) << 8) | static_cast<unsigned char>(s[1])); } else { int byte = static_cast<unsigned char>(s[0]); @@ -2905,7 +3094,7 @@ void Editor::CursorUpOrDown(int direction, bool extend) { if (direction < 0) { // Line wrapping may lead to a location on the same line, so // seek back if that is the case. - // There is an equivalent case when moving down which skips + // There is an equivalent case when moving down which skips // over a line but as that does not trap the user it is fine. Point ptNew = LocationFromPosition(posNew); while ((posNew > 0) && (pt.y == ptNew.y)) { @@ -3789,7 +3978,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { if (drag.len) { if (ctrl) { if (pdoc->InsertString(newPos, drag.s, drag.len)) { - SetSelection(newPos, newPos + drag.len); + SetSelection(newPos, newPos + drag.len); } } else if (newPos < selStart) { pdoc->DeleteChars(selStart, drag.len); @@ -4178,6 +4367,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CLEAR: Clear(); SetLastXChosen(); + EnsureCaretVisible(); break; case SCI_UNDO: @@ -5086,9 +5276,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SEARCHPREV: return SearchText(iMessage, wParam, lParam); - case SCI_SETCARETPOLICY: - caretPolicy = wParam; - caretSlop = lParam; + case SCI_SETCARETPOLICY: // Deprecated + caretXPolicy = caretYPolicy = wParam; + caretXSlop = caretYSlop = lParam; + break; + + case SCI_SETXCARETPOLICY: + caretXPolicy = wParam; + caretXSlop = lParam; + break; + + case SCI_SETYCARETPOLICY: + caretYPolicy = wParam; + caretYSlop = lParam; break; case SCI_SETVISIBLEPOLICY: diff --git a/src/Editor.h b/src/Editor.h index 9eba943a6..724775342 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -77,7 +77,7 @@ public: } } void SetLineStart(int line, int start); - void SetBracesHighlight(Range rangeLine, Position braces[], + void SetBracesHighlight(Range rangeLine, Position braces[], char bracesMatchStyle, int xHighlight); void RestoreBracesHighlight(Range rangeLine, Position braces[]); }; @@ -97,16 +97,16 @@ public: LineLayoutCache(); virtual ~LineLayoutCache(); void Deallocate(); - enum { - llcNone=SC_CACHE_NONE, - llcCaret=SC_CACHE_CARET, - llcPage=SC_CACHE_PAGE, + enum { + llcNone=SC_CACHE_NONE, + llcCaret=SC_CACHE_CARET, + llcPage=SC_CACHE_PAGE, llcDocument=SC_CACHE_DOCUMENT }; void Invalidate(LineLayout::validLevel validity_); void SetLevel(int level_); int GetLevel() { return level; } - LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, + LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, int linesOnScreen, int linesInDoc); void Dispose(LineLayout *ll); }; @@ -259,8 +259,11 @@ protected: // ScintillaBase subclass needs access to much of Editor int xEndSelect; bool primarySelection; - int caretPolicy; - int caretSlop; + int caretXPolicy; + int caretXSlop; ///< Ensure this many pixels visible on both sides of caret + + int caretYPolicy; + int caretYSlop; ///< Ensure this many lines visible on both sides of caret int visiblePolicy; int visibleSlop; @@ -338,7 +341,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault); void PaintSelMargin(Surface *surface, PRectangle &rc); LineLayout *RetrieveLineLayout(int lineNumber); - void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, + void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width=LineLayout::wrapWidthInfinite); void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine=0); |