I know scintilla. It´s the most famous highlight engine ever made.
Reading the Lexer.txt, I see that my lexer is the state kind, cause
if I found a comment or string, I can skip to the close tag and go on
from that point. Perhaps I´m in the right direction :)

Soon I got it working ok, I´ll post it online, so you can test it and see how it´s going.


On 9/27/06, Anatole Tartakovsky < [EMAIL PROTECTED]> wrote:

Here is one project with complewte C++ code we embedded in our product
few years ago
http://scintilla.sourceforge.net

Please note this:
http://scintilla.sourceforge.net/Lexer.txt

The question is - are you optimizing scope for recoloring - as you type
you should not have more then few surrounding characters to recheck

HTH,
Anatole

Flex Brasil wrote:
> I didn´t have much luck finding those kind of algorithms.
>
> I´m sorry, but ActionScript didn´t run at same speed as other native app.
> My benchmarks shows that AS is 18 times slower than a native code and
> runs at the same speed as PHP :)
>
> On 9/27/06, *Alex Harui* <[EMAIL PROTECTED] <mailto: [EMAIL PROTECTED]>>
> wrote:
>
> Have you looked around for algorithms for syntax highlighting? I
> would expect there are some out there. Remember that the player
> converts your actionscript code to machine code so you are running
> at the same speed as any other app on the computer. Make sure you
> are taking advantage of the players string and regex APIs and
> consider building data structures that record bookmarks so you
> don't have to scan from the beginning.
>
>
>
> There is some overhead moving data into Actionscript and back to
> the player so keep that in mind too.
>
>
>
> ----------------------------------------------------------
>
> *From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Wednesday, September 27, 2006 10:29 AM
>
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
>
>
> My benchmarks shows that the flash player html render is pretty fast.
> It has a acceptable behaviour with 50KB to 100KB of text.
> The algorithm to find the matching strings and comments is the
> bottleneck.
> So, no matter if I replace text, setTextFormat or rewrite the
> htmlText property,
> my solution can´t be faster enough inside flash player.
>
> On 9/27/06, *Alex Harui* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> The point several of are trying to make is that setting the .text
> property is expensive, especially if you use html markup.
>
>
>
> You may not be aware that the underlying textfield supports style
> changes purely by character offset which we all expect will be
> much faster for you. Thus, when the user types that quote, I know
> the caretIndex is at position 6. Further I can determine the
> color of the character prior to the caret and know that it is the
> string highlight color so I can scan backwards for the starting
> quote or keep some other data structure that knows where the
> quotes are. Next, I can call setTextFormat with the non-highlight
> color on character 7, call setTextFormat again on characters 8-12,
> etc. all w/o setting the .text property.
>
>
>
> You can still read out the final results as html if you want. The
> TextField will do that for you. However, I would expect that
> setTextFormat would be faster. You could further optimize by only
> coloring the text that is on-screen. The point is that through
> the use of more sophisticated data structures like tables of
> positions of color delimiters and via more powerful APIs like
> setTextFormat, you can probably do much better than computing html
> markup and forcing the player to process it over and over again.
>
>
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Tuesday, September 26, 2006 11:06 PM
>
>
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
>
>
> I really can´t think a way to keep control of the highlight,
> without need to parse everything.
> highligh only reserved words is ok, but strings, single line
> comments and multi line comments
> are hard to parse only on the changed text, cause when you open
> one of those, everything
> forward changes. Look the follow example and imagine the highligh
>
> "stringA" + "stringB" after
>
> Now imagine what happens if I insert a quote before A letter at
> first string
> "string"A" + "stringB" after
> now my strings are:
> "string", " + " and " after
>
> This example shows that a simple local change, affect everything
> forward.
>
> On 9/27/06, *Bjorn Schultheiss* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
>
> Without knowing the details of your algorithm,
> is it necessary to eval the complete text.
>
> Can you write a parser style method that evaluates which part of
> the text block has changed,
> therefore only needing to apply your algorithm to the changed text?
>
>
>
> Regards,
>
>
>
> Bjorn Schultheiss
>
>
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]> [mailto: flexcompone
> <mailto:flexcompone> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>] *On Behalf Of *Flex Brasil
> *Sent:* Wednesday, 27 September 2006 1:06 PM
>
>
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
>
>
> That sounds a nice trick to bypass the internal flash player
> process of
> rendering html, but that´s not what is limitating my syntaxe
> highlighter.
> While flash player is fast enougth to render 100KB of html text,
> my algorithm can´t go over 3KB of text.
>
> On 9/26/06, *Bjorn Schultheiss* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> I dont think it would be that difficult to build.
>
> Just a really smart idea.
>
>
>
> I must say this is why i love flash/flex dev.
>
> 1 problem, Many solutions.
>
> It's where programming and art come together.
>
>
>
> Regards,
>
>
>
> Bjorn Schultheiss
>
>
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]> [mailto: flexcompone
> <mailto:flexcompone> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>] *On Behalf Of *Ted Patrick
> *Sent:* Wednesday, 27 September 2006 9:56 AM
> *To:* [email protected]
> <mailto:[email protected]>
>
>
> *Subject:* RE: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
>
>
> Bjorn,
>
> You are reading me loud and clear!
>
> Trying to extract a small AS3 sample from Beau as a simple
> case/howto.
>
> Ted J
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Bjorn
> Schultheiss
> *Sent: *Tuesday, September 26, 2006 4:39 PM
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* [flexcomponents] Re: WYSIWYG Rich Text Editor for Flex 2
>
> 'A man's got to know his limitations' :)
>
> What Ted brought up was a cool idea i thought.
>
> >From what i get, you can create a box based off TextLineMetrics
> and apply a filter or blend mode to the box..
>
> Thus creating your coloring effect without having to update any text.
>
> Now maybe thats not what teds point was but still interesting.
>
> Regards,
>
> Bjorn Schultheiss
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Wednesday, 27 September 2006 7:03 AM
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
> Could you give more details? I google for Beau Amber, but didn´t
> found his highlighter.
> I didn´t understand how apply filters can be done to certain words.
>
> About my tests:
> I load some text in text property of textfield and discovery that
> the maximum usable
> is 50,000 chars. More than that, each time you press a key, a
> perceptible delay happens.
> A code file with fifty thousand chars has about one thousand and a
> half lines.
>
> On 9/26/06, *Ted Patrick* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> A great way to do this is via Filters. Beau Amber wrote a
> highlighter for AS3 using the Flex Components. Within a TextArea
> control, he used Regex to find matches and used filters to color
> highlight certain words. When the text was scrolled or changed,
> the filtering was removed for performance, then reapplied when the
> change stopped. As the highlighting only effects the viewable
> portion of the textArea, it was quite fast. It was rare to
> actually see it flicker at all.
>
> I would avoid the HTMLText route and use imaging to support your
> needs. I would not have recommended this initially but seeing it
> actually work changed my mind.
>
> Ted Patrick
>
> Flex Evangelist
>
> Adobe Systems Incorporated
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Gordon Smith
> *Sent:* Tuesday, September 26, 2006 1:15 PM
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* RE: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
> > What I do is every stroke, parse the text property and generate
> an html wich I set to htmlText.
>
> That means that on every stroke the player has to reparse the
> entire htmlText, recreate all the style runs, and redo all the
> line wrapping based on new measurement. No matter how fast the
> Player got, that design wouldn't scale to arbitrarily large documents.
>
> - Gordon
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Tuesday, September 26, 2006 12:44 PM
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
> Yes, i´m trying to do a code editor. Since it´s just for learn
> purpose, 3000 chars is ok,
> but would be nice support normal file size.
>
> I didn´t try replace/setTextFormat. What I do is every stroke,
> parse the text property and
> generate an html wich I set to htmlText.
>
> I don´t know how to do a highligher that can work with fragments
> of text, what would be much faster.
> My highlighter is a mix of tokenizer and regular _expression_. I´m
> doing a benchmark class to
> analyze where are the bottle necks on my algorithm.
>
> On 9/26/06, *Alex Harui* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Can you shed more light on what you are trying to do? Is it
> something like a code editor where as you type it colors certain
> text in certain ways?
>
> Have you tried using replaceSelectedText()/replaceText() instead?
> Have you tried using setTextFormat()?
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Tuesday, September 26, 2006 11:26 AM
>
>
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
> I really set text property each textChange event. I couldn´t think
> a better solution.
>
> On 9/26/06, *Alex Harui* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> I would revisit your highlighting algorithm. If you set the .text
> property too often it will definitely slow things down.
>
> ----------------------------------------------------------
>
> * From:* [email protected]
> <mailto:[email protected]>
> [mailto:[email protected]
> <mailto:[email protected]>] *On Behalf Of *Flex Brasil
> *Sent:* Tuesday, September 26, 2006 10:59 AM
> *To:* [email protected]
> <mailto:[email protected]>
> *Subject:* Re: [flexcomponents] Re: WYSIWYG Rich Text Editor for
> Flex 2
>
> One limitation of Flash player is speed. I´m doing a sintaxe
> highlighter but
> with a text bigger than 3000 chars, the input became slow in my
> machine that is
> an Athlon 64 3GHz with 1GB ram!!!
>
> On 9/26/06, *Michael Schmalle* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> > but I don't know if this will ever be out in the public
>
> I don't think I said it would but, just that there are things that
> the flash player can do that can work around current barriers.
>
> Peace, Mike
>
> On 9/26/06, *Peter Hall* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> > wrote:
>
> Yes, but I don't know if this will ever be out in the public.
> However, we know it is possible to make a very advanced text
> editor, rivalling desktop editors. Flash is ready, but it is just
> a hell of a lot of work.
>
> Peter
>
> On 9/23/06, *Michael Schmalle* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> > It's not online yet afaik. But just in case you don't believe
> that it exists, i've seen it too, and i was *very* impressed.
>
> Thanks Claus :), yes Stefan we are talking about something REAL.
> All I am saying is be an engineer - inventor, don't limit yourself
> to what you think you can do, try to do what you can't do.
>
> Peace, Mike
>
> On 9/23/06, *Claus Wahlers* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> >>I have seen something that you wouldn't believe
> > Ok, let's see it. Where is it?
>
> It's not online yet afaik. But just in case you don't believe that it
> exists, i've seen it too, and i was *very* impressed.
>
> Cheers,
> Claus.
>
> --
> claus wahlers
> côdeazur brasil
> http://codeazur.com.br
>
>
>
>
> --
> What goes up, does come down.
>
>
>
>
> --
> What goes up, does come down.
>
>
>
>
>
>
>
>
>


__._,_.___


SPONSORED LINKS
Custom software development Database development software Embedded software development
Offshore software development Software development

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to