jedit的ANSI C/STL/LinuxAPI/JavaScript函数帮助插件

12 views
Skip to first unread message

pi1ot

unread,
Sep 1, 2009, 2:49:31 AM9/1/09
to jEdit中文用户组
本人收集了C标准库、Linux调用库、C++ STL和JavaScript的Core与DOM函数库的全部帮助信息,制作了以下帮助文件包和可用于
jEdit的自动显示帮助插件

Glibc(C标准库)和Linux调用函数参考下载自linux man-pages项目
http://www.kernel.org/doc/man-pages

C++ STL参考下载自apache stdcxx项目
http://stdcxx.apache.org/doc/stdlibref/index.html

JavaScript的Core与DOM函数参考是从最新的第五版《JavaScript权威指南》电子书的Reference部分导出为HTML文件
后使用脚本逐个重命名文件然后打包的

以上C/C++/JS参考帮助文件可从这个地址下载,每个C函数或者Linux调用或者JS函数都是一个单独的以函数名命名的HTML文件,C++
STL以容器名和算法函数名为每个文件名
http://218.30.115.70/files/manpage.zip

你可以直接手工浏览以上帮助,也可以用在你的编辑器/IDE中,另外我写了可用于jEdit的macro,这样在jEdit中可以将光标定位到具体函数
和容器上后按下热键(shortcut)后即可根据所编辑文件类型(C/C++/JS或者HTML),自动定位和显示所查阅函数的帮助信息

macro代码:

1.////////////////////////////////////////////////////////////////////////////////
2.String ref_c = "..\\..\\manpage\\pages\\man"; // man{i}/{keyword}.
{i}.html
3.String ref_cpp = "..\\..\\manpage\\stdcxx\\"; //
{keyword}.html
4.String ref_js = "..\\..\\manpage\\jsref\\"; //
{keyword}.html
5.
6.////////////////////////////////////////////////////////////////////////////////
7.Boolean fileExists( String file ) {
8. File fp = new File( file );
9. return fp.exists();
10.}
11.String openHelp( String htmlFile ) {
12. if ( fileExists(htmlFile) ) {
13. HelpViewer browser = new HelpViewer();
14. browser.gotoURL( htmlFile, false, 0 );
15. }
16. return htmlFile;
17.}
18.
19.////////////////////////////////////////////////////////////////////////////////
20.String keyWord = textArea.getSelectedText();
21.if ( (keyWord == null) || (keyWord.length() == 0) ) {
22. textArea.selectWord();
23. keyWord = textArea.getSelectedText();
24.}
25.if ( (keyWord == null) || (keyWord.length() == 0) ) {
26. keyWord = Macros.input( view, "reference to find:" );
27.}
28.
29.////////////////////////////////////////////////////////////////////////////////
30.if ( (keyWord != null) && (keyWord.length() > 0) ) {
31. String htmlFile = "";
32. String editMode = buffer.getMode().toString();
33.
34. ////////////////////////////////////////////////////////////////////////////
35. // javascript reference
36. if ( editMode.equals("javascript") || editMode.equals("html") )
{
37. File refpath = new File( ref_js );
38. File[] files = refpath.listFiles();
39. for ( var i=0; i<files.length; ++i ) {
40. htmlFile = files[i].getPath();
41. if ( htmlFile.indexOf(keyWord+".html") != -1 ) {
42. openHelp( htmlFile );
43. }
44. }
45. return;
46. }
47.
48. ////////////////////////////////////////////////////////////////////////////
49. // apache stdcxx reference
50. if ( editMode.equals("c++") ) {
51. String cppWord = keyWord.replaceAll( "_", "-" );
52. htmlFile = ref_cpp + cppWord + ".html";
53. if ( fileExists(htmlFile) ) {
54. openHelp( htmlFile );
55. return;
56. }
57. }
58.
59. ////////////////////////////////////////////////////////////////////////////
60. // linux man-pages
61. for ( var i=1; i<=8; ++i ) {
62. htmlFile = ref_c + i + "\\" + keyWord + "." + i +
".html";
63. if ( fileExists(htmlFile) ) {
64. openHelp( htmlFile );
65. return;
66. }
67. }
68.
69. Macros.message( view, keyWord + " reference not found" );
70.}
////////////////////////////////////////////////////////////////////////////////
String ref_c = "..\\..\\manpage\\pages\\man"; // man{i}/{keyword}.
{i}.html
String ref_cpp = "..\\..\\manpage\\stdcxx\\"; // {keyword}.html
String ref_js = "..\\..\\manpage\\jsref\\"; // {keyword}.html

////////////////////////////////////////////////////////////////////////////////
Boolean fileExists( String file ) {
File fp = new File( file );
return fp.exists();
}
String openHelp( String htmlFile ) {
if ( fileExists(htmlFile) ) {
HelpViewer browser = new HelpViewer();
browser.gotoURL( htmlFile, false, 0 );
}
return htmlFile;
}

////////////////////////////////////////////////////////////////////////////////
String keyWord = textArea.getSelectedText();
if ( (keyWord == null) || (keyWord.length() == 0) ) {
textArea.selectWord();
keyWord = textArea.getSelectedText();
}
if ( (keyWord == null) || (keyWord.length() == 0) ) {
keyWord = Macros.input( view, "reference to find:" );
}

////////////////////////////////////////////////////////////////////////////////
if ( (keyWord != null) && (keyWord.length() > 0) ) {
String htmlFile = "";
String editMode = buffer.getMode().toString();

////////////////////////////////////////////////////////////////////////////
// javascript reference
if ( editMode.equals("javascript") || editMode.equals("html") ) {
File refpath = new File( ref_js );
File[] files = refpath.listFiles();
for ( var i=0; i<files.length; ++i ) {
htmlFile = files[i].getPath();
if ( htmlFile.indexOf(keyWord+".html") != -1 ) {
openHelp( htmlFile );
}
}
return;
}

////////////////////////////////////////////////////////////////////////////
// apache stdcxx reference
if ( editMode.equals("c++") ) {
String cppWord = keyWord.replaceAll( "_", "-" );
htmlFile = ref_cpp + cppWord + ".html";
if ( fileExists(htmlFile) ) {
openHelp( htmlFile );
return;
}
}

////////////////////////////////////////////////////////////////////////////
// linux man-pages
for ( var i=1; i<=8; ++i ) {
htmlFile = ref_c + i + "\\" + keyWord + "." + i + ".html";
if ( fileExists(htmlFile) ) {
openHelp( htmlFile );
return;
}
}

Macros.message( view, keyWord + " reference not found" );
}

查阅C函数定义
http://www.javaeye.com/upload/attachment/138184/bb7e4d2d-5517-36bb-ad97-5424d765ccf1.png

查阅STL帮助
http://www.javaeye.com/upload/attachment/138186/9d52a350-9129-355b-afc4-9cdaf26a707e.png

查阅JS函数定义
http://www.javaeye.com/upload/attachment/138188/5e4ebf90-154b-309f-bf19-5fed084d03f1.png
Reply all
Reply to author
Forward
0 new messages