Bonjour à tous,
J'essaye de créer un lexer pour lilypond (un créateur de partition) avec QScintilla. J'ai un soucis avec l'autocompletion car la majorité des fonctions commence par un backslash (genre \clef ou \harmonicsOn) et QScintilla ne semble pas prendre en compte les mots commençant par des caractères spéciaux. Après quelques tests cela semble fonctionner uniquement avec des caractères alphanumériques et "_".
Voici un petit code que j'ai trouvé sur le net:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
import sys
from PyQt4.QtGui import QApplication
from PyQt4 import QtCore, QtGui, Qsci
from PyQt4.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython
 
if __name__ == "__main__":
    app = QApplication(sys.argv)
    editor = QsciScintilla()
 
    ## Choose a lexer
    ## This can be any Scintilla lexer, but the original example used Python
    lexer = QsciLexerPython()
 
    ## Create an API for us to populate with our autocomplete terms
    api = Qsci.QsciAPIs(lexer)
    editor.setBraceMatching(QsciScintilla.StrictBraceMatch)
    ## Add autocompletion strings
    api.add("aLongString")
    api.add("aLongerString")
    api.add("aDifferentString")
    api.add("sOmethingElse")
    api.add("\\clef")
    api.add("\\harmonicsOn")
    api.add("<test>")
    api.add("sOmethingElse")
    ## Compile the api for use in the lexer
    api.prepare()
 
    editor.setLexer(lexer)
 
    ## Set the length of the string before the editor tries to autocomplete
    ## In practise this would be higher than 1
    ## But its set lower here to make the autocompletion more obvious
    editor.setAutoCompletionThreshold(1)
    ## Tell the editor we are using a QsciAPI for the autocompletion
    editor.setAutoCompletionSource(QsciScintilla.AcsAPIs)
 
    ## Render on screen
    editor.show()
 
    ## Show this file in the editor
    #~ editor.setText(open("qt4_sci_ac_test.py").read())
    sys.exit(app.exec_())
Je pense qu'il y a une solution car ça ne marche pas non plus avec les caractères "<", et ">", ce qui peut être très gênant pour les langages genre html ou xml.
J'ai lu la doc de long en large pendant des heures sans rien trouver, et je commence à désespérer.
Donc est-ce possible ou dois-je recodonner mon propre "autocomplete"?