1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 00:27:57 +01:00

added vimperator.has("feature") and made vimperator.open(...) work in thunderbird as well

This commit is contained in:
Martin Stubenschrott
2008-02-05 15:30:08 +00:00
parent 7d9e1e100a
commit 5f04e70663
5 changed files with 39 additions and 17 deletions

View File

@@ -392,13 +392,13 @@ vimperator.Events = function () //{{{
doc.pageIsFullyLoaded = 1; doc.pageIsFullyLoaded = 1;
// code which is only relevant if the page load is the current tab goes here: // 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 // we want to stay in command mode after a page has loaded
// XXX: Does this still causes window map events which is _very_ annoying // XXX: Does this still causes window map events which is _very_ annoying
setTimeout(function () { setTimeout(function () {
var focused = document.commandDispatcher.focusedElement; var focused = document.commandDispatcher.focusedElement;
if (focused && focused.value.length == 0) if (focused && (typeof focused.value != "undefined") && focused.value.length == 0)
focused.blur(); focused.blur();
}, 100); }, 100);
} }
@@ -754,6 +754,8 @@ vimperator.Events = function () //{{{
if (elem && elem.readOnly) if (elem && elem.readOnly)
return; return;
// dump(vimperator.util.objectToString(elem) + "\n");
if (elem && elem instanceof HTMLInputElement && if (elem && elem instanceof HTMLInputElement &&
(elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password"))
{ {
@@ -782,7 +784,7 @@ vimperator.Events = function () //{{{
else if (vimperator.mode == vimperator.modes.INSERT || else if (vimperator.mode == vimperator.modes.INSERT ||
vimperator.mode == vimperator.modes.TEXTAREA || vimperator.mode == vimperator.modes.TEXTAREA ||
// vimperator.mode == vimperator.modes.MESSAGE || vimperator.mode == vimperator.modes.MESSAGE ||
vimperator.mode == vimperator.modes.VISUAL) vimperator.mode == vimperator.modes.VISUAL)
{ {
// FIXME: currently this hack is disabled to make macros work // FIXME: currently this hack is disabled to make macros work

View File

@@ -32,7 +32,8 @@ vimperator.config = {
// this widget is focused when focusContent() is called // this widget is focused when focusContent() is called
get mainWidget() { return GetThreadTree(); }, get mainWidget() { return GetThreadTree(); },
dialogs: [] dialogs: [],
features: ["mail", "hints"]
} }
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1202,6 +1202,12 @@ vimperator.StatusLine = function () //{{{
// you can omit either of the 2 arguments // you can omit either of the 2 arguments
updateTabCount: function (currentIndex, totalTabs) updateTabCount: function (currentIndex, totalTabs)
{ {
if (!vimperator.has("tabs"))
{
tabCountWidget = "";
return;
}
if (!currentIndex || typeof currentIndex != "number") if (!currentIndex || typeof currentIndex != "number")
currentIndex = vimperator.tabs.index() + 1; currentIndex = vimperator.tabs.index() + 1;
if (!totalTabs || typeof currentIndex != "number") if (!totalTabs || typeof currentIndex != "number")

View File

@@ -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 // logs a message to the javascript error console
// if msg is an object, it is beautified // if msg is an object, it is beautified
log: function (msg, level) log: function (msg, level)
@@ -264,7 +271,7 @@ const vimperator = (function () //{{{
// @param callback: not implemented, will be allowed to specify a callback function // @param callback: not implemented, will be allowed to specify a callback function
// which is called, when the page finished loading // which is called, when the page finished loading
// @returns true when load was initiated, or false on error // @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 // convert the string to an array of converted URLs
// -> see vimperator.util.stringToURLArray for more details // -> see vimperator.util.stringToURLArray for more details
@@ -274,7 +281,7 @@ const vimperator = (function () //{{{
if (urls.length == 0) if (urls.length == 0)
return false; return false;
if (!where) if (!where || !vimperator.has("tabs"))
where = vimperator.CURRENT_TAB; where = vimperator.CURRENT_TAB;
var url = typeof urls[0] == "string" ? urls[0] : urls[0][0]; var url = typeof urls[0] == "string" ? urls[0] : urls[0][0];
@@ -285,7 +292,7 @@ const vimperator = (function () //{{{
switch (where) switch (where)
{ {
case vimperator.CURRENT_TAB: 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; break;
case vimperator.NEW_TAB: case vimperator.NEW_TAB:
@@ -310,6 +317,10 @@ const vimperator = (function () //{{{
return false; 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 // all other URLs are always loaded in background
for (var i = 1; i < urls.length; i++) for (var i = 1; i < urls.length; i++)
{ {
@@ -318,8 +329,6 @@ const vimperator = (function () //{{{
whichwindow.getBrowser().addTab(url, null, null, postdata); whichwindow.getBrowser().addTab(url, null, null, postdata);
} }
// TODO: register callbacks
return true; return true;
}, },
@@ -382,12 +391,12 @@ const vimperator = (function () //{{{
vimperator.events = vimperator.Events(); vimperator.events = vimperator.Events();
vimperator.log("Loading module commands...", 3); vimperator.log("Loading module commands...", 3);
vimperator.commands = vimperator.Commands(); vimperator.commands = vimperator.Commands();
if (vimperator.Bookmarks) if (vimperator.has("bookmarks"))
{ {
vimperator.log("Loading module bookmarks...", 3); vimperator.log("Loading module bookmarks...", 3);
vimperator.bookmarks = vimperator.Bookmarks(); vimperator.bookmarks = vimperator.Bookmarks();
} }
if (vimperator.History) if (vimperator.has("history"))
{ {
vimperator.log("Loading module history...", 3); vimperator.log("Loading module history...", 3);
vimperator.history = vimperator.History(); vimperator.history = vimperator.History();
@@ -408,23 +417,26 @@ const vimperator = (function () //{{{
vimperator.buffer = vimperator.Buffer(); vimperator.buffer = vimperator.Buffer();
vimperator.log("Loading module editor...", 3); vimperator.log("Loading module editor...", 3);
vimperator.editor = vimperator.Editor(); vimperator.editor = vimperator.Editor();
if (vimperator.Tabs) if (vimperator.has("tabs"))
{ {
vimperator.log("Loading module tabs...", 3); vimperator.log("Loading module tabs...", 3);
vimperator.tabs = vimperator.Tabs(); vimperator.tabs = vimperator.Tabs();
} }
if (vimperator.Marks) if (vimperator.has("marks"))
{ {
vimperator.log("Loading module marks...", 3); vimperator.log("Loading module marks...", 3);
vimperator.marks = vimperator.Marks(); vimperator.marks = vimperator.Marks();
} }
if (vimperator.QuickMarks) if (vimperator.has("quickmarks"))
{ {
vimperator.log("Loading module quickmarks...", 3); vimperator.log("Loading module quickmarks...", 3);
vimperator.quickmarks = vimperator.QuickMarks(); vimperator.quickmarks = vimperator.QuickMarks();
} }
vimperator.log("Loading module hints...", 3); if (vimperator.has("hints"))
vimperator.hints = vimperator.Hints(); {
vimperator.log("Loading module hints...", 3);
vimperator.hints = vimperator.Hints();
}
vimperator.log("Loading module autocommands...", 3); vimperator.log("Loading module autocommands...", 3);
vimperator.autocommands = vimperator.AutoCommands(); vimperator.autocommands = vimperator.AutoCommands();
vimperator.log("Loading module io...", 3); vimperator.log("Loading module io...", 3);

View File

@@ -29,7 +29,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
vimperator.config = { vimperator.config = {
name: "Vimperator", name: "Vimperator",
hostApplication: "Firefox", hostApplication: "Firefox",
dialogs: [] dialogs: [],
features: ["bookmarks", "history", "marks", "quickmarks", "hints", "tabs"]
} }
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et: