Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programmatically change the background color in eclipse

I have a question related to eclipse plugin development. Is there any means by which I can programmatically change the background color in eclipse. I am able to change the text foreground color by calling setTextColor(color, offset, length, controlRedraw) in ITextViewer but I don't find any function by which I can change the background color of the text. If anyone has been through this kindly share your thoughts.

Thanks arav


1 Answers

I am not sure this can be done easily, short of extending your own version of a Text Editor, here you provide a Configuration Class which inturn accepts a PresentationReconciler Class which is like a Rule Class that tells you if you need to put a Foreground or a Background Color

See this document

PresentationReconciler

  • IPresentationDamager: define dirty region given a text change
  • IPresentationRepairer: recreate presentation for dirty region
  • DefaultDamagerRepairer does both, based on a token scanner
  • ITokenScanner: parse text into a token stream
  • RuleBasedScanner uses simple rules

Extract from the presentation

http://web.archive.org/web/20140715222227/http://img266.i_mageshack.us/img266/5465/setrules2.png

From Text Editor Recipes, Season’s recipes for your text editor
Tom Eicher, IBM Eclipse Team

Here, the null background color means, takes the default system background for that widget. (so here: white).
But you could specify whatever color you want, based on the partitioning of your document and on the rules that would apply.

like image 74
VonC Avatar answered Apr 11 '26 05:04

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!