开发者

I want to make my own source code editor, what are the good choices to make? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 7 years ago.

Improve this question

I've had it of those dozens of editors which never provides simple things like:

  • distinguish type开发者_运维问答 keywords and instruction keywords so I can put different colors on them.
  • being cross platform using a standard GUI lib like qt gtk etc (notepad++, yes, I almost hate you).
  • enough keyboard shortcut like duplicate line, comment selection, and a decent find-replace.
  • Decent task-easing features like single-click-on-the-number-line-margin to select the entire line.
  • Scintilla or another good-enough lexer that highlights enough different things, because brain-compiling code is one thing, quickly identify with the eyes what is what is something I find important.

I just want to support very basic languages like C, C++, maybe Python, not HTML or CSS.

Is Scintilla a good choice to just highlight those languages, and is a lexer really necessary ?

Isn't QT enough to program a text editor such as the one I want to do ? I know there is QScintilla, but is there a reason I shouldn't use a lib that integrates a lexer ? Why is Scintilla such a good lib ?

Is QT a good choice for such an editor ? (I also want to hard embed ProFont in the editor to kill any reluctant font problem between OSes).

EDIT: In short, I want to make an editor, only with the same syntax highlight features of notepad++. That's my main goal, and the use of QScintilla might be a little harder than I thought...

EDIT2: Well I found textadept, it's not so known but is quite awesome. I didn't manage to make my lexer, since I have other to do which I do under windows, unfortunately it's slow on the mac. Apparently there isn't any Scite official build for the mac.


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.


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


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


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:

C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.h
C:\Qt\4.7.3\src\scripttools\debugging\qscriptedit.cpp

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.


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.


use something like C, QT and Lua for the scripting engine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜