Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [gef-dev] how to highlight my key word in editor

hi,

this is probably not the right place to discuss this

but have a look at the following API:
org.eclipse.jface.text.presentation
org.eclipse.jface.text.rules

my experience was with eclipse 2.0.1, some change may have occured
but basically you have to extend a rule based scanner and
introduce it in the appropriate way in the eclipse
content manager. Here is a typicall (constructor)
extension of a RuleBasedScanner

// rule list
List rules = new ArrayList();

// defining token and colors (use a separate ColorManager for colors)
IToken logical =
new Token(
new TextAttribute(
manager.getColor(AlloyConfiguration.LOGICAL)));

//Add rule for comments
rules.add(new EndOfLineRule("//", comment));
rules.add(new EndOfLineRule("--", comment));
rules.add(new MultiLineRule("/*","*/", comment));

//Add rule for keywords
WordRule wr=new WordRule(new AlloyWordDetector(),otherword);
wr.addWord("assert",keyword);
wr.addWord("but",keyword);
rules.add(wr);

// registering rules
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
setRules(result);

Hope this helps
C.


李蛟 wrote:

>gef-dev!
>       I want to create an editor about my plugin .And I wonder how to highlight the key words defined in my plugin .For example in Java, String is one of the key words and  color of String is red in some IDE.
>       Lots of thanks!
>
>           liziwen@xxxxxxxx
>          2003-05-05
>
>
>_______________________________________________
>gef-dev mailing list
>gef-dev@xxxxxxxxxxx
>http://dev.eclipse.org/mailman/listinfo/gef-dev
>  
>

-- 
------------------------------------------------
    Ponsard Christophe  --   CETIC/FAUST
 Aéropole, rue Clément Ader 8, B-6041 Gosselies
 email: cp@xxxxxxxx  web: http://www.cetic.be
------------------------------------------------






Back to the top