-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathDocumentation for Word.tmCommand
More file actions
99 lines (95 loc) · 3.19 KB
/
Documentation for Word.tmCommand
File metadata and controls
99 lines (95 loc) · 3.19 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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundlePath</key>
<string>/Users/kumar/Library/Application Support/TextMate/Bundles/Custom.tmbundle</string>
<key>command</key>
<string>#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
term=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD}
if grep <<<${term} -Esq '^[a-zA-Z0-9_]+$'
then
if URL=`grep -i "^$TM_CURRENT_WORD=" "$TM_BUNDLE_SUPPORT/documentation.txt"`
then
URL=${URL:${#term}+1}
else
URL="function.${term//_/-}"
fi
if [[ "$PHP_MANUAL_LOCATION" ]]
then
if [[ ! -d "$PHP_MANUAL_LOCATION" ]]
then
exit_show_tool_tip "Your PHP_MANUAL_LOCATION directory ($PHP_MANUAL_LOCATION) does not exist. See the bundle Help for setup instructions."
fi
if [[ ! -f "$PHP_MANUAL_LOCATION/$URL.html" ]]
then
exit_show_tool_tip "No documentation found for '$term'"
fi
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "PHP Help" "${TM_FILENAME:-}"
cat <<-'HTML'
<script type="text/javascript" charset="utf-8">
function jump(page) {
TextMate.isBusy = true;
res = TextMate.system('cat "$PHP_MANUAL_LOCATION"/' + page, null).outputString;
document.getElementById('php_help').innerHTML = res;
TextMate.isBusy = false;
setupLinks();
historyList = document.getElementById('history_list');
TextMate.log(historyList);
item = document.createElement('option');
TextMate.log(item);
item.value = page;
TextMate.log(page);
item.innerText = res.match(/>(.+?)<\/TITLE/i)[1];
historyList.appendChild(item);
item.selected = true;
}
function setupLinks() {
var link, links = document.links;
for (i = 0; i < links.length; i++) {
link = links[i];
if (matches = link.href.match(/^x-txmt-command:.+\/(.+.html)$/)) {
link.href = 'javascript:jump("' + matches[1] + '")';
}
}
}
</script>
HTML
echo '<select id="history_list" onchange="jump(this.options[this.selectedIndex].value)"></select>'
echo '<div id="php_help"></div>'
echo '<script>jump("'"$URL"'.html");</script>'
html_footer
exit_show_html
else URL="http://php.net/manual/en/$URL.php"
fi
exit_show_html "<meta http-equiv='Refresh' content='0;URL=$URL'>"
else echo "Nothing to lookup (hint: place the caret on a function name)"
fi</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^h</string>
<key>name</key>
<string>Documentation for Word</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>toolTip</string>
<key>scope</key>
<string>source.php</string>
<key>semanticClass</key>
<string>lookup.define.php</string>
<key>uuid</key>
<string>412481DC-89B7-11D9-9FE3-000A9584EC8C</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>