posts - 76,  comments - 621,  trackbacks - 0
 

终于忍不住了,要为Megax加上语法加亮,我在正则还是lex上徘徊了大半年,始终没有找到比较好的方法,一个编辑器如果支持非常严格的语法加亮的话,那么可配置性是相当的差的。像scintilla,你必须得写个lex针对某种特定的语言才行。当然大多数的语言都有一些共性,比如你可以用c语言的语法文件去渲染java或者c#的。但是我不想这么做,我想要傻瓜也可以进行配置文件的编写,像Editplus,但是Editplus做的不够好。

目前完成了块状代码的识别,这是最关键的,什么是块状的呢,主要是下面这三种:

1.注释(单行,多行)
2.字符串(可续行或者不可)
3.子语言

对于子语言这一块,c++里面可以嵌入asm,html里面可以嵌入css和js,像这样的语言,我把它定义成子语言。但是子语言不可嵌套,在Megax里面我不处理嵌套的子语言(PS:谁他妈的有病啊,这么写)。

完成上面这些,在遇到子语言的时候,只需要切换当前的schema就可以完成子语言的语法加亮,同时Megax定死了,最多支持4种sub language.

识别完之后,在用正则分别进行细节匹配,比如c++里面里面的#[多个空格]include和#[无空格]include都是关键字,或者注释里面含有email地址之类的。

在进行行跳转的时候,我们不需要识别这些,只需要识别块状的代码,所以效率是非常的高,在我的机器上打开100万行的代码,跳转到任意一行,均十分的流畅。

先写这么多了,下面这张截图暂时没有子语言的支持,上班时间偷偷写的啊。

另外高速自动换行基本实现了,效率和内存占用让我很满意,基本上没有明显的延迟,小胜Editplus。

最近下了EMEditor的最新版本,EM做的是越来越强大了,基础功能和架构我觉得应该是目前最棒的编辑器。在打开超大文件的时候,用内存映射之后,剩下的内存占用主要是行信息。在编辑的时候,我一直认为内存映射会非常的慢,看来我需要重新审视一下。思路就是这样的,EM加载大文件的时候会启动一个新的线程,线程的同步着实是个大问题,不是我擅长的啊。。。。

周四回国了,好高兴,回去要大吃一顿,想死我了。


posted @ 2008-06-23 18:17 megax 阅读(1964) | 评论 (4)编辑 收藏
今天在网上搜索自动机的文章的时候发现了一个和我想法差不多的人,他提到了e,简单的试了一下,很慢,没来得及细看。

On a good day I spend anywhere from 8 to 12 hours writing code. Unfortunately, even though I've been doing this for ten years now, I have yet to find a text editor that satisfies all my needs.

I suspect TextMate would fulfill all my wildest fantasies, but I don't have a Mac. A few months ago I wrote about e, which is currently the closest thing to TextMate for Windows. Sadly, my infatuation with e is quickly wearing off; it gets slower, more bloated, and less stable with each release. Intype shows promise, but is missing some very important features and is apparently being developed by a team of hypothermic sloths with refactoritis.

My needs aren't complex, nor are they numerous:

  1. High performance, low resource usage

    During a typical debugging session, I have Firefox, IE7, Opera, Safari, and an IE6 VMWare image running in addition to my email client, IM client, several SSH terminals, and my text editor. Every last megabyte of RAM is precious, yet many text editors (especially recent builds of e) have no qualms about gobbling up a hundred megs or more and responding like a pregnant cow in a lake of molasses. You're a fucking text editor, not a goddamn video game. Learn how to manage memory efficiently.

  2. Good, customizable syntax highlighting

    Shareable color schemes in the form of editable files is a must. GUI dialogs that force me to open a color palette and choose each individual color for each individual language construct are an instant disqualifier, especially if I have to do this for every single language (I'm looking at you Aptana).

  3. Good anti-aliased font rendering

    This comes for free on Windows if you just let the OS render the damn fonts, but plenty of text editors still seem to get this wrong. I have to stare at these fonts all day, every day, so I need them crisp and readable, not pixelated or blurry. If I can't use my favorite font, that's an instant failing grade (suck it, jEdit).

  4. Some kind of outline- or symbol-based navigation

    I need to be able to jump to any class, method, CSS selector, etc. instantly, preferably with a hotkey and a few keystrokes. This is one thing that e does very, very well, but that no other Windows text editor can seem to get right. It does me no good if you display the outline in a lovely treeview with expandable nodes for each class and method but don't give me a keyboard shortcut. I'm not going to use the mouse. I refuse. Mouse equals fail.

  5. Stay the hell out of my way

    I don't want auto-indent, I don't want auto-formatting, I don't want auto-complete, I don't want auto-fucking-anything. I know what I'm doing and I want you to get out of my way and let me do it, because if you try to do it for me you'll only fuck it up.

At this point, I've pretty much given up all hope of finding a Windows text editor that does these five simple things and does them well. I've resigned myself to the fact that I'm either going to have to return to the dark and painful world of desktop application programming and write my own damn text editor or I'm going to have to bite the bullet, get a Mac, and use TextMate.

Since I don't have the time or the desire to write my own text editor, it's looking like I'll probably end up throwing money at the problem. Sigh.

posted @ 2008-06-21 23:45 megax 阅读(533) | 评论 (1)编辑 收藏
今天头好疼,睡到12点。。。
添加了MDI的拖放支持,并且根据不同的FileType显示不同的图标。
都是一些小细节,最近身体不好,有空了,在把core部分好好更新一下。

posted @ 2008-06-08 00:06 megax 阅读(300) | 评论 (0)编辑 收藏
今天上班本来说是导入新的系统,结果因为手顺上几句话,又让我等,我靠。
整整一天,啥也没干,净坐着地铁在东京来回的转悠了,头都晕死了。
下午,空闲的时候,找了个CSizingControlBar,添加了MDI支持,一些基本的代码都出来了。
以前用的codeproject的一些代码,很难用,而且集成进来,代码风格也有点不伦不类。
TabCtrl倒置后的样子很丑陋,而且在操作系统不同的theme下样式也不一样,抽个空自己写一个吧。
其实就是个HWND管理工具,难度应该不是太大。
posted @ 2008-06-05 21:45 megax 阅读(312) | 评论 (0)编辑 收藏
最近睡眠不好,总是睡不着.
抽点空,把代码重构了一遍,进一步优化了性能,改进了一些小bug.
把语法加亮这块拿出来,以后有空了,在好好的封装,以前写了个通用的词法分析器,
可是对于像html这样其中可以嵌入其它的语言,还真不好弄.
输入,删除,剪贴板,Redo,Undo,都完成了,这个雏形算是出来了,剩下的其它的更细节的
操作打算留给脚本来操作.Lua比较好嵌入,就选择它了.
自动换行这块,得好好的弄弄,效率不是太让我满意.


posted @ 2008-05-31 23:21 megax 阅读(450) | 评论 (0)编辑 收藏

制作这个编辑器前前后后也有不短的时间了。
特此在cppBlog上申请一块私留地,记述期间的点点滴滴,也不知道什么时候能完成。。。
我期望它能够至少达到以下目标:
1.较低的内存占用(已实现)
2.可扩展的语法渲染(可以采用正则进行更加通用的匹配)(70%)
3.可自定义的键盘(未实现)
4.完全unicode支持和codepage自选择(已实现)
5.可扩展的架构,包含plugin之类的(未实现)
6.对于超大文件的支持(已实现,文件最多和可用内存一般大)
7.同一种字体的多种style支持(未实现,效率上有问题)
暂时我就需要这么多了。

posted @ 2008-03-11 14:34 megax 阅读(759) | 评论 (4)编辑 收藏
仅列出标题
共8页: 1 2 3 4 5 6 7 8