简体   繁体   English

E4-如何从SourceViewer删除插入符号?

[英]E4 - how to remove caret from SourceViewer?

I need to show something very similiar to source code, but it shouldn't be possible to modify it (but i still need funcionality as paint annotation etc.). 我需要显示一些与源代码非常相似的东西,但是不可能对其进行修改(但是我仍然需要功能,例如绘画注释等)。 The use case is more like - you click on some line and something will happen, some annotation will be shown etc.). 用例更像是-单击某些行,将会发生某些情况,将显示一些注释等)。

So i decided to try to use eclipse application platform, because its jface.text looks very good. 所以我决定尝试使用Eclipse应用程序平台,因为它的jface.text看起来非常好。

I am trying to use SourceViewer for my purposes. 我试图将SourceViewer用于我的目的。 It could be configured to not be editable, but it is still drawing the caret if you click into it. 可以将其配置为不可编辑,但是如果单击它,它仍会绘制插入符号。

QUESTION: How to disable painting of the caret? 问题:如何禁用插入符号的绘画?

EDIT: If you know something better than SourceViewer, which could fit to what i need, tell me please. 编辑:如果您比SourceViewer更好,这可能适合我的需求,请告诉我。

SourceViewer sv = new SourceViewer(parent, new CompositeRuler(), 0);
sv.setEditable(false);
sv.configure(new SourceViewerConfiguration());
sv.addVerticalRulerColumn(new LineNumberRulerColumn());
sv.setDocument(new Document(""));

看起来您应该能够使用以下命令将插入符号设置为null:

sv.getTextWidget().setCaret(null);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM