Eclipse RCP:如何显示源代码?

时间:2023-01-12 21:56:51

I was wandering if it's possible to open a source code in text editor and display it with decorations (Java for example)? I don't need fancy eclipse editor features, just properly decorated source code with line numbers, it can even be read-only. I read that RCP have many limitations with text editors as it drags behind heavy plug-ins. Can it be done at all? Is it possible to navigate to particular line of code when file is opened? It would be really great if someone would point me out to the right direction or give some examples... Thanks in advance!

如果可以在文本编辑器中打开源代码并使用装饰(例如Java)显示它,我就会徘徊?我不需要花哨的eclipse编辑器功能,只需正确装饰带有行号的源代码,它甚至可以是只读的。我读到RCP对文本编辑器有很多限制,因为它拖累了大量的插件。它可以完成吗?打开文件时是否可以导航到特定的代码行?如果有人能指出我正确的方向或给出一些例子,那将是非常好的...在此先感谢!

2 个解决方案

#1


Eclipse (3.4.2) itself ships with a sample XML editor that implements syntax highlighting. Just create a new plugin project, select 'This plugin will make contributions to the UI' and choose 'No' for Rich client application. The following wizard page offers a 'Plugin with an editor' template, which is your friend.

Eclipse(3.4.2)本身附带了一个实现语法高亮的示例XML编辑器。只需创建一个新的插件项目,选择“此插件将为UI做出贡献”,并为Rich客户端应用程序选择“否”。以下向导页面提供了一个“带编辑器的插件”模板,这是您的朋友。

It may be too simple to use it as real template for your task, but it demonstrate how to create colourful editors for text files.

将它用作任务的真实模板可能过于简单,但它演示了如何为文本文件创建彩色编辑器。

#2


i'm implementing a eclipse plugin which focusing on TTCN language, the editor is the most important part for it. actually, i'm using Eclipse editor framework. i guess there are quite more useful features than you want. And it's easy to extended.As Andreads_D said, you can find reference to the basic example which eclipse provided defaultly. I guess you don't need to know everything about it, just fousing on your needs. Also you can reference https://quitus-kitt.googlecode.com/svn/trunk. Any problem, we can discuss. : )

我正在实现一个专注于TTCN语言的eclipse插件,编辑器是最重要的部分。实际上,我正在使用Eclipse编辑器框架。我想有比你想要的更有用的功能。并且它很容易扩展。正如Andreads_D所说,你可以找到默认提供eclipse的基本例子。我想你不需要了解它的一切,只是满足你的需求。您也可以参考https://quitus-kitt.​​googlecode.com/svn/trunk。有任何问题,我们可以讨论。 :)

#1


Eclipse (3.4.2) itself ships with a sample XML editor that implements syntax highlighting. Just create a new plugin project, select 'This plugin will make contributions to the UI' and choose 'No' for Rich client application. The following wizard page offers a 'Plugin with an editor' template, which is your friend.

Eclipse(3.4.2)本身附带了一个实现语法高亮的示例XML编辑器。只需创建一个新的插件项目,选择“此插件将为UI做出贡献”,并为Rich客户端应用程序选择“否”。以下向导页面提供了一个“带编辑器的插件”模板,这是您的朋友。

It may be too simple to use it as real template for your task, but it demonstrate how to create colourful editors for text files.

将它用作任务的真实模板可能过于简单,但它演示了如何为文本文件创建彩色编辑器。

#2


i'm implementing a eclipse plugin which focusing on TTCN language, the editor is the most important part for it. actually, i'm using Eclipse editor framework. i guess there are quite more useful features than you want. And it's easy to extended.As Andreads_D said, you can find reference to the basic example which eclipse provided defaultly. I guess you don't need to know everything about it, just fousing on your needs. Also you can reference https://quitus-kitt.googlecode.com/svn/trunk. Any problem, we can discuss. : )

我正在实现一个专注于TTCN语言的eclipse插件,编辑器是最重要的部分。实际上,我正在使用Eclipse编辑器框架。我想有比你想要的更有用的功能。并且它很容易扩展。正如Andreads_D所说,你可以找到默认提供eclipse的基本例子。我想你不需要了解它的一切,只是满足你的需求。您也可以参考https://quitus-kitt.​​googlecode.com/svn/trunk。有任何问题,我们可以讨论。 :)