mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-01 06:25:47 +01:00
Add :sidebar!. Closes issue #269.
This commit is contained in:
@@ -208,6 +208,20 @@
|
|||||||
</p>
|
</p>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spec>:sidebar! <oa>name</oa></spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Toggle the sidebar window. When <oa>name</oa> is provided, the
|
||||||
|
semantics are as follows: If the named is currently open, it is
|
||||||
|
closed. Otherwise the sidebar is closed. When <oa>name</oa> is
|
||||||
|
not provided, the semantics are as follows: If the sidebar is
|
||||||
|
currently open, it is closed. Otherwise the previously open sidebar
|
||||||
|
panel is re-opened.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
|
||||||
<h2 tag="status-line status-bar">Status line</h2>
|
<h2 tag="status-line status-bar">Status line</h2>
|
||||||
|
|
||||||
|
|||||||
@@ -743,15 +743,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {function(XMLHttpRequest)} callback
|
* @param {function(XMLHttpRequest)} callback
|
||||||
* @returns {XMLHttpRequest}
|
* @returns {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
httpGet: function httpGet(url, callback) {
|
httpGet: function httpGet(url, callback, self) {
|
||||||
try {
|
try {
|
||||||
let xmlhttp = services.Xmlhttp();
|
let xmlhttp = services.Xmlhttp();
|
||||||
xmlhttp.mozBackgroundRequest = true;
|
xmlhttp.mozBackgroundRequest = true;
|
||||||
if (callback)
|
if (callback) {
|
||||||
xmlhttp.onreadystatechange = function () {
|
xmlhttp.onload = function handler(event) { util.trapErrors(callback, self, xmlhttp, event) };
|
||||||
if (xmlhttp.readyState == 4)
|
xmlhttp.onerror = xmlhttp.onload;
|
||||||
callback(xmlhttp);
|
}
|
||||||
};
|
|
||||||
xmlhttp.open("GET", url, !!callback);
|
xmlhttp.open("GET", url, !!callback);
|
||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
|
|||||||
@@ -80,6 +80,8 @@
|
|||||||
- :saveas now provides completions for default file names, and
|
- :saveas now provides completions for default file names, and
|
||||||
automatically chooses a filename when the save target is a
|
automatically chooses a filename when the save target is a
|
||||||
directory.
|
directory.
|
||||||
|
- :sidebar now accepts a ! flag to toggle the sidebar rather
|
||||||
|
than open it unconditionally.
|
||||||
- Added :write !cmd and :write >>file.
|
- Added :write !cmd and :write >>file.
|
||||||
- Added :yank command.
|
- Added :yank command.
|
||||||
- :delmarks, :marks and :qmarks now also accept ranges, same as
|
- :delmarks, :marks and :qmarks now also accept ranges, same as
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ var Config = Module("config", ConfigBase, {
|
|||||||
}, {
|
}, {
|
||||||
}, {
|
}, {
|
||||||
commands: function (dactyl, modules, window) {
|
commands: function (dactyl, modules, window) {
|
||||||
const { commands, completion } = modules;
|
const { commands, completion, config } = modules;
|
||||||
const { document } = window;
|
const { document } = window;
|
||||||
|
|
||||||
commands.add(["winon[ly]"],
|
commands.add(["winon[ly]"],
|
||||||
@@ -205,10 +205,20 @@ var Config = Module("config", ConfigBase, {
|
|||||||
"Open the sidebar window",
|
"Open the sidebar window",
|
||||||
function (args) {
|
function (args) {
|
||||||
function compare(a, b) util.compareIgnoreCase(a, b) == 0
|
function compare(a, b) util.compareIgnoreCase(a, b) == 0
|
||||||
|
let title = document.getElementById("sidebar-title");
|
||||||
|
|
||||||
|
dactyl.assert(args.length || title.value || args.bang && config.lastSidebar,
|
||||||
|
"Argument required");
|
||||||
|
|
||||||
|
if (!args.length)
|
||||||
|
return window.toggleSidebar(title.value ? null : config.lastSidebar);
|
||||||
|
|
||||||
// focus if the requested sidebar is already open
|
// focus if the requested sidebar is already open
|
||||||
if (compare(document.getElementById("sidebar-title").value, args[0]))
|
if (compare(title.value, args[0])) {
|
||||||
|
if (args.bang)
|
||||||
|
return window.toggleSidebar();
|
||||||
return dactyl.focus(document.getElementById("sidebar-box"));
|
return dactyl.focus(document.getElementById("sidebar-box"));
|
||||||
|
}
|
||||||
|
|
||||||
let menu = document.getElementById("viewSidebarMenu");
|
let menu = document.getElementById("viewSidebarMenu");
|
||||||
|
|
||||||
@@ -223,7 +233,8 @@ var Config = Module("config", ConfigBase, {
|
|||||||
return dactyl.echoerr("No sidebar " + args[0] + " found");
|
return dactyl.echoerr("No sidebar " + args[0] + " found");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "?",
|
||||||
|
bang: true,
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
context.ignoreCase = true;
|
context.ignoreCase = true;
|
||||||
return completion.sidebar(context);
|
return completion.sidebar(context);
|
||||||
@@ -322,6 +333,12 @@ var Config = Module("config", ConfigBase, {
|
|||||||
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
|
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
|
||||||
completion.location);
|
completion.location);
|
||||||
},
|
},
|
||||||
|
events: function (dactyl, modules, window) {
|
||||||
|
modules.events.addSessionListener(window, "SidebarFocused", function (event) {
|
||||||
|
modules.config.lastSidebar = window.document.getElementById("sidebar-box")
|
||||||
|
.getAttribute("sidebarcommand");
|
||||||
|
}, false);
|
||||||
|
},
|
||||||
modes: function (dactyl, modules, window) {
|
modes: function (dactyl, modules, window) {
|
||||||
const { config, modes } = modules;
|
const { config, modes } = modules;
|
||||||
config.ignoreKeys = {
|
config.ignoreKeys = {
|
||||||
|
|||||||
Reference in New Issue
Block a user