diff options
-rw-r--r-- | doc/ScintillaDoc.html | 50 | ||||
-rw-r--r-- | include/Scintilla.h | 3 | ||||
-rw-r--r-- | include/Scintilla.iface | 15 | ||||
-rw-r--r-- | src/Editor.cxx | 39 | ||||
-rw-r--r-- | src/Editor.h | 1 |
5 files changed, 79 insertions, 29 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 3c23df0da..f87743f79 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -787,7 +787,7 @@ struct TextToFind { unless the document is read-only.</p> <p>On X, the clipboard is asynchronous and may require several messages between - the destination and source applications. Data from SCI_PASTE will not arrive in the + the destination and source applications. Data from SCI_PASTE will not arrive in the document immediately.</p> <b id="SCI_COPYRANGE">SCI_COPYRANGE(int start, int end)</b><br /> @@ -2065,6 +2065,9 @@ struct TextToFind { <a class="message" href="#SCI_SETCONTROLCHARSYMBOL">SCI_SETCONTROLCHARSYMBOL(int symbol)</a><br /> <a class="message" href="#SCI_GETCONTROLCHARSYMBOL">SCI_GETCONTROLCHARSYMBOL</a><br /> + <a class="message" href="#SCI_SETCARETSTICKY">SCI_SETCARETSTICKY</a><br /> + <a class="message" href="#SCI_GETCARETSTICKY">SCI_GETCARETSTICKY</a><br /> + <a class="message" href="#SCI_TOGGLECARETSTICKY">SCI_TOGGLECARETSTICKY</a><br /> </code> <p><b id="SCI_SETSELFORE">SCI_SETSELFORE(bool useSelectionForeColour, int <a class="jump" @@ -2134,6 +2137,13 @@ struct TextToFind { You can read back the current symbol with the <code>SCI_GETCONTROLCHARSYMBOL</code> message. The default symbol value is 0.</p> + <p><b id="SCI_SETCARETSTICKY">SCI_SETCARETSTICKY(bool useCaretStickyBehaviour)</b><br /> + <b id="SCI_GETCARETSTICKY">SCI_GETCARETSTICKY</b><br /> + <b id="SCI_TOGGLECARETSTICKY">SCI_TOGGLECARETSTICKY</b><br /> + These messages set, get or toggle the caretSticky flag which controls when the last position + of the caret on the line is saved. When set to true, the position is not saved when you type + a character, a tab, paste the clipboard content or press backspace.</p> + <h2 id="Margins">Margins</h2> <p>There may be up to three margins to the left of the text display, plus a gap either side of @@ -2323,8 +2333,8 @@ struct TextToFind { horizontal space, such as Thai, will mostly work but there are some issues where the characters are drawn separately leading to visual glitches. Bi-directional text is not supported.</p> - <p>On Windows, code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), - 949 (Korean), and 950 (Traditional Chinese Big5) although these may require installation of language + <p>On Windows, code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), + 949 (Korean), and 950 (Traditional Chinese Big5) although these may require installation of language specific support.</p> <p>On GTK+, code page <code>SC_CP_DBCS</code> (1) sets Scintilla into @@ -2888,10 +2898,10 @@ struct TextToFind { <p>When the user makes a selection from the list the container is sent a <code><a class="message" href="#SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</a></code> <a class="jump" - href="#Notifications">notification message</a>. On return from the notification Scintilla will insert + href="#Notifications">notification message</a>. On return from the notification Scintilla will insert the selected text unless the autocompletion list has been cancelled, for example by the container sending <code><a class="message" href="#SCI_AUTOCCANCEL">SCI_AUTOCCANCEL</a></code>.</p> - + <p>To make use of autocompletion you must monitor each character added to the document. See <code>SciTEBase::CharAdded()</code> in SciTEBase.cxx for an example of autocompletion.</p> <code><a class="message" href="#SCI_AUTOCSHOW">SCI_AUTOCSHOW(int lenEntered, const char @@ -3054,7 +3064,7 @@ struct TextToFind { <b id="SCI_AUTOCGETMAXWIDTH">SCI_AUTOCGETMAX</b><br /> Get or set the maximum width of an autocompletion list expressed as the number of characters in the longest item that will be totally visible. - If zero (the default) then the list's width is calculated to fit the item with the most characters. Any items that cannot be fully displayed within + If zero (the default) then the list's width is calculated to fit the item with the most characters. Any items that cannot be fully displayed within the available width are indicated by the presence of ellipsis. </p> @@ -3620,10 +3630,10 @@ struct RangeToFormat { into the print rectangle. If you set <code>SC_WRAP_NONE</code>, each line of text generates one line of output and the line is truncated if it is too long to fit into the print area.<br /> - <code>SC_WRAP_WORD</code> tries to wrap only between words as indicated by - white space or style changes although if a word is longer than a line, it will be wrapped before - the line end. <code>SC_WRAP_CHAR</code> is preferred to - <code>SC_WRAP_WORD</code> for Asian languages where there is no white space + <code>SC_WRAP_WORD</code> tries to wrap only between words as indicated by + white space or style changes although if a word is longer than a line, it will be wrapped before + the line end. <code>SC_WRAP_CHAR</code> is preferred to + <code>SC_WRAP_WORD</code> for Asian languages where there is no white space between words.</p> <h2 id="DirectAccess">Direct access</h2> @@ -3751,7 +3761,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ The best way to see how this is done is to search the SciTE source code for the messages used in this section of the documentation and see how they are used. You will also need to use markers and a folding margin to complete your folding implementation. - The <code>"fold"</code> property should be set to <code>"1"</code> with + The <code>"fold"</code> property should be set to <code>"1"</code> with <code>SCI_SETPROPERTY("fold", "1")</code> to enable folding. </p> <code><a class="message" href="#SCI_VISIBLEFROMDOCLINE">SCI_VISIBLEFROMDOCLINE(int docLine)</a><br /> @@ -3966,13 +3976,13 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <p><b id="SCI_SETWRAPMODE">SCI_SETWRAPMODE(int wrapMode)</b><br /> <b id="SCI_GETWRAPMODE">SCI_GETWRAPMODE</b><br /> - Set wrapMode to <code>SC_WRAP_WORD</code> (1) to enable wrapping - on word boundaries, <code>SC_WRAP_CHAR</code> (2) to enable wrapping - between any characters, and to <code>SC_WRAP_NONE</code> (0) to disable line - wrapping. <code>SC_WRAP_CHAR</code> is preferred to - <code>SC_WRAP_WORD</code> for Asian languages where there is no white space + Set wrapMode to <code>SC_WRAP_WORD</code> (1) to enable wrapping + on word boundaries, <code>SC_WRAP_CHAR</code> (2) to enable wrapping + between any characters, and to <code>SC_WRAP_NONE</code> (0) to disable line + wrapping. <code>SC_WRAP_CHAR</code> is preferred to + <code>SC_WRAP_WORD</code> for Asian languages where there is no white space between words.</p> - + <p><b id="SCI_SETWRAPVISUALFLAGS">SCI_SETWRAPVISUALFLAGS(int wrapVisualFlags)</b><br /> <b id="SCI_GETWRAPVISUALFLAGS">SCI_GETWRAPVISUALFLAGS</b><br /> @@ -4442,7 +4452,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); href="#SCI_SETREADONLY">SCI_SETREADONLY</a></code>.</p> <p><b id="SCN_KEY">SCN_KEY</b><br /> - Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of + Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of some problems with keyboard focus and is not sent by the Windows version. <code>SCNotification.ch</code> holds the key code and <code>SCNotification.modifiers</code> holds the modifiers. This notification is sent if the modifiers include <code>SCMOD_ALT</code> or <code>SCMOD_CTRL</code> and the key code is less @@ -4511,7 +4521,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); <td align="left">Valid for text changes, not for style changes. If we are collecting undo information this holds a pointer to the text that is handed to the Undo system, otherwise - it is zero. For user performed SC_MOD_BEFOREDELETE the text field is 0 and + it is zero. For user performed SC_MOD_BEFOREDELETE the text field is 0 and for user performed SC_MOD_BEFOREINSERT the text field points to an array of cells, not bytes.</td> </tr> @@ -4926,7 +4936,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next <p><b id="SCN_AUTOCSELECTION">SCN_AUTOCSELECTION</b><br /> The user has selected an item in an <a class="jump" href="#Autocompletion">autocompletion list</a>. The - notification is sent before the selection is inserted. Automatic insertion can be cancelled by sending a + notification is sent before the selection is inserted. Automatic insertion can be cancelled by sending a <code><a class="message" href="#SCI_AUTOCCANCEL">SCI_AUTOCCANCEL</a></code> message before returning from the notification. The <code>SCNotification</code> fields used are:</p> diff --git a/include/Scintilla.h b/include/Scintilla.h index 6267496b0..3b4bbb919 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -597,6 +597,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETLENGTHFORENCODE 2448 #define SCI_ENCODEDFROMUTF8 2449 #define SCI_FINDCOLUMN 2456 +#define SCI_GETCARETSTICKY 2457 +#define SCI_SETCARETSTICKY 2458 +#define SCI_TOGGLECARETSTICKY 2459 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index ea72a73ca..761ea4d02 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -607,11 +607,11 @@ get int AutoCGetTypeSeparator=2285(,) # Default is '?' but can be changed if items contain '?'. set void AutoCSetTypeSeparator=2286(int separatorCharacter,) -# Set the maximum width, in characters, of auto-completion and user lists. +# Set the maximum width, in characters, of auto-completion and user lists. # Set to 0 to autosize to fit longest item, which is the default. set void AutoCSetMaxWidth=2208(int characterCount,) -# Get the maximum width, in characters, of auto-completion and user lists. +# Get the maximum width, in characters, of auto-completion and user lists. get int AutoCGetMaxWidth=2209(,) # Set the maximum height, in rows, of auto-completion and user lists. @@ -1613,10 +1613,19 @@ fun void SetLengthForEncode=2448(int bytes,) # On error return 0. fun int EncodedFromUTF8=2449(string utf8, stringresult encoded) -# Find the position of a column on a line taking into account tabs and +# Find the position of a column on a line taking into account tabs and # multi-byte characters. If beyond end of line, return line end position. fun int FindColumn=2456(int line, int column) +# Can the caret preferred x position only be changed by explicit movement commands? +get bool GetCaretSticky=2457(,) + +# Stop the caret preferred x position changing when the user types. +set void SetCaretSticky=2458(bool useCaretStickyBehaviour,) + +# Switch between sticky and non-sticky: meant to be bound to a key. +fun void ToggleCaretSticky=2459(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 5eb384bb2..d9ec00a35 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -344,6 +344,7 @@ Editor::Editor() { scrollWidth = 2000; verticalScrollBarVisible = true; endAtLastLine = true; + caretSticky = false; pixmapLine = Surface::Allocate(); pixmapSelMargin = Surface::Allocate(); @@ -3224,7 +3225,9 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } if (treatAsDBCS) { NotifyChar((static_cast<unsigned char>(s[0]) << 8) | @@ -4253,22 +4256,30 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_DELETEBACK: DelCharBack(true); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } EnsureCaretVisible(); break; case SCI_DELETEBACKNOTLINE: DelCharBack(false); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } EnsureCaretVisible(); break; case SCI_TAB: Indent(true); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } EnsureCaretVisible(); break; case SCI_BACKTAB: Indent(false); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } EnsureCaretVisible(); break; case SCI_NEWLINE: @@ -5647,7 +5658,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_PASTE: Paste(); - SetLastXChosen(); + if (!caretSticky) { + SetLastXChosen(); + } EnsureCaretVisible(); break; @@ -6347,6 +6360,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETENDATLASTLINE: return endAtLastLine; + case SCI_SETCARETSTICKY: + PLATFORM_ASSERT((wParam == 0) || (wParam == 1)); + if (caretSticky != (wParam != 0)) { + caretSticky = wParam != 0; + } + break; + + case SCI_GETCARETSTICKY: + return caretSticky; + + case SCI_TOGGLECARETSTICKY: + caretSticky = !caretSticky; + break; + case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); diff --git a/src/Editor.h b/src/Editor.h index 76e79e7e7..ab80a21c4 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -218,6 +218,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int scrollWidth; bool verticalScrollBarVisible; bool endAtLastLine; + bool caretSticky; Surface *pixmapLine; Surface *pixmapSelMargin; |