Forum > LCL
[SOLVED] TSynCompletion filtering question
Wesbat:
Hi all.
Let me first say I've been enjoying working with Lazarus. It is a great tool.
For my question, I did try forum and internet searches, played with the component's events, and checked the Sourceforge bug tracker (admittedly a bit harder to trawl it).
I want to use the TSynCompletion component to provide a means to insert user-generated content. The challenge is the list of items are note searchable - i.e. I want to enter a partial word to match at an arbitrary location in the list, for example typing "hover" should match the entry "Display link target on hover".
I understand the component was built for code editors, and my use-case likely oversteps it's intended use. But I want to ask just in case - is there a way to achieve this filter behaviour with TSynCompletion?
LV:
Maybe: c:\lazarus\examples\SynEdit\SearchAndReplace\
Wesbat:
hmm, not quite the functionality I need. I need to insert a text that does not yet exist via a completion-like list. Thanks for the suggestion either way LV.
Martin_fr:
There is a "completion" example in the example folder. It shows how to use different completion tools. It also shows how to fill and filter the list.
Wesbat:
Thanks for the good suggestion Martin_fr,
Apologies for not be clearer in my original post. That example was the first place I looked and it works well for single-word completions. In my case I am trying to complete multiple words.
To demonstrate per the example: To complete the phrase "Personal Computer" (a word within the example's Itemlist) I cannot type "computer" and see the phrase in the popup list (screenshot attached). I have to type "personal" instead (it matches from the start of the ItemList entry)
Is it possible to match any word in the ItemList, not just the first word?
The ItemList from lazarus\examples\SynCompletion:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SynCompletion1.ItemList.Add('Personal Computer'); { <-- not shown in completion list if "computer" is entered } SynCompletion1.ItemList.Add('Personal'); SynCompletion1.ItemList.Add('Computer'); SynCompletion1.ItemList.Add('Police Constable'); SynCompletion1.ItemList.Add('Police'); SynCompletion1.ItemList.Add('Constable');
In comparison, when I enter "que" within the Lazarus code editor it matches "Query" and "Request" - I'd like to mimic this behaviour :)
Navigation
[0] Message Index
[#] Next page