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

commited pending changes, nothing big

This commit is contained in:
Martin Stubenschrott
2007-05-20 11:05:21 +00:00
parent f2bc81d820
commit c5ddcea49e
4 changed files with 157 additions and 119 deletions

View File

@@ -329,25 +329,25 @@ function History()
return history;
}
this.add = function (uri, title)
this.add = function (url, title)
{
if(!history)
load();
// XXX: check if fast enough
history = history.filter(function(elem) {
return elem[0] != uri;
return elem[0] != url;
});
// for(var i in history)
// {
// if(g_history[i][0] == url)
// if(history[i][0] == url)
// return;
// }
// g_history.unshift([url, title]);
history.unshift([uri, title]);
history.unshift([url, title]);
//history.push([url, title]);
return true;
}
};
logMessage("History initialized");
}

View File

@@ -51,7 +51,8 @@ var g_commands = [/*{{{*/
["addons"],
"Show available Browser Extensions and Themes",
"You can add/remove/disable browser extensions from this dialog.<br/>Be aware that not all Firefox extensions work, because Vimperator overrides some keybindings and changes Firefox's GUI.",
function() { openURLsInNewTab("chrome://mozapps/content/extensions/extensions.xul", true); },
//function() { },
function(args) { vimperator.commands.addons(args); },
null
],
[
@@ -176,8 +177,8 @@ var g_commands = [/*{{{*/
["hardcopy", "ha"],
["ha[rdcopy]"],
"Print current document",
"NOT FUNCTIONAL YET. Open a GUI dialog where you can select the printer, number of copies, orientation, etc.",
function() { goDoCommand('cmd_print'); },
"Open a GUI dialog where you can select the printer, number of copies, orientation, etc.",
function() { getBrowser().contentWindow.print(); },
null
],
[
@@ -2179,4 +2180,18 @@ function toggle_images() {
message ("imageBehavior set to " + pref);
}
function Commands()
{
this.addons = function(args)
{
openURLsInNewTab("chrome://mozapps/content/extensions/extensions.xul", true);
}
logMessage("Commands initialized");
}
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -19,6 +19,6 @@
chrome:author="Martin Stubenschrott"
chrome:name="vimperator"
chrome:extension="true"
chrome:description="Make Firefox like Vim">
chrome:description="Make Firefox behave like Vim">
</RDF:Description>
</RDF:RDF>

View File

@@ -41,13 +41,11 @@ var heredoc = '';
// handles to our gui elements
var command_line = null;
/* this function reacts to status bar and url changes which are sent from
the mozilla core */
function nsBrowserStatusHandler() /*{{{*/
function nsBrowserStatusHandler2() /*{{{*/
{
this.init();
}
nsBrowserStatusHandler.prototype =
nsBrowserStatusHandler2.prototype =
{
QueryInterface : function(aIID)
{
@@ -167,9 +165,6 @@ window.addEventListener("load", init, false);
////////////////////////////////////////////////////////////////////////
// init/uninit //////////////////////////////////////////////////// {{{1
////////////////////////////////////////////////////////////////////////
//function moo() { return ["moo", "x"];};
// return [startindex, [[itemtext, itemhelp],...]]
function init()
{
// init the main object
@@ -177,6 +172,7 @@ function init()
// these inner classes are created here, because outside the init()
// function, the chrome:// is not ready
Vimperator.prototype.commands = new Commands;
Vimperator.prototype.bookmarks = new Bookmarks;
Vimperator.prototype.history = new History;
Vimperator.prototype.qm = new QM;
@@ -196,108 +192,8 @@ function init()
command_line = document.getElementById("vim-commandbar");
// Setup our main status handler - from browser.js
window.XULBrowserWindow = new nsBrowserStatusHandler();
// window.XULBrowserWindow = new function()
// {
// this.init = function(){alert("init");};
// QueryInterface: function(aIID)
// {
// if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
// aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
// aIID.equals(Components.interfaces.nsIXULBrowserWindow) ||
// aIID.equals(Components.interfaces.nsISupports))
// return this;
// throw Components.results.NS_NOINTERFACE;
// },
//
// /* functions needed for functioning */
// init: function() {},
// setJSStatus: function(status) {},
// setJSDefaultStatus: function(status) {},
// setDefaultStatus: function(status) {},
// onLinkIconAvailable:function(a) {},
// onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage) { return 0; },
//
// setOverLink: function(link, b)
// {
// var ssli = get_pref("showstatuslinks");
// if (link && ssli)
// {
// if (ssli == 1)
// vimperator.statusline.updateUrl("Link: " + link);
// else if (ssli == 2)
// vimperator.echo("Link: " + link);
// }
//
// if (link == "")
// {
// vimperator.statusline.updateUrl();
// showMode();
// }
// },
//
//
// // called when a page load is requested or finished/stopped
// onStateChange:function(aProgress,aRequest,aFlag,aStatus)
// {
// const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
// //const nsIChannel = Components.interfaces.nsIChannel;
// if (aFlag & nsIWebProgressListener.STATE_START && aRequest && aRequest.URI)
// {
// vimperator.statusline.updateProgress(0);
// }
// // this is called when all loading was done (or when the user canceled the load
// else if (aFlag & nsIWebProgressListener.STATE_STOP)
// {
// vimperator.statusline.updateUrl(aRequest.URI.spec);
// vimperator.statusline.updateProgress("");
// // also reset the buffer list, since the url titles are valid here
// showBufferList(true);
// }
// return 0;
// },
// // onLocationChange is also called when switching/deleting tabs
// onLocationChange: function (aWebProgress, aRequest, aLocation)
// {
// // firefox 3.0 doesn't seem to have this function anymore
// if (typeof UpdateBackForwardButtons == "function")
// UpdateBackForwardButtons();
//
// var url = aLocation.spec;
//
// // also update the original firefox location bar
// if (gURLBar)
// gURLBar.value = url;
//
// if (hah.currentMode() != HINT_MODE_ALWAYS)
// hah.disableHahMode();
//
// vimperator.statusline.updateUrl(url);
// vimperator.statusline.updateProgress();
// setTimeout(function() {vimperator.statusline.updateBufferPosition();}, 100); // if not delayed we get the wrong position of the old buffer
//
// // updating history cache is not done here but in the 'pageshow' event
// // handler, because at this point I don't have access to the url title
// return 0;
// },
// onProgressChange:function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
// {
// vimperator.statusline.updateProgress(aCurTotalProgress/aMaxTotalProgress);
// return 0;
// },
// onSecurityChange:function (aWebProgress, aRequest, aState)
// {
// const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
// if(aState & nsIWebProgressListener.STATE_IS_INSECURE)
// vimperator.statusline.setColor("transparent");
// else if(aState & nsIWebProgressListener.STATE_IS_BROKEN)
// vimperator.statusline.setColor("orange");
// else if(aState & nsIWebProgressListener.STATE_IS_SECURE)
// vimperator.statusline.setColor("yellow");
//
// return 0;
// }
// }
// this function reacts to status bar and url changes which are sent from the mozilla core
window.XULBrowserWindow = new vimperator.browserStatusHandler;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
@@ -306,6 +202,9 @@ function init()
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow;
var interfaceRequestor = QueryInterface(Components.interfaces.nsIInterfaceRequestor);
// var webProgress = interfaceRequestor.getInterface(Components.interfaces.nsIWebProgress);
// webProgress.addProgressListener(window.XULBrowserWindow, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
@@ -423,9 +322,17 @@ function addEventListeners()
var title = getCurrentTitle(); // not perfect "- Vimperator" in the title
vimperator.history.add(url, title);
}
//alert("moo");
}
, null);
window.document.addEventListener("DOMTitleChanged", function(event)
{
//alert("tit");
}
, null);
// called when the window is scrolled.
window.onscroll = function (event)
{
@@ -1069,6 +976,122 @@ function Vimperator()
vimperator.statusline.updateInputBuffer(g_inputbuffer);
return false;
}/*}}}*/
this.browserStatusHandler = function() { this.init(); }
this.browserStatusHandler.prototype =
{
QueryInterface : function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
init : function()
{
},
setOverLink : function(link, b)
{
var ssli = get_pref("showstatuslinks");
if (link && ssli)
{
if (ssli == 1)
vimperator.statusline.updateUrl("Link: " + link);
else if (ssli == 2)
vimperator.echo("Link: " + link);
}
if (link == "")
{
if (ssli == 1)
vimperator.statusline.updateUrl();
else if (ssli == 2)
{
//vimperator.echo("");
vimperator.setMode(); // trick to reshow the mode in the command line
}
}
},
setJSStatus : function(status) { },
setJSDefaultStatus : function(status) { },
setDefaultStatus : function(status) { },
onStateChange:function(aProgress,aRequest,aFlag,aStatus)
{
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
//const nsIChannel = Components.interfaces.nsIChannel;
if (aFlag & nsIWebProgressListener.STATE_START && aRequest && aRequest.URI)
{
vimperator.statusline.updateProgress(0);
}
// this is called when all loading was done (or when the user canceled the load
else if (aFlag & nsIWebProgressListener.STATE_STOP)
{
//alert('stop: ' + aRequest.URI.spec);
vimperator.statusline.updateUrl(aRequest.URI.spec);
vimperator.statusline.updateProgress("");
// also reset the buffer list, since the url titles are valid here
showBufferList(true);
}
return 0;
},
onLocationChange:function (aWebProgress, aRequest, aLocation)
{
// firefox 3.0 doesn't seem to have this function anymore
if (typeof UpdateBackForwardButtons == "function")
UpdateBackForwardButtons();
var url = aLocation.spec;
// also update the original firefox location bar
if (gURLBar)
gURLBar.value = url;
// onLocationChange is also called when switching/deleting tabs
//if (hah.currentMode() != HINT_MODE_ALWAYS)
if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
hah.disableHahMode();
vimperator.statusline.updateUrl(url);
vimperator.statusline.updateProgress();
setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100); // if not delayed we get the wrong position of the old buffer
// updating history cache is not done here but in the 'pageshow' event
// handler, because at this point I don't have access to the url title
return 0;
},
onProgressChange:function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
{
vimperator.statusline.updateProgress(aCurTotalProgress/aMaxTotalProgress);
return 0;
},
onStatusChange:function (aWebProgress, aRequest, aStatus, aMessage)
{
alert('change');
vimperator.statusline.updateUrl(aMessage);
return 0;
},
onSecurityChange:function (aWebProgress, aRequest, aState)
{
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
if(aState & nsIWebProgressListener.STATE_IS_INSECURE)
vimperator.statusline.setColor("transparent");
else if(aState & nsIWebProgressListener.STATE_IS_BROKEN)
vimperator.statusline.setColor("orange");
else if(aState & nsIWebProgressListener.STATE_IS_SECURE)
vimperator.statusline.setColor("yellow");
return 0;
}
//onLinkIconAvailable:function(a){}
};/*}}}*/
// alert('end');
}