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

And xulmus was born.

This commit is contained in:
Doug Kearns
2009-03-16 15:54:02 +11:00
parent 9f70457a4a
commit 80beaa41df
61 changed files with 7085 additions and 36 deletions

View File

@@ -42,8 +42,9 @@ function Buffer() //{{{
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// FIXME: This doesn't belong here.
let mainWindowID = config.mainWindowID || "main-window";
// FIXME: This doesn't belong here.
let mainWindowID = config.mainWindowID || "mainplayer";
let fontSize = util.computedStyle(document.getElementById(mainWindowID)).fontSize;
styles.registerSheet("chrome://liberator/skin/liberator.css");
@@ -214,7 +215,13 @@ function Buffer() //{{{
mappings.add(myModes, ["<C-c>"],
"Stop loading",
function () { window.BrowserStop(); });
function ()
{
if(config.name == "Xulmus")
getBrowser().mCurrentBrowser.stop();
else
window.BrowserStop();
});
// scrolling
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
@@ -596,7 +603,13 @@ function Buffer() //{{{
commands.add(["st[op]"],
"Stop loading",
function () { window.BrowserStop(); },
function ()
{
if(config.name == "Xulmus")
getBrowser().mCurrentBrowser.stop();
else
window.BrowserStop();
},
{ argCount: "0" });
commands.add(["vie[wsource]"],

View File

@@ -1381,6 +1381,16 @@ function Completion() //{{{
completion.urls(context, tags);
},
songCompletion: function songCompletion(context, args)
{
if (args.completeArg == 0)
context.completions = getArtists();
else if (args.completeArg == 1)
context.completions = getAlbums(args[0]);
else if (args.completeArg == 2)
context.completions = getTracks(args[0],args[1]);
},
buffer: function buffer(context)
{
filter = context.filter.toLowerCase();

View File

@@ -628,7 +628,7 @@ function Events() //{{{
// return true when load successful, or false otherwise
function waitForPageLoaded() events.waitForPageLoad();
// load all macros inside ~/.vimperator/macros/
// load all macros inside ~/.xulmus/macros/
// setTimeout needed since io. is loaded after events.
setTimeout(function () {
try
@@ -678,16 +678,16 @@ function Events() //{{{
function () { events.onEscape(); });
// add the ":" mapping in all but insert mode mappings
mappings.add([modes.NORMAL, modes.VISUAL, modes.HINTS, modes.MESSAGE, modes.COMPOSE, modes.CARET, modes.TEXTAREA],
mappings.add([modes.NORMAL, modes.PLAYER, modes.VISUAL, modes.HINTS, modes.MESSAGE, modes.COMPOSE, modes.CARET, modes.TEXTAREA],
[":"], "Enter command line mode",
function () { commandline.open(":", "", modes.EX); });
// focus events
mappings.add([modes.NORMAL, modes.VISUAL, modes.CARET],
mappings.add([modes.NORMAL, modes.PLAYER, modes.VISUAL, modes.CARET],
["<Tab>"], "Advance keyboard focus",
function () { document.commandDispatcher.advanceFocus(); });
mappings.add([modes.NORMAL, modes.VISUAL, modes.CARET, modes.INSERT, modes.TEXTAREA],
mappings.add([modes.NORMAL, modes.PLAYER,modes.VISUAL, modes.CARET, modes.INSERT, modes.TEXTAREA],
["<S-Tab>"], "Rewind keyboard focus",
function () { document.commandDispatcher.rewindFocus(); });
@@ -704,12 +704,12 @@ function Events() //{{{
function () { return; });
// macros
mappings.add([modes.NORMAL, modes.MESSAGE],
mappings.add([modes.NORMAL, modes.PLAYER, modes.MESSAGE],
["q"], "Record a key sequence into a macro",
function (arg) { events.startRecording(arg); },
{ flags: Mappings.flags.ARGUMENT });
mappings.add([modes.NORMAL, modes.MESSAGE],
mappings.add([modes.NORMAL, modes.PLAYER, modes.MESSAGE],
["@"], "Play a macro",
function (count, arg)
{
@@ -1037,8 +1037,8 @@ function Events() //{{{
// (i.e., cntrl codes 27--31)
// ---
// For more information, see:
// [*] Vimp FAQ: http://vimperator.org/trac/wiki/Vimperator/FAQ#WhydoesntC-workforEscMacOSX
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/vimperator/2008-May/001548.html
// [*] Vimp FAQ: http://xulmus.org/trac/wiki/Xulmus/FAQ#WhydoesntC-workforEscMacOSX
// [*] Referenced mailing list msg: http://www.mozdev.org/pipermail/xulmus/2008-May/001548.html
// [*] Mozilla bug 416227: event.charCode in keypress handler has unexpected values on Mac for Ctrl with chars in "[ ] _ \"
// https://bugzilla.mozilla.org/show_bug.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&id=416227
// [*] Mozilla bug 432951: Ctrl+'foo' doesn't seem same charCode as Meta+'foo' on Cocoa
@@ -1226,6 +1226,21 @@ function Events() //{{{
}
}
if(config.name == "Xulmus")
{
// Switch to -- PLAYER -- mode for Songbird Media Player.
if(config.isPlayerWindow)
{
liberator.mode = modes.PLAYER;
}
else
{
liberator.mode = modes.NORMAL;
}
return;
}
urlbar = document.getElementById("urlbar");
if (elem == null && urlbar && urlbar.inputField == lastFocus)
liberator.threadYield(true);
@@ -1421,8 +1436,8 @@ function Events() //{{{
// XXX: ugly hack for now pass certain keys to Firefox as they are without beeping
// also fixes key navigation in combo boxes, submitting forms, etc.
// FIXME: breaks iabbr for now --mst
if ((config.name == "Vimperator" && liberator.mode == modes.NORMAL)
|| liberator.mode == modes.INSERT)
if (((config.name == "Xulmus" || config.name == "Vimperator") && liberator.mode == modes.NORMAL || liberator.mode == modes.INSERT))
{
if (key == "<Return>")
return false;

View File

@@ -26,6 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
/** @scope modules */
Cu.import("resource://gre/modules/XPCOMUtils.jsm", modules);
@@ -70,7 +71,7 @@ const liberator = (function () //{{{
let nError = 0;
function loadModule(name, func)
{
let message = "Loading module " + name + "...";
let message = "Loading module " + name + "...";
try
{
liberator.log(message, 0);
@@ -81,7 +82,10 @@ const liberator = (function () //{{{
catch (e)
{
if (nError++ == 0)
window.toJavaScriptConsole();
liberator.dump("Error loading module - "+ name + "..");
liberator.dump(e);
liberator.dump(e.stack);
window.toJavaScriptConsole();
liberator.reportError(e);
}
}
@@ -1215,8 +1219,6 @@ const liberator = (function () //{{{
startup: function ()
{
let start = Date.now();
liberator.log("Initializing liberator object...", 0);
config.features = config.features || [];
config.features.push(getPlatformFeature());
config.defaults = config.defaults || {};
@@ -1225,7 +1227,7 @@ const liberator = (function () //{{{
config.mailModes = config.mailModes || [modes.NORMAL];
// TODO: suitable defaults?
//config.mainWidget
//config.mainWindowID
//config.mainWindowID
//config.visualbellWindow
//config.styleableChrome
config.autocommands = config.autocommands || [];

View File

@@ -269,6 +269,7 @@ const modes = (function () //{{{
self.addMode("MESSAGE"); // for now only used in Muttator when the message has focus
self.addMode("COMPOSE");
self.addMode("CUSTOM", false, function () plugins.mode);
self.addMode("PLAYER"); // Player mode for songbird
// extended modes, can include multiple modes, and even main modes
self.addMode("EX", true);
self.addMode("HINTS", true);

View File

@@ -48,6 +48,7 @@ function Services()
self.add("appStartup", "@mozilla.org/toolkit/app-startup;1", Ci.nsIAppStartup);
self.add("autoCompleteSearch", "@mozilla.org/browser/global-history;2", Ci.nsIAutoCompleteSearch);
//self.add("autoCompleteSearch", "@mozilla.org/autocomplete/search;1?name=songbird-autocomplete", Ci.nsIAutoCompleteSearch);
self.add("browserSearch", "@mozilla.org/browser/search-service;1", Ci.nsIBrowserSearchService);
self.add("cache", "@mozilla.org/network/cache-service;1", Ci.nsICacheService);
self.add("console", "@mozilla.org/consoleservice;1", Ci.nsIConsoleService);
@@ -64,7 +65,8 @@ function Services()
self.add("threadManager", "@mozilla.org/thread-manager;1", Ci.nsIThreadManager);
self.add("windowMediator", "@mozilla.org/appshell/window-mediator;1", Ci.nsIWindowMediator);
self.add("windowWatcher", "@mozilla.org/embedcomp/window-watcher;1", Ci.nsIWindowWatcher);
self.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", Ci.nsINavBookmarksService);
self.addClass("file", "@mozilla.org/file/local;1", Ci.nsILocalFile);
self.addClass("find", "@mozilla.org/embedcomp/rangefind;1", Ci.nsIFind);
self.addClass("process", "@mozilla.org/process/util;1", Ci.nsIProcess);

View File

@@ -109,7 +109,10 @@ function Tabs() //{{{
// hide tabs initially
if (config.name == "Vimperator")
getBrowser().mStrip.getElementsByClassName("tabbrowser-tabs")[0].collapsed = true;
/*
if (config.name == "Xulmus")
getBrowser()._strip.getElementsByClassName(
*/
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -148,7 +151,7 @@ function Tabs() //{{{
validator: Option.validateCompleter
});
if (config.name == "Vimperator")
if (config.name == "Vimperator" || config.name == "Xulmus" )
{
options.add(["activate", "act"],
"Define when tabs are automatically activated",
@@ -238,7 +241,7 @@ function Tabs() //{{{
function (count) { tabs.select("-" + (count < 1 ? 1 : count), true); },
{ flags: Mappings.flags.COUNT });
if (config.name == "Vimperator")
if (config.name == "Vimperator" || config.name == "Xulmus")
{
mappings.add([modes.NORMAL], ["b"],
"Open a prompt to switch buffers",
@@ -449,7 +452,7 @@ function Tabs() //{{{
function () { tabs.select(0, false); },
{ argCount: "0" });
if (config.name == "Vimperator")
if (config.name == "Vimperator" || config.name == "Xulmus")
{
// TODO: "Zero count" if 0 specified as arg, multiple args and count ranges?
commands.add(["b[uffer]"],
@@ -584,7 +587,7 @@ function Tabs() //{{{
});
}
if (liberator.has("session"))
if (liberator.has("session") && config.name != "Xulmus")
{
// TODO: extract common functionality of "undoall"
commands.add(["u[ndo]"],
@@ -780,6 +783,22 @@ function Tabs() //{{{
getBrowser().removeTab(tab);
else
liberator.beep();
},
Songbird: function (tab)
{
if (getBrowser().mTabs.length > 1)
getBrowser().removeTab(tab);
else
{
if (buffer.URL != "about:blank" ||
window.getWebNavigation().sessionHistory.count > 0)
{
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
getBrowser().removeTab(tab);
}
else
liberator.beep();
}
}
}[config.hostApplication] || function () {};

View File

@@ -568,7 +568,7 @@ function CommandLine() //{{{
var startHints = false; // whether we're waiting to start hints mode
var lastSubstring = "";
// the containing box for the promptWidget and commandWidget
const commandlineWidget = document.getElementById("liberator-commandline");
// the prompt for the current command, for example : or /. Can be blank
@@ -577,7 +577,7 @@ function CommandLine() //{{{
const commandWidget = document.getElementById("liberator-commandline-command");
const messageBox = document.getElementById("liberator-message");
commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
messageBox.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);

View File

@@ -170,7 +170,7 @@ const util = { //{{{
*/
computedStyle: function computedStyle(node)
{
while (node instanceof Text && node.parentNode)
while (node instanceof Text && node.parentNode)
node = node.parentNode;
return node.ownerDocument.defaultView.getComputedStyle(node, null);
},