Home Backend Development PHP Tutorial Scintilla User Guide (2) - Full text search and modification

Scintilla User Guide (2) - Full text search and modification

Jan 17, 2017 am 10:26 AM

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
Copy after login

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;
Copy after login

2) SCI_SETTEXT(, const char *text)
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
Copy after login

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;
Copy after login

SCI_REPLACESEL

SCI_REPLACESEL(, const char *text)
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(, TextRange *tr)
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(, TextRange *tr)
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(, char *s)
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 (www.php.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to change the personal name in the group on DingTalk_How to modify the personal name in the group on DingTalk How to change the personal name in the group on DingTalk_How to modify the personal name in the group on DingTalk Mar 29, 2024 pm 08:41 PM

1. First open DingTalk. 2. Open the group chat and click the three dots in the upper right corner. 3. Find my nickname in this group. 4. Click to enter to modify and save.

How to Change User Folder Name: Win11 Tutorial How to Change User Folder Name: Win11 Tutorial Jan 09, 2024 am 10:34 AM

Some games will be automatically installed into the user folder and require an English folder. However, many friends do not know how to modify the user folder name in win11. In fact, we only need to modify the user name. Modify the user folder name in win11: The first step is to press the "Win+R" key combination on the keyboard. In the second step, enter "gpedit.msc" and press Enter to open the Group Policy Editor. Step 3: Expand "Security Settings" under "Windows Settings" Step 4: Open "Security Options" in "Local Policies" Step 5: Double-click to open the "Account: Rename System Administrator Account" policy on the right. Step 6: Enter the name of the folder you want to modify below and click "OK" to save. Modify user folder

Can Douyin Blue V change its name? What are the steps to change the name of corporate Douyin Blue V account? Can Douyin Blue V change its name? What are the steps to change the name of corporate Douyin Blue V account? Mar 22, 2024 pm 12:51 PM

Douyin Blue V certification is the official certification of a company or brand on the Douyin platform, which helps enhance brand image and credibility. With the adjustment of corporate development strategy or the update of brand image, the company may want to change the name of Douyin Blue V certification. So, can Douyin Blue V change its name? The answer is yes. This article will introduce in detail the steps to modify the name of the enterprise Douyin Blue V account. 1. Can Douyin Blue V change its name? You can change the name of Douyin Blue V account. According to Douyin’s official regulations, corporate Blue V certified accounts can apply to change their account names after meeting certain conditions. Generally speaking, enterprises need to provide relevant supporting materials, such as business licenses, organization code certificates, etc., to prove the legality and necessity of changing the name. 2. What are the steps to modify the name of corporate Douyin Blue V account?

Guide to modifying win11 window corners to rounded corners Guide to modifying win11 window corners to rounded corners Dec 31, 2023 pm 08:35 PM

After updating the win11 system, many friends found that the win11 interface window adopts a new rounded corner design. But some people don’t like this rounded corner design and want to modify it to the previous interface, but they don’t know how to modify it. Let’s take a look below. How to modify rounded corners in win11 1. The rounded corner design of win11 is a built-in system setting that cannot be modified at present. 2. So if you don’t like using the rounded corner design of win11, you can wait for Microsoft to provide a modification method. 3. If you are really not used to it, you can also choose to return to the previous win10 system. 4. If you don’t know how to roll back, you can check out the tutorials provided on this site. 5. If you cannot go back using the tutorial above, you can still

Win11 power mode modification location and method Win11 power mode modification location and method Dec 30, 2023 pm 05:25 PM

In the win11 system, we can reduce our battery consumption or improve our system performance by modifying the power mode. The setting method is very simple, just find the power option. Let’s follow the editor to take a look at the specific operation process. How to modify the power mode in win11 1. First click the leftmost button on the taskbar to open the start menu. 2. Then search and open "Control Panel" above the Start menu. 3. In the Control Panel, you can find "Hardware and Sound" 4. Enter Hardware and Sound, click "Choose a power plan" under Power Options 5. Then in You can modify the power mode. You can select balanced, energy-saving mode or expand the hidden additional plan and select high-performance mode.

PyCharm background color adjustment tips: Master it quickly! PyCharm background color adjustment tips: Master it quickly! Feb 03, 2024 am 09:39 AM

To quickly master the skills of modifying the background color of PyCharm, you need specific code examples. In recent years, the Python language has become more and more popular in the field of program development, and PyCharm, as an integrated development environment (IDE), is loved and used by the majority of developers. In PyCharm, some developers often personalize the IDE interface, including changing the background color. This article will introduce the technique of modifying the background color of PyCharm and give specific code examples to help readers quickly master this skill.

Win10 sleep time modification tips revealed Win10 sleep time modification tips revealed Mar 08, 2024 pm 06:39 PM

Win10 Sleep Time Modification Tips Revealed As one of the currently widely used operating systems, Windows 10 has a sleep function to help users save power and protect the screen when not using the computer. However, sometimes the default sleep time does not meet the needs of users, so it is particularly important to know how to modify the Win10 sleep time. This article will reveal the tips for modifying the sleep time of Win10, allowing you to easily customize the system’s sleep settings. 1. Modify Win10 sleep time through “Settings” First, the simplest fix

How to change the color of the Windows 10 taskbar How to change the color of the Windows 10 taskbar Jan 01, 2024 pm 09:05 PM

It is very simple to modify the taskbar color in Windows 10, but many users find that they cannot set it. In fact, it is very simple. Just choose your favorite color in the personalization of the computer. If you cannot change the color, pay attention to the detailed settings. How to change the color of the win10 taskbar Step 1: Right-click on the desktop - click Personalize Step 2: Customize the color area Step 3: Choose your favorite color PS: If you cannot change the color, you can click Color -> Select Color -> Customize->Default windows mode, select dark color.

See all articles