autocompletion in Scintilla, howto ?

Stef Mientki wrote:

hello,

doe someone knows how to start autocompletion in Scintilla (with Python lexer) after typing the first letter of a word ?

It's shown in the StyledTextCtrl_2 sample in the demo. Look for AutoCompShow. I'll list here the C++ STC APIs available for the auto-completion features, the Python versions are equivalent:

     // Display a auto-completion list.
     // The lenEntered parameter indicates how many characters before
     // the caret should be used to provide context.
     void AutoCompShow(int lenEntered, const wxString& itemList);

     // Remove the auto-completion list from the screen.
     void AutoCompCancel();

     // Is there an auto-completion list visible?
     bool AutoCompActive();

     // Retrieve the position of the caret when the auto-completion list was displayed.
     int AutoCompPosStart();

     // User has selected an item so remove the list and insert the selection.
     void AutoCompComplete();

     // Define a set of character that when typed cancel the auto-completion list.
     void AutoCompStops(const wxString& characterSet);

     // Change the separator character in the string setting up an auto-completion list.
     // Default is space but can be changed if items contain space.
     void AutoCompSetSeparator(int separatorCharacter);

     // Retrieve the auto-completion list separator character.
     int AutoCompGetSeparator();

     // Select the item in the auto-completion list that starts with a string.
     void AutoCompSelect(const wxString& text);

     // Should the auto-completion list be cancelled if the user backspaces to a
     // position before where the box was created.
     void AutoCompSetCancelAtStart(bool cancel);

     // Retrieve whether auto-completion cancelled by backspacing before start.
     bool AutoCompGetCancelAtStart();

     // Define a set of characters that when typed will cause the autocompletion to
     // choose the selected item.
     void AutoCompSetFillUps(const wxString& characterSet);

     // Should a single item auto-completion list automatically choose the item.
     void AutoCompSetChooseSingle(bool chooseSingle);

     // Retrieve whether a single item auto-completion list automatically choose the item.
     bool AutoCompGetChooseSingle();

     // Set whether case is significant when performing auto-completion searches.
     void AutoCompSetIgnoreCase(bool ignoreCase);

     // Retrieve state of ignore case flag.
     bool AutoCompGetIgnoreCase();

     // Display a list of strings and send notification when user chooses one.
     void UserListShow(int listType, const wxString& itemList);

     // Set whether or not autocompletion is hidden automatically when nothing matches.
     void AutoCompSetAutoHide(bool autoHide);

     // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
     bool AutoCompGetAutoHide();

     // Set whether or not autocompletion deletes any word characters
     // after the inserted text upon completion.
     void AutoCompSetDropRestOfWord(bool dropRestOfWord);

     // Retrieve whether or not autocompletion deletes any word characters
     // after the inserted text upon completion.
     bool AutoCompGetDropRestOfWord();

     // Register an image for use in autocompletion lists.
     void RegisterImage(int type, const wxBitmap& bmp);

     // Clear all the registered images.
     void ClearRegisteredImages();

     // Retrieve the auto-completion list type-separator character.
     int AutoCompGetTypeSeparator();

     // Change the type-separator character in the string setting up an auto-completion list.
     // Default is '?' but can be changed if items contain '?'.
     void AutoCompSetTypeSeparator(int separatorCharacter);

     // Set the maximum width, in characters, of auto-completion and user lists.
     // Set to 0 to autosize to fit longest item, which is the default.
     void AutoCompSetMaxWidth(int characterCount);

     // Get the maximum width, in characters, of auto-completion and user lists.
     int AutoCompGetMaxWidth();

     // Set the maximum height, in rows, of auto-completion and user lists.
     // The default is 5 rows.
     void AutoCompSetMaxHeight(int rowCount);

     // Set the maximum height, in rows, of auto-completion and user lists.
     int AutoCompGetMaxHeight();

     // Get currently selected item position in the auto-completion list
     int AutoCompGetCurrent();

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!