标题: 求对一个EmEditor 宏 精简,求高手啊 [打印本页]

作者: powerwrf    时间: 2012-12-7 00:37
标题: 求对一个EmEditor 宏 精简,求高手啊
求一个EmEditor 宏
拿别人的剪切的的精简代码
现在想不要弹菜单,直接点击运行,求精简


[attach]73693[/attach]

不要弹菜单,直接运行!


代码:
menu= CreatePopupMenu();

[/table]
if (document.selection.isempty)
nFlags=eeFindNext eeReplaceAll eeFindReplaceRegExp;
else
nFlags=eeFindNext eeReplaceSelOnly eeReplaceAll eeFindReplaceRegExp;
menu.Add( "半角标点→全角", 1);
result = menu.Track( 0 );
if (result>40) nFlags=nFlags=eeFindNext eeReplaceAll eeFindReplaceRegExp;
switch(result){
case 1: //半角标点符号 → 全角标点符号
//alert( "引号部分的转换可能存在错误,脚本运行完毕后,会以绿色标示出来,请手动修改。");
//        document.selection.Replace(",",",",eeFindNext eeReplaceAll);
//        document.selection.Replace(".","。",eeFindNext eeReplaceAll);
document.selection.Replace("([0-9]),([0-9]{3})","\\1,\\2",nFlags);
document.selection.Replace("([0-9])。([0-9])","\\1\\.\\2",nFlags);
document.selection.Replace("?","?",eeFindNext eeReplaceAll);
document.selection.Replace("!","!",eeFindNext eeReplaceAll);
document.selection.Replace(":",":",eeFindNext eeReplaceAll);
document.selection.Replace(";",";",eeFindNext eeReplaceAll);
document.selection.Replace("(","(",eeFindNext eeReplaceAll);
document.selection.Replace(")",")",eeFindNext eeReplaceAll);
document.selection.Replace("┅","…",eeFindNext eeReplaceAll);
document.selection.Replace("@","@",eeFindNext eeReplaceAll);
document.selection.Replace("#","#",eeFindNext eeReplaceAll);
document.selection.Replace("%","%",eeFindNext eeReplaceAll);
//        document.selection.Replace("<","《",eeFindNext eeReplaceAll);
//        document.selection.Replace(">","》",eeFindNext eeReplaceAll);
//        document.selection.Replace("<","《",eeFindNext eeReplaceAll);
//        document.selection.Replace(">","》",eeFindNext eeReplaceAll);
document.selection.Replace("~","~",eeFindNext eeReplaceAll);
document.selection.Replace("^","^",eeFindNext eeReplaceAll);
document.selection.Replace("&","&",eeFindNext eeReplaceAll);
[table=100%,#f2f2f2]                        document.selection.Replace("([: ])\x22","\\1“",eeFindNext eeReplaceAll)//x22为引号

document.selection.Replace("(。…)\x22","\\1”",eeFindNext eeFindReplaceEscSeq eeReplaceAll eeFindReplaceRegExp);

document.selection.Replace("\x22$","”",eeFindNext eeFindReplaceEscSeq eeReplaceAll eeFindReplaceRegExp);

document.selection.Replace("\x22","“",eeFindNext eeReplaceAll);

document.selection.Replace("“([^”]*)$\
^\\s*([^“]*)”","“\\1\\2”",nFlags);

document.selection.Find("“[^”]*“”[^“]*”^[^“]*”“[^”]*$‘[^’]*$^[^‘]*'‘[^’]*‘’[^‘]*’",eeFindNext eeFindReplaceRegExp);

break;

default:

}


[attach]73694[/attach]
作者: 晓月黄昏    时间: 2012-12-7 01:42
var nFlags = eeFindNext eeReplaceAll eeFindReplaceRegExp;

document.selection.Replace(",",",",eeFindNext eeReplaceAll);//表示数量时应用半角,如$1,000,000。下一个语句做出了修改
   document.selection.Replace("([0-9]),([0-9]{3})","
\\\\1,\\\\2",nFlags
);

document.selection.Replace("([0-9])。([0-9])","
\\\\1\\\\.\\\\2",nFlags
);
   document.selection.Replace("?","?",eeFindNext eeReplaceAll);//此处替换可能会有错
   document.selection.Replace("!","!",eeFindNext eeReplaceAll);

document.selection.Replace(":",":",eeFindNext eeReplaceAll);//表示时刻时应用半角,如9:00,下一个语句做出了修改
   document.selection.Replace("([0-9]):([0-9])","
\\\\1:\\\\2",nFlags
);

document.selection.Replace(";",";",eeFindNext eeReplaceAll);
   document.selection.Replace("(","(",eeFindNext eeReplaceAll);
   document.selection.Replace(")",")",eeFindNext eeReplaceAll);
   document.selection.Replace("~","~",eeFindNext eeReplaceAll);

//引号部分的转换可能存在错误,脚本运行完毕后,会以绿色标示出来,请手动修改。
   document.selection.Replace("([: ])\\x22","
\\\\1“",eeFindNext
eeReplaceAll)//x22为引号
   document.selection.Replace("(。…)\\x22","
\\\\1”",eeFindNext
eeFindReplaceEscSeq eeReplaceAll eeFindReplaceRegExp);
   document.selection.Replace("\\x22$","”",eeFindNext eeFindReplaceEscSeq eeReplaceAll eeFindReplaceRegExp);
   document.selection.Replace("\\x22","“",eeFindNext eeReplaceAll);
   document.selection.Replace("“([^”]*)$\\\
^\\\\s*([^“]*)”","“\\\\1\\\\2”",nFlags);
   document.selection.Find("“[^”]*“”[^“]*”^[^“]*”“[^”]*$‘[^’]*$^[^‘]*'‘[^’]*‘’[^‘]*’",eeFindNext eeFindReplaceRegExp);



你的脚本有些替换是不科学的,把内容稍微删减了下,另将一些建议添加进了注释。

那个替换引号的语句感觉没写的必要,这个功能很难完全靠脚本很保险地实现,不过没有删。。。
作者: g372145    时间: 2012-12-7 09:33
偶只能说:关注一下了
作者: powerwrf    时间: 2012-12-7 11:30
标题: 回 1楼(晓月黄昏) 的帖子
真心谢了,我觉得现在好用多了哈




欢迎光临 (https://imap.zazww.com/~zazww/) Powered by Discuz! X3.2