search
HomeBackend DevelopmentPHP TutorialScintilla User Guide (2) - Full text search and modification

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(, 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

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(, 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
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
如何更改Windows 11的PIN码如何更改Windows 11的PIN码Dec 23, 2023 pm 04:15 PM

有些朋友设置了pin码,但是由于不好记或者不方便等原因,想要修改,但是不知道win11怎么修改pin码,其实我们只需要进入账户设置的登录选项就可以了。win11怎么修改pin码:第一步,右键底部开始菜单。第二步,打开其中的“设置”第三步,点击左边的“账户”选项。第四步,打开右侧列表的“登录选项”第五步,点击pin右侧“小箭头”展开。第六步,点击下方“更改pin”第七步,在其中输入原pin码,再输入新pin码。输入完成点击“确定”即可完成修改。如果你之前没有pin码,也可以在这个位置新建pin码。

win10修改电脑开机密码的简单方法win10修改电脑开机密码的简单方法Jul 16, 2023 pm 05:33 PM

修改电脑开机密码的简单方法是什么?给win10电脑设置一个开机密码可以很好的保护资料隐私安全。不过,有些时候我们处于安全性考虑会设置比较复杂再者是简单的密码,但是想要更改电脑密码,却不知win10怎么修改电脑开机密码,其实电脑开机密码修改方法还是很简单的,下面我们就来看看修改电脑开机密码。win10修改电脑开机密码的简单方法如下:方法一1、进入电脑“搜索”功能搜索“账户”,打开“管理你的账户”。2、在出现的账户界面,左边列表栏找到“登陆选项”,点击选择。3、找到密码,选择点击更改的按钮。4、输入

Java开发:如何实现搜索引擎和全文检索功能Java开发:如何实现搜索引擎和全文检索功能Sep 21, 2023 pm 01:10 PM

Java开发:如何实现搜索引擎和全文检索功能,需要具体代码示例搜索引擎和全文检索是现代互联网时代的重要功能。它们不仅可以帮助用户快速找到想要的内容,还可以为网站和应用程序提供更好的用户体验。本文将介绍如何使用Java开发搜索引擎和全文检索功能,并提供一些具体的代码示例。使用Lucene库实现全文检索Lucene是一款开源的全文检索引擎库,由ApacheSo

修改WordPress中的特色图像大小修改WordPress中的特色图像大小Sep 15, 2023 pm 03:13 PM

特色图片是您可以添加到博客文章中的最重要的图片之一。特色图片之所以如此重要,是因为它在WordPress中的使用方式。当人们偶然发现在社交媒体上分享的您网站的链接时,他们首先看到的就是特色图片和帖子标题。这意味着您的特色图片会影响人们是否会从社交媒体点击查看您的帖子。这些图像还可以提供另一个重要功能,具体取决于您在网站上安装的主题。它们可以显示在您网站上链接到文章的所有位置。例如,假设您有一个侧边栏,显示阅读量最高的五篇文章。您将能够在侧边栏中显示您的帖子标题以及相应的特色图片。这可以使网站在视

使用Go语言编写高性能的全文检索引擎使用Go语言编写高性能的全文检索引擎Jun 15, 2023 pm 11:51 PM

随着互联网时代的到来,全文检索引擎越来越受到人们的重视。在无数的网页、文档和数据中,我们需要快速地找到所需的内容,这就需要使用高效的全文检索引擎。Go语言是一种以效率而闻名的编程语言,它的设计目标是提高代码的执行效率和性能。因此,使用Go语言编写全文检索引擎可以大大提高其运行效率和性能。本文将介绍如何使用Go语言编写高性能的全文检索引擎。一、理解全文检索引擎

PHP和Elasticsearch集成实现全文检索功能详解PHP和Elasticsearch集成实现全文检索功能详解Jun 25, 2023 am 10:14 AM

随着互联网的发展,企业面对的文本数据越来越庞大。如何快速、准确地检索出相关内容,成为企业在信息化领域的重要课题之一。Elasticsearch作为一个基于Lucene的开源搜索引擎,具有高可用性、高可扩展性和快速检索的特点,成为企业全文检索的首选方案之一。而PHP作为一门流行的服务器端编程语言,也能够快速进行Web开发和API开发,成为与Elasticsea

win7系统如何修改开机等待时间win7系统如何修改开机等待时间Jul 08, 2023 pm 06:49 PM

当我们使用win7系统时,在开机过程中,可能要等很长时间才进入系统,每一次启动都要浪费大量时间,如不希望每次开机都要等很长时间,可以修改开机等待时间,下面小编为大家介绍win7修改开机等待时间的方法。win7系统如何修改开机等待时间:1.点击win7系统桌面左下角的开始菜单,在菜单中选择“电脑”右键,然后选择“属性”选项;2.然后在计算机属性面板中,选择面板左边的“高级系统设置”项目;3.然后在系统属性弹出窗口中,切换到Advanced选项卡,在启动和故障恢复部分,点击Settings按钮;4.

win10修改系统时间的步骤教程win10修改系统时间的步骤教程Jul 10, 2023 pm 06:49 PM

相信大家都知道,当电脑时间出现不准确的时候,我们是可以自行通过电脑右下角的时间区域进行调整的。不过还是有的朋友刚接触电脑,不知道如何操作,下面我们来看看win10修改系统时间的步骤教程,大家快来看看吧。1、回到桌面,右键单击右下角的时间,出现菜单,点击调整日期和时间,如下图所示2、进入日期和时间调整界面,将自动设置开关关闭,如下图所示3、关闭自动设置后点击更改日期和时间下面的更改按钮,如下图所示4、进入调整界面,点击小时和分后面的箭头,如下图所示5、出现小时和分钟拨轮,调整时间,如下图所示以上就

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.