diff --git a/content/events.js b/content/events.js index 1532d628..ef369992 100644 --- a/content/events.js +++ b/content/events.js @@ -392,13 +392,13 @@ vimperator.Events = function () //{{{ doc.pageIsFullyLoaded = 1; // code which is only relevant if the page load is the current tab goes here: - if (!vimperator.tabs || doc == getBrowser().selectedBrowser.contentDocument) + if (doc == getBrowser().contentDocument) { // we want to stay in command mode after a page has loaded // XXX: Does this still causes window map events which is _very_ annoying setTimeout(function () { var focused = document.commandDispatcher.focusedElement; - if (focused && focused.value.length == 0) + if (focused && (typeof focused.value != "undefined") && focused.value.length == 0) focused.blur(); }, 100); } @@ -754,6 +754,8 @@ vimperator.Events = function () //{{{ if (elem && elem.readOnly) return; + // dump(vimperator.util.objectToString(elem) + "\n"); + if (elem && elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) { @@ -782,7 +784,7 @@ vimperator.Events = function () //{{{ else if (vimperator.mode == vimperator.modes.INSERT || vimperator.mode == vimperator.modes.TEXTAREA || - // vimperator.mode == vimperator.modes.MESSAGE || + vimperator.mode == vimperator.modes.MESSAGE || vimperator.mode == vimperator.modes.VISUAL) { // FIXME: currently this hack is disabled to make macros work diff --git a/content/muttator.js b/content/muttator.js index f5421957..2f470bc6 100644 --- a/content/muttator.js +++ b/content/muttator.js @@ -32,7 +32,8 @@ vimperator.config = { // this widget is focused when focusContent() is called get mainWidget() { return GetThreadTree(); }, - dialogs: [] + dialogs: [], + features: ["mail", "hints"] } // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/ui.js b/content/ui.js index 80d017bc..2c11b334 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1202,6 +1202,12 @@ vimperator.StatusLine = function () //{{{ // you can omit either of the 2 arguments updateTabCount: function (currentIndex, totalTabs) { + if (!vimperator.has("tabs")) + { + tabCountWidget = ""; + return; + } + if (!currentIndex || typeof currentIndex != "number") currentIndex = vimperator.tabs.index() + 1; if (!totalTabs || typeof currentIndex != "number") diff --git a/content/vim.js b/content/vim.js index 51ab995e..ba942f38 100644 --- a/content/vim.js +++ b/content/vim.js @@ -241,6 +241,13 @@ const vimperator = (function () //{{{ } }, + // return true, if this VIM-like extension has a certain feature + has: function (feature) + { + var features = vimperator.config.features || []; + return features.some (function(feat) { return feat == feature; }); + }, + // logs a message to the javascript error console // if msg is an object, it is beautified log: function (msg, level) @@ -264,7 +271,7 @@ const vimperator = (function () //{{{ // @param callback: not implemented, will be allowed to specify a callback function // which is called, when the page finished loading // @returns true when load was initiated, or false on error - open: function (urls, where, callback) + open: function (urls, where) { // convert the string to an array of converted URLs // -> see vimperator.util.stringToURLArray for more details @@ -274,7 +281,7 @@ const vimperator = (function () //{{{ if (urls.length == 0) return false; - if (!where) + if (!where || !vimperator.has("tabs")) where = vimperator.CURRENT_TAB; var url = typeof urls[0] == "string" ? urls[0] : urls[0][0]; @@ -285,7 +292,7 @@ const vimperator = (function () //{{{ switch (where) { case vimperator.CURRENT_TAB: - window.loadURI(url, null, postdata); // getBrowser.loadURI() did not work with postdata in my quick experiments --mst + getBrowser().loadURIWithFlags(url, null, null, null, postdata); break; case vimperator.NEW_TAB: @@ -310,6 +317,10 @@ const vimperator = (function () //{{{ return false; } + // only load more than one url if we have tab support + if (!vimperator.has("tabs")) + return true; + // all other URLs are always loaded in background for (var i = 1; i < urls.length; i++) { @@ -318,8 +329,6 @@ const vimperator = (function () //{{{ whichwindow.getBrowser().addTab(url, null, null, postdata); } - // TODO: register callbacks - return true; }, @@ -382,12 +391,12 @@ const vimperator = (function () //{{{ vimperator.events = vimperator.Events(); vimperator.log("Loading module commands...", 3); vimperator.commands = vimperator.Commands(); - if (vimperator.Bookmarks) + if (vimperator.has("bookmarks")) { vimperator.log("Loading module bookmarks...", 3); vimperator.bookmarks = vimperator.Bookmarks(); } - if (vimperator.History) + if (vimperator.has("history")) { vimperator.log("Loading module history...", 3); vimperator.history = vimperator.History(); @@ -408,23 +417,26 @@ const vimperator = (function () //{{{ vimperator.buffer = vimperator.Buffer(); vimperator.log("Loading module editor...", 3); vimperator.editor = vimperator.Editor(); - if (vimperator.Tabs) + if (vimperator.has("tabs")) { vimperator.log("Loading module tabs...", 3); vimperator.tabs = vimperator.Tabs(); } - if (vimperator.Marks) + if (vimperator.has("marks")) { vimperator.log("Loading module marks...", 3); vimperator.marks = vimperator.Marks(); } - if (vimperator.QuickMarks) + if (vimperator.has("quickmarks")) { vimperator.log("Loading module quickmarks...", 3); vimperator.quickmarks = vimperator.QuickMarks(); } - vimperator.log("Loading module hints...", 3); - vimperator.hints = vimperator.Hints(); + if (vimperator.has("hints")) + { + vimperator.log("Loading module hints...", 3); + vimperator.hints = vimperator.Hints(); + } vimperator.log("Loading module autocommands...", 3); vimperator.autocommands = vimperator.AutoCommands(); vimperator.log("Loading module io...", 3); diff --git a/content/vimperator.js b/content/vimperator.js index 25ad92ba..fe538845 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -29,7 +29,8 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.config = { name: "Vimperator", hostApplication: "Firefox", - dialogs: [] + dialogs: [], + features: ["bookmarks", "history", "marks", "quickmarks", "hints", "tabs"] } // vim: set fdm=marker sw=4 ts=4 et: