[QScintilla] Search Whole Word matches Only on regular expression symbol

Phil Thompson phil at riverbankcomputing.com
Sat Oct 12 11:52:02 BST 2013


On Thu, 10 Oct 2013 18:06:31 +0100, Baz Walter <bazwal at ftml.net> wrote:
> On 10/10/13 01:29, Han Lun Tan wrote:
>> Hi,
>>
>> I using FindFirst to do search, turn on wo = true to search for whole
>> word matches only.
>> However, I found some bug as below text
>>
>> Known that I have turned on ONLY wo = true for whole word matches.
>> Given I have text as below, I search for "$test" It returns nothing.
>> ($test)
>> ($test)
>> ($test)
>>
>> If I change my search text to "test", I can find all the 3 lines
results.
>>
>> Is this a bug ? Any workaround?
> 
> It's not a bug: by default, "$" won't be counted as a word character. 
> However, it is possible to change the set of characters that Scintilla 
> treats as word-characters (and also what is treated as whitespace and 
> punctuation).
> 
> At the moment, I don't think QScintilla provides a way to do this 
> through the high-level api. (It is possible to re-implement the 
> QSciLexer wordCharacters function, but I think this will only directly 
> affect auto-completion). Instead, you could try setting the 
> word-characters through the low-level api, i.e.:
> 
>      SendScintilla(SCI_SETWORDCHARS, characters)
> 
> Note that setting the word-characters in this way will change the 
> behaviour of Scintilla in several ways, not just finding text. For 
> instance, double-clicking a word to select it will include any new 
> characters you have added.

So I need to call SCI_SETWORDCHARS when a lexer is set using the value
returned by the lexer's wordCharacters() method.

Is this likely to cause any unforeseen problems?

Phil


More information about the QScintilla mailing list