posts - 11,  comments - 93,  trackbacks - 0
  2009年3月7日
     摘要: 代码折叠这个功能,我最早是在Dreamweaver里面看到的,具体哪个版本记不清了,好多年了。

当时DM的实现是当你选择文本的时候,在编辑器的左侧,有一个折叠的提示,提示你可以把选中的

文本折叠起来。那个时候觉得这个功能,毫无用处。不过自从VisualStudio2003以来,代码折叠

这个功能几乎成为了程序员的必备。

的确,在浏览代码的时候,代码折叠可以带来一些好处,让重点凸显在用户的面前,或者可以拉近两块

相隔很远的代码,实现比较。当然,这个也完全可以通过分割视图完成。

在众多的编辑器当中,我认为单纯就代码折叠而言,目前实现的最好的还是VisualStudio,它

可以根据语言上下文的关系,即语法,进行代码折叠,这是其它编辑器无法企及的。当然,它本身也是

一个重量级的IDE,超出了简单编辑器的范畴。

本文试图描述代码折叠最基本的思路,没有具体的代码。其实这个功能并不难实现,相反很简单。

  阅读全文
posted @ 2009-03-07 16:07 megax 阅读(1227) | 评论 (10)编辑 收藏
  2009年2月25日
     摘要: 【因工作原因,好久不更新了,向各位关心的朋友说声道歉】

去年的某一天,对MegaxEdit进行了整理,因最后MFC静态编译出来的东西较大,遂萌生往WTL转移的想法。

前前后后花了很长事件移植完毕,与其说是移植,倒不如说是重写。

现在编译出来只有300K左右,压缩一下,100多K,挺小巧。

最近反复在想,我为什么做这个东西?最后的答案是:兴趣。  阅读全文
posted @ 2009-02-25 19:39 megax 阅读(1537) | 评论 (20)编辑 收藏
  2008年8月8日
     摘要: 今天在csdn上看了一篇文章,叫做《到底是该做windows还是linux程序员?》。很显然这是一个欲从事IT行业的新人所发的帖子。csdn也经营了这么多年了,按理说高人该不少。但是看看回复,确实让人觉得很可笑。  阅读全文
posted @ 2008-08-08 13:59 megax 阅读(2753) | 评论 (34)编辑 收藏
  2008年8月1日

这阵子把代码内核重新构造一遍,不过外围的代码还是耦合度比较高。有机会好好考虑考虑。

添加了一个CmdBar,打算集成一些常用的命令,比如cmd啊,grep啊,sort工具之类的,像vi那样,敲击代码调用一些命令

查找方面,反向查找还没有做,看来我得自己写了,比较熟悉kmp算法,就打算用这个了。不过比较奇怪的是c函数库带的strstr效率竟然比

kmp和BM算法的都快。

发个截图作个纪念。


posted @ 2008-08-01 17:28 megax 阅读(267) | 评论 (16)编辑 收藏
  2008年7月9日
     摘要: 编辑器制作之语法加亮基本原理在上一篇文章里,我简单的提及了语法加亮的基本思路,下面在总结概括一下。

笔者认为,对于编辑器而言,如果支持非常严格的语法加亮的话,那么扩展性是很低的。那么在扩展性和正确性之间,我们应该取得一个平衡。这个平衡就是既要保证编辑器的高效率运转,又要保持文本配置文件的可编辑性。

首先,几乎所有的编程语言都具有某种共性,这些共性概括如下:
1.关键字
2.注释
3.字符串
4.Delimiters
5.普通字符

详细....  阅读全文
posted @ 2008-07-09 20:23 megax 阅读(1270) | 评论 (4)编辑 收藏
  2008年6月23日

终于忍不住了,要为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 阅读(1442) | 评论 (4)编辑 收藏
  2008年6月21日
今天在网上搜索自动机的文章的时候发现了一个和我想法差不多的人,他提到了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 阅读(129) | 评论 (1)编辑 收藏
  2008年6月8日
今天头好疼,睡到12点。。。
添加了MDI的拖放支持,并且根据不同的FileType显示不同的图标。
都是一些小细节,最近身体不好,有空了,在把core部分好好更新一下。

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


posted @ 2008-05-31 23:21 megax 阅读(116) | 评论 (0)编辑 收藏
仅列出标题  下一页