[英]Eclipse Plugin: Highlight Code Line (textmarker while debugging)
Please do not confuse this with 'selecting code' like selecting code with a mouse. 请不要将此与“选择代码”混淆,例如用鼠标选择代码。
When my debug device hits a break point I want to highlight the specific line of code. 当我的调试设备达到断点时,我要突出显示特定的代码行。 I am using the CDT Plugin.
我正在使用CDT插件。
I already got the lineNumber
and all I want to do now is to tell 我已经有了
lineNumber
,现在我要做的就是告诉
editor.highlightLine(lineNumber);
to get something like this: 得到这样的事情:
I already tried this: 我已经尝试过了:
marker = resource.createMarker(IMarker.TEXT);
marker.setAttribute(IMarker.LINE_NUMBER, 10);
marker.setAttribute(IMarker.CHAR_START, 0);
marker.setAttribute(IMarker.CHAR_END, 10);
but it didn't work. 但这没用。
Since there are already predefined annotations provided by Eclipse and/or the CDT Plugin I'd like to reuse them. 由于Eclipse和/或CDT插件已经提供了预定义的注释,因此我想重用它们。 But how to access and use them inside sourcecode?
但是如何在源代码中访问和使用它们呢?
You can create your own marker using an extension point "org.eclipse.core.resources.markers"
and adding super attribute of type "org.eclipse.core.resources.textmarker"
. 您可以使用扩展点
"org.eclipse.core.resources.markers"
并添加类型为"org.eclipse.core.resources.textmarker"
超级属性来创建自己的标记。 After setting up your marker, you still need to describe its look and feel by adding the annotation extension point "org.eclipse.ui.editors.annotationTypes"
设置标记后,您仍然需要通过添加注释扩展点
"org.eclipse.ui.editors.annotationTypes"
来描述其外观。
I am not exactly sure of your intentions but this link might help http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide/section3.html 我不确定您的意图,但此链接可能会帮助http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-plugin-guide/section3.html
Marker is the thing on your ruler. 标记是您标尺上的东西。 You need to look at the editor background painting.
您需要查看编辑器的背景画。 Take a look at InstructionPointerManager.java
看看InstructionPointerManager.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.