If you must write your own editor, I suggest looking at the other open source editors and examine which pieces you port to your editor.
Porting pieces of existing working and tested code is usually much better than writing your own code and debugging it.
After perusing a couple serious open source editors: Emacs, Eclips, CodeBlocks, CodeLight, etc., I believe you will start changing your mind about writing an editor from scratch.
如果你真的想这样做(听起来需要很多工作),我会看看 ANTLR 来解析代码。您可能会从他们的 ANTLRWorks 展示中得到一些想法。 将解析树链接到显示可能需要大量工作,因此我想了解 IDE 平台(例如 Eclipse)必须提供什么
If you really want to do this (and it sounds like a lot of work) I would look at ANTLR for parsing the code. You may get some ideas from their ANTLRWorks display. To link the parse tree to a display could be a fair amount of work so I'd see what an IDE platform such as Eclipse has to offer
但是,您可能想更进一步并为您的应用程序使用 Eclipse RCP 框架...但是为什么不使用 Eclipse IDE 本身呢?只需添加任何您想要的插件即可。
Eclipse 代码库非常庞大,重用程度取决于您。
Are you OK with Java?
If so, go for Eclipse technologies: SWT and JFace. The latter provides you with org.eclipse.jface.text package with a lot of features. Then you can roll own editor easily basing on that. (I prefer Eclipse-based editors to Scintilla-based, I believe they tend to be more advanced and feature-rich, but that's my personal opinion.)
But then, you might want to go a step further and use the Eclipse RCP framework for you application... But then why not use the Eclipse IDE itself and just add whatever you want as plug-ins.
The Eclipse codebase is huge and it's up to you how much you want to reuse.
I would expend some effort experimenting with the emacs colour theme package and the various langauge modes; see if you can bend the lisp to do what you want. You almost certainly can. to my mind emacs and a bit of effort on your part will get you your ultimate editor (remember emacs is really just a DIY editor toolkit). If you cant bend emacs into the shape you want you will be well placed to expend the effort in writing your own.
I have tried to do something similar myself for a project I'm working on at the moment, I looked into the QScintilla and had to remove it from my project because when you embedded inside a QGraphicsView I can't control the resolution of the widgets image, it seems to paint the text as an image and that's what we see, I played with increasing the smoothness of the QFont and that improved it but still a no-go.
So I found a simple code editor inside QT's code base it comes with every installation of QT if you look into:
If you go to the source code of OpenShapeFactory where I'm trying to embed a Code Editor: check how I got the syntax Highlighter and the autocomplete :
this widget uses the qscriptedit widget that ships with qt, you can add your own keywords to the syntax hightlighter from a file as well as for the auto-complete dropdownlist.
the next stage is to look into the QTCreator and see the code they already have all if not most of these features after you get to compile their version, just find where to add your little mods and you might be getting closer to the simple code editor.
I wish you the best of luck on this direction and if you find a solution please send it over, :) heads-up keep a lookout for the repository link above, if I find a way of making it first, I might chase you to the answer.
Like everyone else is saying, it's probably more trouble than it's worth, but if you really want to do it, Qt's a good choice since it's cross platform. Use QSyntaxHighlighter to do your keyword/type highlighting, and take full advantage Qt's support for keyboard shortcuts.
发布评论
评论(8)
无论怎么想,C++ 都不是一种“非常基础的语言”。
为什么你真的想这样做?那里有很多开源代码编辑器。
C++ is not a "very basic language" by any stretch of the imagination.
Why do you really want to do this? There are SOOO many open source code editors out there.
如果您必须编写自己的编辑器,我建议您查看其他开源编辑器并检查将哪些部分移植到您的编辑器中。
移植现有的工作和测试代码通常比编写自己的代码并调试它要好得多。
在仔细研究了几个严肃的开源编辑器:Emacs、Eclips、CodeBlocks、CodeLight 等之后,我相信您会开始改变从头开始编写编辑器的想法。
——托马斯·马修斯
我的信息
If you must write your own editor, I suggest looking at the other open source editors and examine which pieces you port to your editor.
Porting pieces of existing working and tested code is usually much better than writing your own code and debugging it.
After perusing a couple serious open source editors: Emacs, Eclips, CodeBlocks, CodeLight, etc., I believe you will start changing your mind about writing an editor from scratch.
-- Thomas Matthews
My Info
如果你真的想这样做(听起来需要很多工作),我会看看 ANTLR 来解析代码。您可能会从他们的 ANTLRWorks 展示中得到一些想法。
将解析树链接到显示可能需要大量工作,因此我想了解 IDE 平台(例如 Eclipse)必须提供什么
If you really want to do this (and it sounds like a lot of work) I would look at ANTLR for parsing the code. You may get some ideas from their ANTLRWorks display.
To link the parse tree to a display could be a fair amount of work so I'd see what an IDE platform such as Eclipse has to offer
你对 Java 还好吗?
如果是这样,请选择 Eclipse 技术:SWT 和 JFace。后者为您提供了具有许多功能的
org.eclipse.jface.text
包。然后您可以在此基础上轻松推出自己的编辑器。 (与基于 Scintilla 的编辑器相比,我更喜欢基于 Eclipse 的编辑器,我相信它们往往更先进、功能更丰富,但这是我个人的观点。)但是,您可能想更进一步并为您的应用程序使用 Eclipse RCP 框架...但是为什么不使用 Eclipse IDE 本身呢?只需添加任何您想要的插件即可。
Eclipse 代码库非常庞大,重用程度取决于您。
Are you OK with Java?
If so, go for Eclipse technologies: SWT and JFace. The latter provides you with
org.eclipse.jface.text
package with a lot of features. Then you can roll own editor easily basing on that. (I prefer Eclipse-based editors to Scintilla-based, I believe they tend to be more advanced and feature-rich, but that's my personal opinion.)But then, you might want to go a step further and use the Eclipse RCP framework for you application... But then why not use the Eclipse IDE itself and just add whatever you want as plug-ins.
The Eclipse codebase is huge and it's up to you how much you want to reuse.
我会花一些精力尝试 emacs 颜色主题包和各种语言模式;看看你是否可以弯曲口齿不清来做你想做的事。你几乎肯定可以。在我看来,emacs 和你的一点努力将让你成为终极编辑器(记住 emacs 实际上只是一个 DIY 编辑器工具包)。如果您无法将 emacs 弯曲成您想要的形状,那么您将有能力花费精力编写自己的 emacs。
I would expend some effort experimenting with the emacs colour theme package and the various langauge modes; see if you can bend the lisp to do what you want. You almost certainly can. to my mind emacs and a bit of effort on your part will get you your ultimate editor (remember emacs is really just a DIY editor toolkit). If you cant bend emacs into the shape you want you will be well placed to expend the effort in writing your own.
我尝试为我目前正在从事的项目做类似的事情,我研究了 QScintilla 并不得不将其从我的项目中删除,因为当您嵌入到 QGraphicsView 中时 我无法控制小部件图像的分辨率,它似乎将文本绘制为图像,这就是我们所看到的,我尝试增加
QFont
的平滑度并改进但仍然不行。所以我在 QT 的代码库中找到了一个简单的代码编辑器,如果你看的话,每次安装 QT 都会附带它
进入:
如果您转到
OpenShapeFactory
的源代码,我试图在其中嵌入代码编辑器:检查我如何获得语法荧光笔和自动完成:此小部件使用 qt 附带的 qscriptedit 小部件,您可以将自己的关键字从文件以及自动完成下拉列表添加到语法高亮显示中。
这是标头、scriptwidget.h 和实现scriptwidget.cpp 作为整个 < a href="http://code.google.com/p/openshapefactory" rel="nofollow">项目代码。
下一阶段是研究 QTCreator,在编译他们的版本后查看他们已经拥有的所有(如果不是大部分)这些功能的代码,只需找到在哪里添加你的小 mod,你可能会更接近简单的代码编辑器。
我祝你在这个方向上好运,如果你找到解决方案,请将其发送出去,:)
请注意上面的存储库链接,如果我首先找到一种方法,我可能会追寻您的答案。
I have tried to do something similar myself for a project I'm working on at the moment, I looked into the
QScintilla
and had to remove it from my project because when you embedded inside aQGraphicsView
I can't control the resolution of the widgets image, it seems to paint the text as an image and that's what we see, I played with increasing the smoothness of theQFont
and that improved it but still a no-go.So I found a simple code editor inside QT's code base it comes with every installation of QT if you look
into:
If you go to the source code of
OpenShapeFactory
where I'm trying to embed a Code Editor: check how I got the syntax Highlighter and the autocomplete :this widget uses the qscriptedit widget that ships with qt, you can add your own keywords to the syntax hightlighter from a file as well as for the auto-complete dropdownlist.
this is the header, scriptwidget.h and the implementation scriptwidget.cpp are available as part of the whole project code.
the next stage is to look into the QTCreator and see the code they already have all if not most of these features after you get to compile their version, just find where to add your little mods and you might be getting closer to the simple code editor.
I wish you the best of luck on this direction and if you find a solution please send it over, :)
heads-up keep a lookout for the repository link above, if I find a way of making it first, I might chase you to the answer.
就像其他人所说的那样,这可能比它的价值更麻烦,但如果你真的想这样做,Qt 是一个不错的选择,因为它是跨平台的。使用 QSyntaxHighlighter 进行关键字/类型突出显示,并充分利用 Qt 对键盘快捷键的支持。
Like everyone else is saying, it's probably more trouble than it's worth, but if you really want to do it, Qt's a good choice since it's cross platform. Use QSyntaxHighlighter to do your keyword/type highlighting, and take full advantage Qt's support for keyboard shortcuts.
使用 C、QT 和 Lua 等作为脚本引擎。
use something like C, QT and Lua for the scripting engine.