悲情土仔一生

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  14 随笔 :: 0 文章 :: 74 评论 :: 0 Trackbacks

让UltraEdit完美支持Lua语法

作者:Tuuzed(土仔)   发表于:2008年12月27日
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明
http://www.cppblog.com/tuuzed/archive/2008/12/27/70516.html




     最近在研究Lua脚本语言(个人觉得它是Basic、C、C++的结合体),可是“强大”的UltraEdit默认安装后是不支持Lua语法高亮显示的,满屏幕“黑黑”的鸡肠字符让人感觉编程是那么的索然无味,没有了灵感。
     终于有一天GOOGLE了一下,发现了很多解决办法,最好的办法就是:先去UltraEdit的官网下载支持Lua的Wordfiles文件(这里),是个文本文件(lua.txt)。打开UltraEdit安装目录下的wordfile.txt,把lua.txt文件中的内容拷贝粘贴到wordfile.txt的末尾,存盘,OK,于是UltraEdit语法高亮项多出Lua一项,可以选择使用了。比起网上说的02年版的lua.txt,这个04版(也是很旧)已经完美支持“注释块”和“注释行”高亮了,所以无需在改它的第一行。
     但是,使用一段时间后,还是发现有问题,比如:有部分关键字没有加亮(如:os,pair, ipair等);不支持代码折叠(不能很好地知道结束关键字end是属于哪个while、for、function等);对UltraEdit的F8(函数列表)功能支持得不完美。还好,看了UltraEdit帮助后,自己修改了一下,解决了上述问题,下面就贴出我的lua.txt在这里下载修改后的Lua.txt

 1 /L20"Lua" Line Comment = -- Block Comment On = [[ Block Comment Off = ]] String Chars = "' Escape Char = \ File Extensions = LUA BIN
 2 /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> ,    .?
 3 /Function String 1 = "function[ ]++[a-zA-Z]*)"
 4 /Function String 2 = "function[ ]++([ a-zA-Z]*)"
 5 /Open Fold Strings = "function" "if" "while" "for"
 6 /Close Fold Strings = "end"
 7 /C1 "key words"
 8 and
 9 break
10 do
11 else 
12 elseif 
13 end
14 function
15 if in
16 local
17 nil not
18 or
19 repeat return
20 then
21 until
22 while
23 /C2
24 abs acos appendto ascii asin assert atan atan2
25 call ceil clock collectgarbage copytagmethods cos
26 date deg dofile dostring
27 error execute exit
28 false find floor foreach foreachvar format frexp
29 getbinmethod getenv getglobal gettagmethod gfind gmatch gsub
30 insert ipairs
31 ldexp log log10
32 match max min mod
33 newtag next nextvar
34 os
35 pairs print
36 rad random randomseed rawgetglobal rawgettable rawsetglobal rawsettable read
37 readfrom remove rename
38 seterrormethod setglobal setlocale settag settagmethod sin sqrt strbyte sub
39 strchar strfind string strlen strlower strrep strsub strupper
40 table tag tan tmpname tonumber tostring true type
41 write writeto
42 /C3
43 $debug
44 $else
45 $end
46 $endinput
47 $if
48 $ifnot
49 $nodebug
50 /C4
51 PI
52 _INPUT _OUTPUT _STDERR _STDIN _STDOUT
53 /C5
54 +
55 -
56 *
57 // /
58 ^
59 <
60 >
61 =
62 ~
63 %
64 .
65 :
66 /C6
67 ;
68 ,
69 (
70 )
71 {
72 }
73 [
74 ]
75 /C7
76 cgi cgilua cgilua_url char2hexa chdir
77 dbluaerrorfb dblua_escape decode default_script
78 encodecgi encodetable escape
79 filetype
80 getvalue
81 hexa hexa2char html_mask
82 includehtml insertfield
83 lua_mask
84 maketable map mkurl
85 nopipe
86 preprocess
87 redirect relativeurl relative_url
88 saveluavar savestate script_path script_pdir script_vdir stateerrormethod
89 statefile stdin strsplit
90 unescape
91 /C8
92 DBClose DBExec DBOpen DBRow

    
     支持UltraEdit的F8(函数列表)功能的是3、4行;支持代码折叠的是5、6行;增加了部分关键字(io,pair,ipair等),但还不完整,可以根据以后编程需要自己再添加,添加时一定要按字母排列顺序“插”对位置!


posted on 2008-12-27 17:19 土仔 阅读(7743) 评论(5)  编辑 收藏 引用 所属分类: 土仔编程

评论

# re: 让UltraEdit完美支持Lua语法 2008-12-27 22:34 5193
转载文章的时候需要加版权...

顺便问一句
你的ultraedit有版权么...  回复  更多评论
  

# re: 让UltraEdit完美支持Lua语法 2008-12-28 10:03 土仔
@5193
回答问题:此文章为原创;UltraEdit是公司买的license。  回复  更多评论
  

# re: 让UltraEdit完美支持Lua语法 2008-12-28 13:14 Xw.Y
支持原创
支持正版

可惜偶等穷人只能用emacs……  回复  更多评论
  

# re: 让UltraEdit完美支持Lua语法[未登录] 2009-01-30 15:35 Betty
非常感谢,很有用~~  回复  更多评论
  

# re: 让UltraEdit完美支持Lua语法[未登录] 2011-10-06 09:58 阿炳
棒棒的,赞一个,已经使用中  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理