[QScintilla] How to do AutoCompletion? Is there an example?

Timo Rothenpieler BORNtobeNAMELESS at online.de
Thu Mar 15 18:57:15 GMT 2007


Ok, i get it working with the Python Lexer, but not with my BMax Lexer.
What do i have to do for getting my Lexer work with Auto-Completion?

Here is the Lexer-Class:
------------
class QSCINTILLA_EXPORT QsciLexerBMax : public QsciLexer
{
	Q_OBJECT

	public:

	enum {
		Default = 0,
		Comment = 1,
		Number = 2,
		Keyword = 3,
		String = 4,
		MLComment = 5,
		Identifier = 6,
		HexNumber = 7,
		Operator = 8,
		BinNumber = 9,
		StringLiteral = 10,
		Extern = 11
	};

	QsciLexerBMax(QObject* parent=0);
	virtual ~QsciLexerBMax();

	const char* language() const;
	const char* lexer() const;
	const char* blockEnd(int *style = 0) const;
	const char* blockStart(int *style = 0) const;
	QString description(int style) const;
	const char* wordCharacters() const;
	const char* keywords(int set) const;
	int autoIndentStyle();
	QColor color(int style) const;
	QFont font(int style) const;
	QColor paper(int style) const;

	public slots:
	void setFont(const QFont &f,int style=-1);
	void setColor(const QColor &c,int style=-1);
	void setPaper(const QColor &c,int style=-1);
	void setKeywords(QString s);

	private:
	QColor frontColors[12];
	QColor paperColors[12];
	QFont  fonts[12];
	QString keywordList;
};
------------

And here the nowDoc Slot of my Document-Manager, which works fine for  
Python, but does not work for BMax:
------------
void SciManager::newDoc()
{
	QsciScintilla* sci = new QsciScintilla(this);
	sci->setPaper(QColor(1,81,107));
	sci->setMarginLineNumbers(1,true);
	sci->setFolding(QsciScintilla::CircledTreeFoldStyle);
	sci->setAutoIndent(true);
	sci->setAutoCompletionThreshold(2);
	sci->setAutoCompletionSource(QsciScintilla::AcsAPIs);

	//QsciLexerBMax* lex = new QsciLexerBMax(sci);
	QsciLexerPython* lex = new QsciLexerPython(sci);

	QsciAPIs* apis = new QsciAPIs(lex);
	apis->add("test");
	apis->add("test123");
	apis->add("foobar");
	apis->prepare();

	sci->setLexer(lex);

	int index = addTab(sci,"//"+tr("newdoc")+"//");

	SciDokument* doc = new SciDokument(sci,index,this);
	connect(doc,SIGNAL(changed(int)),this,SLOT(docChanged(int)));

	edits[index] = doc;
	setCurrentIndex(index);
}
------------

>
> Yes. The fact that you are creating your lexer and APIs on the stack,  
> rather
> than the heap, is odd - but you haven't supplied enough context to be  
> able to
> say if that is correct or not.
>
> Phil
> _______________________________________________
> QScintilla mailing list
> QScintilla at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/qscintilla





More information about the QScintilla mailing list