非常简单,可分发的文本编辑器,具有可自定义的语法突出显示和可能的单词完成 - 没有别的

时间:2021-03-01 23:36:50

I'm looking for an editor - not an IDE - that has just syntax highlighting. Word completion would be nice for the keywords I specify as well, but I could give up that feature. It only needs to be Windows compatible.

我正在寻找一个只有语法高亮的编辑器 - 而不是IDE。单词完成对于我指定的关键字也很好,但我可以放弃该功能。它只需要与Windows兼容。

The situation is that I have an extremely narrow domain specific language that only has around 25 keywords; it doesn't even have conditionals. I would like the keywords to be highlighted so that the user knows when they've written a keyword correctly. And to help ensure that they don't need to specifically memorize each keyword, that's where word-completion would be nice.

情况是我有一个非常狭窄的域特定语言,只有大约25个关键字;它甚至没有条件。我希望突出显示关键字,以便用户知道他们何时正确地编写了关键字。并且为了帮助确保他们不需要专门记住每个关键字,这就是单词完成会很好的地方。

I'm going under the assumption that the user has the computer skills of your typical grandparent -- I've easily made syntax files for this DSL in Vim and PSPad, but I feel that those have way too many features to be "usable" for this target audience. The functionality of Notepad (plus coloring) would be just about adequate.

我假设用户具有典型祖父母的计算机技能 - 我很容易在Vim和PSPad中为这个DSL制作语法文件,但我觉得那些功能太多而无法“可用”对于这个目标受众。记事本的功能(加上着色)就足够了。

I'm also open to writing a simple editor from scratch, if there is a library that already does most of the work I've explained here - i.e. I just tell it what to highlight in what color, possibly using regular expressions.

我也愿意从头开始编写一个简单的编辑器,如果有一个库已经完成了我在这里解释过的大部分工作 - 也就是我只是告诉它要用什么颜色突出显示什么,可能使用正则表达式。


Updates: I've looked at SciTE a bit -- it is very much like what I'm looking for, except that creating the new syntax file (properties file) is becoming quite a hassle. My syntax is rather simple: a short sample script might have the form of:

CommandA
CommandB Num1 Num2

CommandC

It doesn't quite fit into Python or a Basic language, but I'm not going to write a lexer for it either. But the simplicity of SciTE and its ability to run external programs with the file are two high points.

它不太适合Python或Basic语言,但我也不会为它编写词法分析器。但SciTE的简单性及其使用该文件运行外部程序的能力是两个要点。

Notepad++ is decent too -- I think it's a bit too full-featured for the intended purpose, but that's not too bad in itself. I had already tried setting up a syntax file for it, but I'm having a couple issues that just shouldn't even pop up. For example, I've chosen a color for the number style. If I put the number 3, it shows up fine. If I put 3.0, the .0 part is in the default color, not the number color. If I do 0x80, only the first zero is colored, let alone the x80; so of course 0xff isn't colored right either. Also, # is my line-comment character. If I have a line such as

Notepad ++也很不错 - 我认为它对于预期目的来说有点太全功能了,但这本身并不算太糟糕。我已经尝试为它设置一个语法文件,但我有几个问题甚至不应该弹出。例如,我为数字样式选择了一种颜色。如果我把数字3,它显示罚款。如果我放3.0,.0部分是默认颜色,而不是数字颜色。如果我做0x80,只有第一个零被着色,更不用说x80;所以当然0xff也没有着色。另外,#是我的行注释字符。如果我有一条线如

# foo bar

the whole line is blue, which is proper. But if there isn't a space (#foo bar), then the whole line stays black. My last gripe is that auto-completion seems to only pick up on words already used in the file, not the keywords that haven't been used yet.

整条线是蓝色的,这是正确的。但如果没有空格(#foo bar),则整条线保持黑色。我的最后一个抱怨是,自动完成似乎只能查找文件中已经使用的单词,而不是尚未使用的关键字。

Am I missing something obvious with the syntax configuration here? I've had poor luck searching Google for what I think should be obvious answers in regards to Notepad++ syntax.

我在这里错过了一些明显的语法配置吗?我在搜索谷歌时遇到了运气不佳的问题,我认为应该是关于Notepad ++语法的明显答案。

5 个解决方案

#1


use notepad plus plus... with language plugin.. it read the keywords from a text file

使用notepad plus plus ... with language plugin ..它从文本文件中读取关键字

#2


Use the Scintilla library, as seen the SciTE editor. It has a systems for custom syntax highlighting and for autocompletion.

使用ScinTE库,就像SciTE编辑器一样。它有一个用于自定义语法高亮和自动完成的系统。

You might be able to use SciTE as it is, or you could easily modify it or write your own shell for the Scintilla editor component.

您可以按原样使用SciTE,也可以轻松修改它或为Scintilla编辑器组件编写自己的shell。

It comes with commercial-friendly Open Source licence.

它带有商业友好的开源许可证。

#3


NotePad++ satisfies all of your requirements, and more.

NotePad ++满足您的所有要求,等等。

from the link:

从链接:

Notepad++ is a free (as in "free speech" and also as in "free beer")

Notepad ++是免费的(如“言论*”和“免费啤酒”)

it also has auto-completion and user defined syntax highlighting.

它还具有自动完成和用户定义的语法突出显示。

#4


crimsoneditor and jedit work well

crimsoneditor和jedit运作良好

#5


After digging through the Wikipedia article on text editors, I've found that Programmer's Notepad will best suit my needs. Keyword completion is based only on the defined keywords; the syntax file was simple to set up; and I can disable the "complicated" features by default, turning it into just what I need.

在深入阅读*关于文本编辑器的文章之后,我发现程序员的记事本最适合我的需求。关键字完成仅基于定义的关键字;语法文件设置简单;我可以默认禁用“复杂”功能,将其转换为我需要的功能。

#1


use notepad plus plus... with language plugin.. it read the keywords from a text file

使用notepad plus plus ... with language plugin ..它从文本文件中读取关键字

#2


Use the Scintilla library, as seen the SciTE editor. It has a systems for custom syntax highlighting and for autocompletion.

使用ScinTE库,就像SciTE编辑器一样。它有一个用于自定义语法高亮和自动完成的系统。

You might be able to use SciTE as it is, or you could easily modify it or write your own shell for the Scintilla editor component.

您可以按原样使用SciTE,也可以轻松修改它或为Scintilla编辑器组件编写自己的shell。

It comes with commercial-friendly Open Source licence.

它带有商业友好的开源许可证。

#3


NotePad++ satisfies all of your requirements, and more.

NotePad ++满足您的所有要求,等等。

from the link:

从链接:

Notepad++ is a free (as in "free speech" and also as in "free beer")

Notepad ++是免费的(如“言论*”和“免费啤酒”)

it also has auto-completion and user defined syntax highlighting.

它还具有自动完成和用户定义的语法突出显示。

#4


crimsoneditor and jedit work well

crimsoneditor和jedit运作良好

#5


After digging through the Wikipedia article on text editors, I've found that Programmer's Notepad will best suit my needs. Keyword completion is based only on the defined keywords; the syntax file was simple to set up; and I can disable the "complicated" features by default, turning it into just what I need.

在深入阅读*关于文本编辑器的文章之后,我发现程序员的记事本最适合我的需求。关键字完成仅基于定义的关键字;语法文件设置简单;我可以默认禁用“复杂”功能,将其转换为我需要的功能。