mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 22:17:59 +01:00
move buffer_switch and toggleBufferList to the :buffer and :buffers
ex-commands; make the "u" normal mode command call vimperator.commands.undo rather than execute_command() directly
This commit is contained in:
@@ -312,7 +312,19 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["b[uffer]"],
|
addDefaultCommand(new Command(["b[uffer]"],
|
||||||
buffer_switch,
|
// TODO: move to v.tabs/buffers
|
||||||
|
function(args)
|
||||||
|
{
|
||||||
|
var match;
|
||||||
|
if (match = args.match(/^(\d+):?/))
|
||||||
|
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
|
||||||
|
for (var i = 0; i < getBrowser().browsers.length; i++)
|
||||||
|
{
|
||||||
|
var url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
|
||||||
|
if (url == args)
|
||||||
|
return vimperator.tabs.select(i, false);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
usage: ["b[uffer] {url|index}"],
|
usage: ["b[uffer] {url|index}"],
|
||||||
short_help: "Go to buffer from buffer list",
|
short_help: "Go to buffer from buffer list",
|
||||||
@@ -321,7 +333,18 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["buffers", "files", "ls", "tabs"],
|
addDefaultCommand(new Command(["buffers", "files", "ls", "tabs"],
|
||||||
toggleBufferList,
|
// TODO: move to v.tabs/buffers
|
||||||
|
function()
|
||||||
|
{
|
||||||
|
if (vimperator.bufferwindow.visible())
|
||||||
|
vimperator.bufferwindow.hide();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var items = get_buffer_completions("");
|
||||||
|
vimperator.bufferwindow.show(items);
|
||||||
|
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
usage: ["buffers"],
|
usage: ["buffers"],
|
||||||
short_help: "Show a list of all buffers (=tabs)",
|
short_help: "Show a list of all buffers (=tabs)",
|
||||||
@@ -1366,31 +1389,6 @@ function tab()
|
|||||||
execute(arguments[0], null, null, {inTab: true});
|
execute(arguments[0], null, null, {inTab: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buffer_switch(string)
|
|
||||||
{
|
|
||||||
var match;
|
|
||||||
if (match = string.match(/^(\d+):?/))
|
|
||||||
return vimperator.tabs.select(parseInt(match[1]) - 1, false); // make it zero-based
|
|
||||||
for (var i = 0; i < getBrowser().browsers.length; i++)
|
|
||||||
{
|
|
||||||
var url = getBrowser().getBrowserAtIndex(i).contentDocument.location.href;
|
|
||||||
if (url == string)
|
|
||||||
return vimperator.tabs.select(i, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//toggles the buffer preview window
|
|
||||||
function toggleBufferList()
|
|
||||||
{
|
|
||||||
if (vimperator.bufferwindow.visible())
|
|
||||||
vimperator.bufferwindow.hide();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var items = get_buffer_completions("");
|
|
||||||
vimperator.bufferwindow.show(items);
|
|
||||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// updates the buffer preview in place only if list is visible
|
// updates the buffer preview in place only if list is visible
|
||||||
function updateBufferList()
|
function updateBufferList()
|
||||||
{
|
{
|
||||||
@@ -1622,7 +1620,7 @@ Vimperator.prototype.source = function(filename, silent)
|
|||||||
function getEnv(variable)
|
function getEnv(variable)
|
||||||
{
|
{
|
||||||
var environment = Components.classes["@mozilla.org/process/environment;1"]
|
var environment = Components.classes["@mozilla.org/process/environment;1"]
|
||||||
.getService(Components.interfaces.nsIEnvironment);
|
.getService(Components.interfaces.nsIEnvironment);
|
||||||
return environment.get(variable);
|
return environment.get(variable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ function help(section, easter) //{{{
|
|||||||
function findSectionElement(section)
|
function findSectionElement(section)
|
||||||
{
|
{
|
||||||
return evaluateXPath('//code[@class="tag" and text()="' + section + '"]')
|
return evaluateXPath('//code[@class="tag" and text()="' + section + '"]')
|
||||||
.snapshotItem(0);
|
.snapshotItem(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var element = findSectionElement(section);
|
var element = findSectionElement(section);
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["B"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["B"],
|
||||||
toggleBufferList,
|
function() { vimperator.commands.buffers(); },
|
||||||
{
|
{
|
||||||
short_help: "Toggle buffer list",
|
short_help: "Toggle buffer list",
|
||||||
help: "Toggles the display of the buffer list which shows all opened tabs."
|
help: "Toggles the display of the buffer list which shows all opened tabs."
|
||||||
@@ -402,7 +402,7 @@ function Mappings() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["u"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["u"],
|
||||||
function(count) { execute_command(count, 'undo', false, ''); },
|
function(count) { vimperator.commands.undo("", false, count); },
|
||||||
{
|
{
|
||||||
short_help: "Undo closing of a tab",
|
short_help: "Undo closing of a tab",
|
||||||
help: "If a count is given, don't close the last but the n'th last tab.",
|
help: "If a count is given, don't close the last but the n'th last tab.",
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function Options() //{{{
|
|||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
var firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
var firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefBranch);
|
.getService(Components.interfaces.nsIPrefBranch);
|
||||||
var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator.");
|
var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator.");
|
||||||
var options = [];
|
var options = [];
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ function Vimperator() //{{{
|
|||||||
|
|
||||||
// our services
|
// our services
|
||||||
var console_service = Components.classes['@mozilla.org/consoleservice;1']
|
var console_service = Components.classes['@mozilla.org/consoleservice;1']
|
||||||
.getService(Components.interfaces.nsIConsoleService);
|
.getService(Components.interfaces.nsIConsoleService);
|
||||||
|
|
||||||
function showMode()
|
function showMode()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user