-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMan_Page.bsh
More file actions
102 lines (88 loc) · 3.25 KB
/
Man_Page.bsh
File metadata and controls
102 lines (88 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
////////////////////////////////////////////////////////////////////////////////
// base path: /Applications/Develop/jEdit.app/Contents/Resources/Java/doc
String base = "../../../../../../..";
String ref_c = base+"/Users/pi1ot/Documents/TechDocs/manpage/pages/man"; // man{i}/{keyword}.{i}.html
// or http://man7.org/linux/man-pages/man{i}/{keyword}.{i}.html
String ref_cpp = base+"/Users/pi1ot/Documents/TechDocs/manpage/stdcxx/"; // {keyword}.html
// or http://stdcxx.apache.org/doc/stdlibref/{keyword}.html
String ref_pl = base+"/Users/pi1ot/Documents/TechDocs/manpage/perlfunc/"; // {keyword}.html
// or http://perldoc.perl.org/functions/{keyword}.html
String ref_js = base+"/Users/pi1ot/Documents/TechDocs/manpage/jsref/"; // {keyword}.html
String ref_py = "http://docs.python.org/search.html?q="; // {keyword}
////////////////////////////////////////////////////////////////////////////////
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() <= 1) ) {
keyWord = Macros.input( view, "reference to find:" );
}
////////////////////////////////////////////////////////////////////////////////
if ( (keyWord != null) && (keyWord.length() > 0) ) {
openHelp( "http://www.baidu.com" );
String htmlFile = "";
String editMode = buffer.getMode().toString();
////////////////////////////////////////////////////////////////////////////
// python reference
if ( editMode.equals("python") ) {
Url = ref_py + keyWord;
infoviewer.InfoViewerPlugin.openURL( view, Url );
return;
}
////////////////////////////////////////////////////////////////////////////
// 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;
}
////////////////////////////////////////////////////////////////////////////
// perl doc functions
if ( editMode.equals("perl") ) {
htmlFile = ref_pl + keyWord + ".html";
if ( fileExists(htmlFile) ) {
openHelp( htmlFile );
return;
}
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" );
}