1
0
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:
Doug Kearns
2007-07-03 05:30:49 +00:00
parent f610861aa2
commit 9f88317a14
5 changed files with 31 additions and 33 deletions

View File

@@ -312,7 +312,19 @@ function Commands() //{{{
}
));
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}"],
short_help: "Go to buffer from buffer list",
@@ -321,7 +333,18 @@ function Commands() //{{{
}
));
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"],
short_help: "Show a list of all buffers (=tabs)",
@@ -1366,31 +1389,6 @@ function tab()
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
function updateBufferList()
{
@@ -1622,7 +1620,7 @@ Vimperator.prototype.source = function(filename, silent)
function getEnv(variable)
{
var environment = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
.getService(Components.interfaces.nsIEnvironment);
return environment.get(variable);
}

View File

@@ -239,7 +239,7 @@ function help(section, easter) //{{{
function findSectionElement(section)
{
return evaluateXPath('//code[@class="tag" and text()="' + section + '"]')
.snapshotItem(0);
.snapshotItem(0);
}
var element = findSectionElement(section);

View File

@@ -220,7 +220,7 @@ function Mappings() //{{{
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["B"],
toggleBufferList,
function() { vimperator.commands.buffers(); },
{
short_help: "Toggle buffer list",
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"],
function(count) { execute_command(count, 'undo', false, ''); },
function(count) { vimperator.commands.undo("", false, count); },
{
short_help: "Undo closing of a tab",
help: "If a count is given, don't close the last but the n'th last tab.",

View File

@@ -88,7 +88,7 @@ function Options() //{{{
/////////////////////////////////////////////////////////////////////////////{{{
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 options = [];

View File

@@ -192,7 +192,7 @@ function Vimperator() //{{{
// our services
var console_service = Components.classes['@mozilla.org/consoleservice;1']
.getService(Components.interfaces.nsIConsoleService);
.getService(Components.interfaces.nsIConsoleService);
function showMode()
{