
Signature
Daniel Sjöblom
Remove _NOSPAM to reply by mail
Uzytkownik "Daniel Sj?blom" <dsjoblom@mbnet.fi_NOSPAM> napisal w wiadomosci
news:40589afa$0$26136$7b6a8dc4@news.mbnet.fi...
> Once upon a time, I also asked this question. In response, Fahd Shariff
> posted an example extension of SyntaxStyledDocument. You should look
[quoted text clipped - 4 lines]
> attributes for specific syntactic elements. I can email you the source
> if you are interested.
I'am interested. Pplease use this email address: iyo( at)o2.pl
I have started implementing other solution:
1. I have inherited my class SourceDocument from AbstractDocument.
2. I keep text in a list of javax.swing.text.Segment.
3. I have created simple structure:
A) every SourceDocument has own rootElement which is subclass of Element
B) rootElement contains list od SourceBlockElement which is subclass of
BranchElement,
SourceBlockElement's are for example blocks and instructions
C) SourceBlockElement can store other SourceBlockElement and
SourceLeafElement
D) SourceLeafElement can be for example: keyword, numer,string ,
operator, etc
4. every leaf element is associated with part of text which is stored in
Segment
5. every leaf element have own Style -> MuttableAttributeSet
6. every SourceDocument have Syntax class which is responsible for
recognizing leaf and block elements
When user will update data I find leaf element (which have been changed) and
update it or create new leaf element.
So I dont have to parse all document, but only the right Element.
Particular Element shouldn't be longer than one line (50 characters).
I think this solution should work quite fast, and it dont require threads.
I have a lot of problems with make my Document compatible with
AbstractDocument :(
I cant deal with it.
> Ostermiller (I forget his first name, try google) has also implemented a
> syntax highlighting package, that uses some slightly different tactics
> (painting and parsing is done in separate threads). The source is
> available under GPL licensing I think.
I thought about threads too, but I think solution i've just described is
more
elegant.
> The bad news is that the first option is terribly slow, and the second
> looks a bit weird, and they both use generic swing components that are
> not meant to be used for code editors. You are better off using some
> component that is designed with syntax highlighting in mind. The old
> JEdit component is fast and in the public domain, but it is no longer
> maintained, so you will need to modify it to fit your needs.
I'am starting my adventure with Java. I wanted to create code editor only
as exercise. So it isnt very important to me, but
thx for response.
Michal Piotrkowski