Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

How to implement intellisense with TLMDEditorView?

Hi,

I am trying to simulate intellisense with TLMDEditorView for my scripted application.  The built-in "Completion" feauture seems to be for correction and expansion, but I am trying to make it work.

Progress so far:
  • I expose a "Customer" object and added my available methods & properties in the completion list.
  • Completion fires for word-end when the user hits "." and shows the methods & properties.
  • On selection, completion replaces the word "Customer" before the ".". Eg. instead of "Customer.FirstName", I get "FirstName." in my editor.

I have tried a few things, but no luck so far.  Is there a better way to do this?

Thanks,

Carl

Comments

  • 2 Comments sorted by Votes Date Added
  • Hi,

    Edit completion is a feature, which is hard to undertsand and implement correctly. Usually it implemented with a help from corresponding compiler. So, its considered for advanced users only.

    Anyway, there some advices for you:

    1) Never use fcWordEnd cause. It for auto-correction only.

    2) For debug purposes restrict your completion with Cause = fcForced only. And use Ctrl+Space to force completion at any required cursor position. So, the code of OnFillCompletionList event handler shoudl start with:

    if Cause <> fcForced then
      Exit;
    //....

    3) The general case for completion is when it REPLACE some text with another. For example, if you type "Customer.First" and press Crtl+Space, completion will consider that you want to complete "First" word, and thust it will replace it. 

    Its important to understand that LeftPart event parameter will store "First" value - that is the part of word to replace. Another example: if you type "Customer.", then LeftPart parameter will have "" value (empty string), because nothing is typed after the dot. 
    So, the main idea is that LeftPart parameter stores already typed part of the word to replace, but NOT the context (not "Customer" word). So, the LeftPart parameter is NOT indended to be used determine object name to fill object methods/properties list. Its indended only to filter method/properties list, if required.

    The context itself ("Customer" in your case) should (at least) be determined from the document text itslef by manually parsing the text backward, starting from cursor position. Its important to understand that correct context can't be determined without a help from your compiler; just a simple example:

    var c = Customer;
    c.|        <-- Here simple completion will not work.

    Consider also correct skipping comments, string literals, ect, ect....
Sign In or Register to comment.