diff options
-rw-r--r-- | plugins/org.eclipse.dltk.sh.ui/plugin.xml | 12 | ||||
-rw-r--r-- | plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java | 20 |
2 files changed, 27 insertions, 5 deletions
diff --git a/plugins/org.eclipse.dltk.sh.ui/plugin.xml b/plugins/org.eclipse.dltk.sh.ui/plugin.xml index b0f844a..26ff717 100644 --- a/plugins/org.eclipse.dltk.sh.ui/plugin.xml +++ b/plugins/org.eclipse.dltk.sh.ui/plugin.xml @@ -200,9 +200,9 @@ </command> <command defaultHandler="org.eclipse.dltk.sh.internal.ui.commands.ShowManHandler" - description="Show man page view" + description="Show command in the man page view" id="org.eclipse.dltk.sh.ui.showman" - name="Show man page"> + name="Show Man Page"> </command> <command defaultHandler="org.eclipse.dltk.sh.internal.ui.commands.AddNature" @@ -286,6 +286,14 @@ </visibleWhen> </command> </menuContribution> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.dltk.sh.ui.editor.EditorContext?after=additions"> + <command + commandId="org.eclipse.dltk.sh.ui.showman" + style="push"> + </command> + </menuContribution> </extension> <extension point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java index 239300e..8787cdb 100644 --- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java +++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/selection/ShellDocumentationProvider.java @@ -30,11 +30,25 @@ public class ShellDocumentationProvider implements IScriptDocumentationProvider if (!helpInfo.isEmpty()) { return new StringReader("<pre>" + helpInfo + "</pre>"); } - String info = new ManPage(content).getStrippedHtmlPage().toString(); - if (info.equals("<pre></pre>")) { + StringBuilder manInfo = new ManPage(content).getStrippedPage(); + if (manInfo.length() == 0) { return null; } - return new StringReader(info); + // Any more than ~10kb and the hover help starts to take a really long time to + // render, so truncate it in that case and advise to use the man page view + final int maxLen = 1024 * 10; + StringBuilder sb = new StringBuilder("<pre>"); + if (manInfo.length() > maxLen) { + sb.append(manInfo.substring(0, maxLen)); + } else { + sb.append(manInfo); + } + sb.append("</pre>"); + if (manInfo.length() > maxLen) { + sb.append( + "<p>This man page is truncated, use <b>Show Man Page</b> (Alt+M) to see the whole page for the selected word.</p>"); + } + return new StringReader(sb.toString()); } private static String getHelp(String command) { |