[Qt-interest] Syntax Highlighter State Stack

Alan M. Carroll amc at network-geographics.com
Fri Jan 2 19:55:26 CET 2009


I think this illustrates what to me is a design flaw in QSyntaxHighlighter that renders it unusable for any of my projects. The flaw is that you cannot access the user data for the previous block. You can get the state, which is just an int, but not an instance of a generic class. Therefore, it's pointless to ask "What container would you use?" because you can't use a container, only an int. Clearly, the API can find the previous block because previousBlockState() does it. Why there isn't a parallel previousBlockUserData() is incomprehensible to me.

So my advice is that if your parse engine has any non-trivial state, write your own and ignore QSyntaxHighlighter.

At 12:16 PM 12/30/2008, Scott Aron Bloom wrote:
>Did you look at the QT syntax highlighter example?
>
>Did you look at the non-gui datatstructures given to you by QT in the
>docs?
>http://doc.trolltech.com/4.3/tools.html
>
>First, think of it in a Non-QT way?? What container would you use?
>
>
>> -----Original Message-----
>> From: Neel Basu [mailto:neel.basu.z at gmail.com]
>> Sent: Tuesday, December 30, 2008 10:08 AM
>> To: qt-interest at trolltech.com
>> Cc: Scott Aron Bloom
>> Subject: Re: [Qt-interest] Syntax Highlighter State Stack
>> 
>> No The reason for which I am asking is QSyntaxHighlighter provides
>> int previousBlockState () const
>> void setCurrentBlockState ( int newState )
>> int currentBlockState () const
>> function which seems to keep track of state data in two integer
>variables.
>> 
>> But what I am trying to do is keeping a stack of states.
>> So I'll not make mush use of these Qt methods rather I'll use mine.
>> 
>> Thanks why I am asking to make sure am I running through a wrong track
>??
>> 
>> On Tuesday 30 Dec 2008 11:29:42 pm Scott Aron Bloom wrote:
>> > What does this have to do with QT?  This is simple C++ data
>structure
>> > theory.
>> >
>> > Scott
>> >
>> > > -----Original Message-----
>> > > From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
>> > > bounces at trolltech.com] On Behalf Of Neel Basu
>> > > Sent: Tuesday, December 30, 2008 9:51 AM
>> > > To: Qt Interest
>> > > Subject: [Qt-interest] Syntax Highlighter State Stack
>> > >
>> > > I am Making a Syntax Highlighter for PHP
>> > > there are a lot of states such as
>> > >           enum State{
>> > >                   NormalState = -1,
>> > >                   InPHPCodeBlock,
>> > >                   InFunction,
>> > >                   InClass,
>> > >                   InMultiComment,
>> > >                   InCurlyBraces
>> > >           };
>> > > Now Its possible that some code block is in InMultiComment which
>is in
>> > > InFnction which is in InPHPCodeBlock
>> > > It is not possible to keep informations about these states in a
>single
>> > integer
>> > > variable.
>> > > (Is it ??)
>> > > So I thought to keep a vector for this enum values which will be
>used
>> > as a
>> > > StateStack
>> > >
>> > > Now the question is am I on the right Track ?? or there are easier
>or
>> > safer or
>> > > more standard alternatives ??
>> > >
>> > > Neel
>> > > _______________________________________________
>> > > Qt-interest mailing list
>> > > Qt-interest at trolltech.com
>> > > http://lists.trolltech.com/mailman/listinfo/qt-interest
>> >
>> > _______________________________________________
>> > Qt-interest mailing list
>> > Qt-interest at trolltech.com
>> > http://lists.trolltech.com/mailman/listinfo/qt-interest
>> >
>> 
>> 
>> 
>> --
>> Zigmoyd PHP Framework http://zigmoyd.net
>
>_______________________________________________
>Qt-interest mailing list
>Qt-interest at trolltech.com
>http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list