以编程方式更改 Eclipse 中的背景颜色
我有一个关于 eclipse 插件开发的问题。有什么办法吗 通过它我可以以编程方式更改 Eclipse 中的背景颜色。 我可以通过调用更改文本前景色 ITextViewer 中的 setTextColor(颜色、偏移量、长度、controlRedraw) 但我没有找到任何可以更改背景的功能 文本的颜色。 如果有人经历过这种情况,请分享您的想法。
谢谢 阿拉夫
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否可以轻松完成,除非扩展您自己的文本编辑器版本,在这里您提供一个
Configuration
类,该类又接受一个PresentationReconciler
类,就像告诉您是否需要放置前景色或背景色的Rule
类请参阅 本文档
PresentationReconciler
IPresentationDamager
:定义给定文本的脏区域更改DefaultDamagerRepairer
基于令牌扫描器执行这两项操作ITokenScanner
:将文本解析为令牌流RuleBasedScanner
使用简单的规则从演示文稿中摘录
来自文本编辑器食谱,文本编辑器的季节食谱
Tom Eicher,IBM Eclipse 团队
这里,空背景颜色意味着采用该小部件的默认系统背景。 (所以这里:白色)。
但是您可以根据文档的分区和适用的规则指定所需的任何颜色。
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 aPresentationReconciler
Class which is like aRule
Class that tells you if you need to put a Foreground or a Background ColorSee this document
PresentationReconciler
IPresentationDamager
: define dirty region given a text changeIPresentationRepairer
: recreate presentation for dirty regionDefaultDamagerRepairer
does both, based on a token scannerITokenScanner
: parse text into a token streamRuleBasedScanner
uses simple rulesExtract from the presentation
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.
我知道不久前有人问过这个问题,但如果有人正在寻找其他解决方案,我想我会发布以下内容:
既然您能够使用 setTextColor 方法,那么您也应该能够使用 changeTextPresentation 方法。
就我的插件而言,我有一个 TextListener,它调用我重写的 TextChanged 方法。我执行了以下操作,使用 changeTextPresentation 方法添加背景颜色。通过这样做,我能够获得绿色背景和黑色前景。当然,并不是我想要这个,只是为了测试目的。
I know this was asked a while ago, but in case anyone is looking for another solution, I thought I would post the following:
Since you are able to use the setTextColor method, then you should be able to use the changeTextPresentation method as well.
In the case of my plug-in, I have a TextListener that calls the TextChanged method I overwrote. I did the following to add background color using the changeTextPresentation method. In doing so, I was able to get a Green background with Black foreground. Not that I would want this, of course, but just for testing purposes.