|
Scintilla Usage Notes |
The key idea is to use the SCN_CHARADDED notification to add indentation after a newline.
The lParam on the notification is a pointer to a SCNotification structure whose ch member specifies the character added. If a newline was added, the previous line can be retrieved and the same indentation can be added to the new line.
Here is the relevant portion of code from SciTE: (SciTE.cxx SciTEWindow::CharAdded)
if (ch == '\r' || ch == '\n') {Of course, fancier handling could be implemented. For example, if the previous line was the start of a control construct, the next line could be automatically indented one tab further. (Assuming that is your indenting style.)
Syntax styling is handled by the SCN_STYLENEEDED notification. Scintilla keeps track of the end of the styled text - this is retrieved with SCI_GETENDSTYLED. In response to the SCN_STYLENEEDED notification, you should apply styles to the text from ENDSTYLED to the position specified by the notification.
Here is the relevant portion of code from SciTE: (SciTE.cxx)
void SciTEWindow::Notify(SCNotification *notification) {Colourize(start, end) retrieves the specified range of text and then calls ColourizeDoc in keywords.cxx. It starts the process by calling:
SendMessage(hwnd, SCI_STARTSTYLING, startPos, 31);and then for each token of the text, calling:
SendMessage(hwnd, SCI_SETSTYLING, length, style);where style is a number from 0 to 31 whose appearance has been defined using the HTTP/1.1 200 OK Connection: keep-alive Connection: keep-alive Content-Disposition: inline; filename="ScintillaUsage.html" Content-Disposition: inline; filename="ScintillaUsage.html" Content-Length: 23412 Content-Length: 23412 Content-Security-Policy: default-src 'none' Content-Security-Policy: default-src 'none' Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8 Date: Wed, 21 Oct 2026 10:45:13 UTC ETag: "e0ffb0bfc404373771709278a46ab56f4e81f722" ETag: "e0ffb0bfc404373771709278a46ab56f4e81f722" Expires: Sat, 18 Oct 2036 10:45:12 GMT Expires: Sat, 18 Oct 2036 10:45:13 GMT Last-Modified: Wed, 21 Oct 2026 10:45:12 GMT Last-Modified: Wed, 21 Oct 2026 10:45:13 GMT Server: OpenBSD httpd Server: OpenBSD httpd X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff
|
Scintilla Usage Notes |
The key idea is to use the SCN_CHARADDED notification to add indentation after a newline.
The lParam on the notification is a pointer to a SCNotification structure whose ch member specifies the character added. If a newline was added, the previous line can be retrieved and the same indentation can be added to the new line.
Here is the relevant portion of code from SciTE: (SciTE.cxx SciTEWindow::CharAdded)
if (ch == '\r' || ch == '\n') {