In Scintilla, each character is followed by a byte representing the character style. The character byte and the style byte together form a character unit. The 8 bits of the style byte are divided into two parts: character style and character indicator. The character indicator of a piece of text can be set through the SCI_INDICATORFILLRANGE message. By default, the lower 5 bits are the character style and the higher 3 bits are the character indicator. Therefore, there can be 32 character styles. 3 independent character indicators that can be used to indicate syntax errors, deprecated names, bad indentation and other information. You can use the SCI_SETSTYLEBITS message to set character style bits up to 7 bits, and the rest will be assigned to the character indicator.
Position indicates the position of the character or the blank point before the character in Scintilla. The first character's position is 0, the second is 1, and so on. If the document contains nLen characters, the position of the last character is nLen – 1. The cursor exists between two characters and can be positioned before the first character (0) and after the last character (nLen).
When two characters are treated as one character, the cursor cannot exist between the two characters. This situation usually occurs when multi-byte characters such as Chinese or when the line terminator is CRLF. The constant INVALID_POSITION (-1) represents an illegal position.
For performance reasons, all lines of text have the same height: the height of the largest font in the current style.
SCI_GETTEXT, SCI_SETTEXT
1) SCI_GETTEXT(int length, char *text)
Get text:
(1) When text is 0, return the entire document length len + 1;
(2) When length is 0, return 0;
(3) When text is not 0 and length is greater than 0, return length – 1, text is filled with length – 1 characters starting from position 0 and a 0 terminator. If length is greater than the document length, the extra positions will be filled with null characters 0.
unsigned int len = SendMessage(SCI_GETTEXT, 0, 0); char *chText = new char[len]; SendMessage(SCI_GETTEXT, len, (LPARAM)chText); … delete [] chText;
2) SCI_SETTEXT(
Set the document text to text, which is a constant string ending with 0. If text is 0, return FALSE (0), otherwise return TRUE (1).
SCI_SETSAVEPOINT SCI_SETSAVEPOINT
Set the save point, the document status will become unmodified, and TRUE (1) will be returned. The SCI_SETSAVEPOINT message will trigger the SCN_SAVEPOINTREACHED event notification. When the document status changes to modified, the SCN_SAVEPOINTLEFT event notification will be triggered.
SCI_GETLINE
SCI_GETLINE(int line, char *text)
Get the text of the specified line and return the length of the text of the specified line (including the line terminator). The line number line starts from 0. If the line number is greater than the maximum line number, 0 will be returned. When text is 0, the length of the specified line of text is returned directly; when text is not 0, text will be filled with the specified line of text, but the terminator 0 will not be automatically set.
unsigned int len = SendMessage(SCI_GETLINE, 1, 0); char *chText = new char[len + 1]; memset(chText, 0, len + 1);SendMessage(SCI_GETLINE, 1, (LPARAM)chText); …delete [] chText;
SCI_REPLACESEL
SCI_REPLACESEL(
Replace the selected text, text is a constant string ending with 0. When no text is selected, text will be inserted at the current position. After replacement, the cursor will be behind the inserted text and the view will automatically scroll so that the text is visible. When text is 0, return FALSE (0), otherwise return TRUE (1).
SCI_SETREADONLY, SCI_GETREADONLY
1) SCI_SETREADONLY(bool readOnly)
Set the document as read-only and return TRUE (1). When the document is in a read-only state, when the document is modified, the SCN_MODIFYATTEMPTRO event notification will be triggered.
2) SCI_GETREADONLY
Get the read-only status of the document and return TRUE (1) or FALSE (0).
SCI_GETTEXTRANGE
SCI_GETTEXTRANGE(
Get the specified range of text, if tr is 0, return 0, otherwise return the text length (not including 0 terminator), and fills tr.lpstrText with the specified range of text and a 0 terminator. When tr.chrg.cpMax is -1, it means the end of the document. You must ensure that the tr.lpstrText character buffer is large enough ((tr.chrg.cpMax - tr.chrg.cpMin) + 1).
SCI_GETSTYLEDTEXT
SCI_GETSTYLEDTEXT(
Get the specified range of style text, similar to SCI_GETTEXTRANGE, but the required character buffer size is SCI_GETTEXTRANGE 2 times (2 * (tr.chrg.cpMax - tr.chrg.cpMin) + 2). Scintilla will automatically append two zero terminators to the end of tr.lpstrText.
SCI_ALLOCATE
SCI_ALLOCATE(int bytes,
Allocate a buffer large enough to accommodate bytes of the specified size, return TRUE (1). The buffer will be reallocated only if the specified size is greater than the current buffer size, otherwise no processing will be done.
SCI_ADDTEXT
SCI_ADDTEXT(int length, const char *s)
Insert the specified length of the specified text at the current position, s is a constant string ending with 0, return 0. After inserting text, the current position is behind the inserted text, but the view does not automatically scroll to make it visible.
SCI_ADDSTYLEDTEXT
SCI_ADDSTYLEDTEXT(int length, cell *s)
Insert style text at the current position, the processing method is similar to SCI_ADDTEXT, and 0 is returned.
SCI_APPENDTEXT
SCI_APPENDTEXT(int length, const char *s)
Insert text at the end of the document. The processing method is similar to SCI_ADDTEXT, and 0 is returned.
SCI_INSERTTEXT
SCI_INSERTTEXT(int pos, const char *text)
Insert text at the specified position. The processing method is similar to SCI_ADDTEXT and returns 0. When pos is -1, it means inserting at the current position.
SCI_CLEARALL
SCI_CLEARALL
Unless the document is read-only, delete all characters from the document and return 0.
SCI_CLEARDOCUMENTSTYLE
SCI_CLEARDOCUMENTSTYLE
Clear all style information of the document and return 0. This is typically used when the document needs to be restyled.
SCI_GETCHARAT
SCI_GETCHARAT(int position)
Returns the character at the specified position. When position is less than 0 or greater than the end of the document, 0 is returned.
SCI_GETSTYLEAT
SCI_GETSTYLEAT(int position)
Returns the style at the specified position. When position is less than 0 or greater than the end of the document, 0 is returned.
SCI_SETSTYLEBITS, SCI_GETSTYLEBITS
1) SCI_SETSTYLEBITS(int bits)
Set the style bit width in bytes and return TRUE (1). The default is 5 bits, and the maximum can be set to 7 bits. The remaining bits will be used to represent character indicators.
2) SCI_GETSTYLEBITS
Returns the style bit width in bytes.
SCI_TARGETASUTF8 *
SCI_TARGETASUTF8(
Convert the target string to UTF8 encoding format, return the encoded text length, and encode the bytes are filled into s. This message is only available on the GTK+ platform.
SCI_ENCODEDFROMUTF8 *
SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded)
Convert UTF8 format string to document encoding format and return the converted byte length, And fill the converted bytes into encoded. This message is only available on the GTK+ platform.
SCI_SETLENGTHFORENCODE
SCI_SETLENGTHFORENCODE(int bytes)
Set the document encoding length and return 0.
The above is the content of Scintilla User Guide (2) - Full-text search and modification. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!
How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AMPHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.
How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AMIn PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.
PHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AMPHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.
Describe different HTTP caching headers (e.g., Cache-Control, ETag, Last-Modified).Apr 17, 2025 am 12:22 AMKey players in HTTP cache headers include Cache-Control, ETag, and Last-Modified. 1.Cache-Control is used to control caching policies. Example: Cache-Control:max-age=3600,public. 2. ETag verifies resource changes through unique identifiers, example: ETag: "686897696a7c876b7e". 3.Last-Modified indicates the resource's last modification time, example: Last-Modified:Wed,21Oct201507:28:00GMT.
Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1?Apr 17, 2025 am 12:06 AMIn PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.
PHP: An Introduction to the Server-Side Scripting LanguageApr 16, 2025 am 12:18 AMPHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.
PHP and the Web: Exploring its Long-Term ImpactApr 16, 2025 am 12:17 AMPHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.
Why Use PHP? Advantages and Benefits ExplainedApr 16, 2025 am 12:16 AMThe core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment






