1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:38:00 +01:00

Add [c]:toolbaropen[c], [c]:toolbarclose[c], and [c]:toolbartoggle[c].

This commit is contained in:
Kris Maglione
2009-07-21 22:18:15 -04:00
parent a7de8b8cd0
commit 842dd61f4c
5 changed files with 71 additions and 1 deletions

View File

@@ -321,6 +321,8 @@ const liberator = (function () //{{{
////////////////////// COMMANDS //////////////////////////////////////////////// ////////////////////// COMMANDS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var toolbox;
registerObserver("load_commands", function () { registerObserver("load_commands", function () {
commands.add(["addo[ns]"], commands.add(["addo[ns]"],
@@ -644,6 +646,45 @@ const liberator = (function () //{{{
function () { liberator.restart(); }, function () { liberator.restart(); },
{ argCount: "0" }); { argCount: "0" });
toolbox = document.getElementById("navigator-toolbox");
if (toolbox)
{
function findToolbar(name) buffer.evaluateXPath(
"./*[@toolbarname=" + util.escapeString(name, "'") + "]",
document, toolbox).snapshotItem(0);
let tbcmd = function (names, desc, action, filter)
{
commands.add(names, desc,
function (args)
{
let toolbar = findToolbar(args[0]);
if (!toolbar)
return void liberator.echoerr("E474: Invalid argument");
action(toolbar);
},
{
argcount: "1",
completer: function (context)
{
completion.toolbar(context)
if (filter)
context.filters.push(filter);
},
literal: 0
});
}
tbcmd(["toolbarshow", "tbshow"], "Show the named toolbar",
function (toolbar) toolbar.collapsed = false,
function (item) item.item.collapsed);
tbcmd(["toolbarhide", "tbhide"], "Hide the named toolbar",
function (toolbar) toolbar.collapsed = true,
function (item) !item.item.collapsed);
tbcmd(["toolbartoggle", "tbtoggle"], "Toggle the named toolbar",
function (toolbar) toolbar.collapsed = !toolbar.collapsed);
}
commands.add(["time"], commands.add(["time"],
"Profile a piece of code or run a command multiple times", "Profile a piece of code or run a command multiple times",
function (args) function (args)
@@ -805,6 +846,12 @@ const liberator = (function () //{{{
context.keys = { text: "fullMenuPath", description: function (item) item.getAttribute("label") }; context.keys = { text: "fullMenuPath", description: function (item) item.getAttribute("label") };
context.completions = liberator.menuItems; context.completions = liberator.menuItems;
}; };
completion.toolbar = function toolbar(context) {
context.title = ["Toolbar"];
context.keys = { text: function (item) item.getAttribute("toolbarname"), description: function () "" };
context.completions = buffer.evaluateXPath("./*[@toolbarname]", document, toolbox);
}
}); });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -463,7 +463,7 @@ const util = { //{{{
[XHTML, 'html'], [XHTML, 'html'],
[XUL, 'xul'] [XUL, 'xul']
]); ]);
if (object instanceof Node && !(object instanceof Document)) if (object instanceof Element)
{ {
let elem = object; let elem = object;
if (elem.nodeType == elem.TEXT_NODE) if (elem.nodeType == elem.TEXT_NODE)

View File

@@ -16,6 +16,7 @@
* IMPORTANT: shifted key notation now matches Vim's behaviour. E.g. <C-a> * IMPORTANT: shifted key notation now matches Vim's behaviour. E.g. <C-a>
and <C-A> are equivalent, to map the uppercase character use <C-S-A>. and <C-A> are equivalent, to map the uppercase character use <C-S-A>.
* add [c]:toolbaropen[c], [c]:toolbarclose[c], and [c]:toolbartoggle[c]
* make [c]:open[c] behavior match that of [c]:tabopen[c] and [c]:winopen[c] * make [c]:open[c] behavior match that of [c]:tabopen[c] and [c]:winopen[c]
when no argument is specified when no argument is specified
* add extension related commands - [c]:extadd[c], [c]:extdelete[c], * add extension related commands - [c]:extadd[c], [c]:extdelete[c],

View File

@@ -140,4 +140,23 @@ standard Firefox View->Sidebar menu. Add-ons, Preferences and Downloads are
also available in the sidebar. also available in the sidebar.
________________________________________________________________________________ ________________________________________________________________________________
|:tbshow| |:toolbarshow| +
||:toolbarshow {name}||
________________________________________________________________________________
Shows the named toolbar.
________________________________________________________________________________
|:tbhide| |:toolbarhide| +
||:toolbarhide {name}||
________________________________________________________________________________
Hides the named toolbar.
________________________________________________________________________________
|:tbtoggle| |:toolbartoggle| +
||:toolbartoggle {name}||
________________________________________________________________________________
Toggles the named toolbar.
________________________________________________________________________________
// vim: set filetype=asciidoc: // vim: set filetype=asciidoc:

View File

@@ -258,6 +258,9 @@ section:Ex{nbsp}commands[ex-cmd-index,:index]
||[c]:tabprevious[c]|| Switch to the previous tab or go [count] tabs back + ||[c]:tabprevious[c]|| Switch to the previous tab or go [count] tabs back +
||[c]:tabrewind[c]|| Switch to the first tab + ||[c]:tabrewind[c]|| Switch to the first tab +
||[c]:time[c]|| Profile a piece of code or run a command multiple times + ||[c]:time[c]|| Profile a piece of code or run a command multiple times +
||[c]toolbarshow[c]|| Show the named toolbar +
||[c]toolbarhide[c]|| Hide the named toolbar +
||[c]toolbartoggle[c]|| Toggle the named toolbar +
||[c]:unabbreviate[c]|| Remove an abbreviation + ||[c]:unabbreviate[c]|| Remove an abbreviation +
||[c]:undo[c]|| Undo closing of a tab + ||[c]:undo[c]|| Undo closing of a tab +
||[c]:undoall[c]|| Undo closing of all closed tabs + ||[c]:undoall[c]|| Undo closing of all closed tabs +