diff --git a/content/commands.js b/content/commands.js index e31aedfe..c1d63d20 100644 --- a/content/commands.js +++ b/content/commands.js @@ -701,6 +701,26 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["dia[log]"], function (args, special) { + function viewPartialSource() + { + // copied (and tuned somebit) from browser.jar -> nsContextMenu.js + var focusedWindow = document.commandDispatcher.focusedWindow; + if (focusedWindow == window) + focusedWindow = content; + + var docCharset = null; + if (focusedWindow) + docCharset = "charset=" + focusedWindow.document.characterSet; + + var reference = null; + reference = focusedWindow.getSelection(); + + var docUrl = null; + window.openDialog("chrome://global/content/viewPartialSource.xul", + "_blank", "scrollbars,resizable,chrome,dialog=no", + docUrl, docCharset, reference, "selection"); + } + try { switch (args) @@ -728,7 +748,7 @@ vimperator.Commands = function () //{{{ case "saveframe": saveFrameDocument(); break; case "savepage": saveDocument(window.content.document); break; case "searchengines": openDialog("chrome://browser/content/search/engineManager.xul", "_blank", "chrome,dialog,modal,centerscreen"); break; - // TODO add viewPartialSource('selection'); ... + case "selectionsource": viewPartialSource(); break; case "": vimperator.echoerr("E474: Invalid argument"); break; default: vimperator.echoerr("Dialog '" + args + "' not available"); } diff --git a/content/completion.js b/content/completion.js index 8146a88f..133a953c 100644 --- a/content/completion.js +++ b/content/completion.js @@ -171,7 +171,8 @@ vimperator.Completion = function () //{{{ ["print", "Show print dialog"], ["saveframe", "Save frame to disk"], ["savepage", "Save page to disk"], - ["searchengines", "Manage installed search engines"] + ["searchengines", "Manage installed search engines"], + ["selectionsource", "View selection source"] ]; if (!filter)