1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 01:14:12 +01:00

new gf gF and :viewsource commands (thanks dpb)

This commit is contained in:
Martin Stubenschrott
2008-01-03 11:39:40 +00:00
parent c0d333629e
commit 5ea202647b
7 changed files with 58 additions and 6 deletions

View File

@@ -2517,6 +2517,39 @@ vimperator.Commands = function () //{{{
help: "You can show the Firefox version page with <code class=\"command\">:version!</code>."
}
));
commandManager.add(new vimperator.Command(["vie[wsource]"],
function (args, special)
{
var url = args || vimperator.buffer.URL;
if (special) // internal editor
{
vimperator.open("view-source:" + url)
}
else
{
// TODO: make that a helper function
// TODO: save return value in v:shell_error
var newThread = Components.classes["@mozilla.org/thread-manager;1"].getService().newThread(0);
var editor = vimperator.options["editor"];
var args = editor.split(" "); // FIXME: too simple
if (args.length < 1)
{
vimperator.open("view-source:" + url)
vimperator.echoerr("no editor specified");
return;
}
var prog = args.shift();
args.push(url)
vimperator.callFunctionInThread(newThread, vimperator.run, [prog, args, true]);
}
},
{
usage: ["vie[wsource][!] [url]"],
shortHelp: "View source code of current document",
help: "When ! is given, it is opened with the internal editor, otherwise with the external."
}
));
commandManager.add(new vimperator.Command(["viu[sage]"],
function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
{

View File

@@ -329,8 +329,7 @@ vimperator.Editor = function () //{{{
{
var textBox = document.commandDispatcher.focusedElement;
var editor = vimperator.options["editor"];
var args = [];
args = editor.split(" ");
var args = editor.split(" ");
if (args.length < 1)
{
vimperator.echoerr("no editor specified");

View File

@@ -440,6 +440,8 @@ vimperator.Hints = function () //{{{
case "O": vimperator.commandline.open(":", "open " + loc, vimperator.modes.EX); break;
case "t": openHint(vimperator.NEW_TAB); break;
case "T": vimperator.commandline.open(":", "tabopen " + loc, vimperator.modes.EX); break;
case "v": vimperator.commands.viewsource(loc); break;
case "V": vimperator.commands.viewsource(loc, true); break;
case "w": openHint(vimperator.NEW_WINDOW); break;
case "W": vimperator.commandline.open(":", "winopen " + loc, vimperator.modes.EX); break;
case "y": yankHint(false); break;
@@ -491,7 +493,7 @@ vimperator.Hints = function () //{{{
// TODO: implement framesets
show: function (mode, minor, filter)
{
if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTwWyY]$/.test(minor))
if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTvVwWyY]$/.test(minor))
{
vimperator.beep();
return;

View File

@@ -567,6 +567,22 @@ vimperator.Mappings = function () //{{{
help: "You can also use the hints to create the probably fastest file browser on earth."
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gf"],
function () { vimperator.commands.viewsource(); },
{
shortHelp: "View source",
help: "Opens the source code of the current website with the external editor specified " +
"by the <code class='option'>'editor'</code> option. For now the external editor " +
"must be able to download and open files from a remote URL."
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gF"],
function () { vimperator.commands.viewsource(null, true); },
{
shortHelp: "View source in current tab",
help: "Opens the source code of the current website with the internal editor."
}
));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gh"],
BrowserHome,
{
@@ -1244,6 +1260,7 @@ vimperator.Mappings = function () //{{{
"<li><code class=\"mapping\">t</code> to open its location in a new tab</li>" +
"<li><code class=\"mapping\">O</code> to open its location in an <code class=\"command\">:open</code> query</li>" +
"<li><code class=\"mapping\">T</code> to open its location in a <code class=\"command\">:tabopen</code> query</li>" +
"<li><code class=\"mapping\">v</code> to view its destination source</li>" +
"<li><code class=\"mapping\">w</code> to open its destination in a new window</li>" +
"<li><code class=\"mapping\">W</code> to open its location in a <code class=\"command\">:winopen</code> query</li>" +
"<li><code class=\"mapping\">y</code> to yank its location</li>" +