mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 07:47:58 +01:00
now we have a Events() class
Please report all bugs which arised because of these changes Still not sure, if we should put that into an event.js
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<pre>
|
||||
2007-05-02:
|
||||
* version ???
|
||||
* The RSS feed button in the address bar works again
|
||||
* reload/stop buttons update enabled state again
|
||||
* added marks support (thanks Viktor Kojouharov)
|
||||
* temporary shortcut Y to yank current selection (for non UNIX-users)
|
||||
* Flashing frame with ]f now works as expected
|
||||
|
||||
14
TODO
14
TODO
@@ -4,32 +4,26 @@ Priority list:
|
||||
|
||||
BUGS:
|
||||
- switching tabs while HINT_MODE_ALWAYS is on does not redisplay hints in new tabs, but exits hint mode
|
||||
- The RSS feed button in the address bar no longer works.
|
||||
- autoupdate does not work
|
||||
- multiple windows to not work at all, so :q will close the whole browser session, even when there are other windows which has tabs
|
||||
- reload/stop buttons don't update enabled state
|
||||
- http://en.wikipedia.org/wiki/Portal:Current_events - 'f' shows more hints than 'F' (on left side of nav bar)
|
||||
- gu and gU don't work on local files properly
|
||||
- dpb| 09:09:56 dpb :: when I save a page with vimperator, it adds <hints
|
||||
id="hah_hints"></hints> near the end of it.. kinda annoying
|
||||
dpb| 09:11:50 dpb :: and this happens only when saving the complete
|
||||
webpage, saving only the html works just fine..
|
||||
- <ESC> key closes :addons window
|
||||
- <ESC> key closes :addons and other XUL windows
|
||||
|
||||
|
||||
FEATURES:
|
||||
9 marks of a Location, [m a-zA-Z] to set it, [` a-zA-Z] to go there
|
||||
[m 0-9] marks a buffer instead [' 0-9] goes there
|
||||
also mark bookmarks (with M[a-zA-Z] maybe and use only lowercase marks for inbuffer marks?)
|
||||
also support :mark and :marks
|
||||
8 :map commands to keys
|
||||
8 :command for new commands
|
||||
9 :map commands to keys
|
||||
9 :command for new commands
|
||||
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
|
||||
8 Use our own find-as-you-type mechanism (like conkeror does)
|
||||
8 make hints smarter, not only with characters from from hintchars, but use "NE" or "NP" for 'new posts' e.g. (might be too slow)
|
||||
7 [ctrl-o/i] to Go back to a Previous Position (done partly, however currenty does not use a per tab jumplist)
|
||||
7 provide a buffer on the bottom where more than 1 line messages can be shown, preferrable
|
||||
with color support (for things like :echo line1\nline2)
|
||||
7 make hints smarter, not only with characters from from hintchars, but use "NE" or "NP" for 'new posts' e.g. (might be too slow)
|
||||
7 whereever possible: get rid of dialogs and ask console-like dialog questions or write error prompts directly on the webpage or with :echo()
|
||||
7 Ctrl-6/Ctrl-^ -> jump to the previously active tab
|
||||
7 3d should delete 3 tabs
|
||||
|
||||
@@ -653,7 +653,7 @@ function Mappings()//{{{
|
||||
));
|
||||
// if you ever add/remove keys here, also check them in the vimperaotr.onEvent()
|
||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<Esc>", "<C-[>"],
|
||||
onEscape,
|
||||
vimperator.events.onEscape,
|
||||
{
|
||||
short_help: "Cancel any operation",
|
||||
help: "Exits any command line or hint mode and returns to browser mode.<br/>" +
|
||||
|
||||
@@ -48,6 +48,10 @@ function init()
|
||||
|
||||
// these inner classes are created here, because outside the init()
|
||||
// function, the chrome:// is not ready
|
||||
|
||||
// TODO: can these classes be moved into a namesspace to now clobber
|
||||
// the main namespace?
|
||||
Vimperator.prototype.events = new Events;
|
||||
Vimperator.prototype.commands = new Commands;
|
||||
Vimperator.prototype.bookmarks = new Bookmarks;
|
||||
Vimperator.prototype.history = new History;
|
||||
@@ -71,7 +75,8 @@ function init()
|
||||
|
||||
// this function adds all our required listeners to react on events
|
||||
// also stuff like window.onScroll is handled there.
|
||||
addEventListeners();
|
||||
//addEventListeners();
|
||||
//vimperator.events();
|
||||
|
||||
set_showtabline(get_pref("showtabline"));
|
||||
set_guioptions(get_pref("guioptions"));
|
||||
@@ -126,26 +131,11 @@ function unload()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// focus and mode handling //////////////////////////////////////// {{{1
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
function onEscape()
|
||||
{
|
||||
if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY))
|
||||
{
|
||||
vimperator.setMode(vimperator.modes.NORMAL);
|
||||
vimperator.echo("");
|
||||
hah.disableHahMode();
|
||||
vimperator.focusContent();
|
||||
vimperator.statusline.updateUrl();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// event listeners //////////////////////////////////////////////// {{{1
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
function addEventListeners()
|
||||
function Events() //{{{1
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// CONSTRUCTOR /////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// any window related events
|
||||
window.addEventListener("unload", unload, false);
|
||||
window.addEventListener("keypress", vimperator.onEvent, true);
|
||||
@@ -173,6 +163,7 @@ function addEventListeners()
|
||||
vimperator.statusline.updateTabCount();
|
||||
updateBufferList();
|
||||
}, false);
|
||||
|
||||
// this adds an event which is is called on each page load, even if the
|
||||
// page is loaded in a background tab
|
||||
getBrowser().addEventListener("load", onPageLoad, true);
|
||||
@@ -188,8 +179,100 @@ function addEventListeners()
|
||||
//alert("titlechanged");
|
||||
}, null);
|
||||
|
||||
// for setOverLink() XXX: maybe there is an addEventListener way
|
||||
window.XULBrowserWindow = buffer_changed_listener;
|
||||
|
||||
|
||||
this.progressListener =
|
||||
{
|
||||
QueryInterface: function(aIID)
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) || // for setOverLink();
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
// XXX: function may later be needed to detect a canceled synchronous openURL()
|
||||
onStateChange: function(webProgress, aRequest, flags, aStatus)
|
||||
{
|
||||
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
|
||||
// receive statechange events for loading images and other parts of the web page
|
||||
if(flags & (Components.interfaces.nsIWebProgressListener.STATE_IS_DOCUMENT |
|
||||
Components.interfaces.nsIWebProgressListener.STATE_IS_WINDOW))
|
||||
{
|
||||
// This fires when the load event is initiated
|
||||
if(flags & Components.interfaces.nsIWebProgressListener.STATE_START)
|
||||
{
|
||||
vimperator.statusline.updateProgress(0);
|
||||
}
|
||||
else if (flags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
|
||||
;// vimperator.statusline.updateUrl();
|
||||
}
|
||||
},
|
||||
// for notifying the user about secure web pages
|
||||
onSecurityChange: function (webProgress, aRequest, aState)
|
||||
{
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
if(aState & nsIWebProgressListener.STATE_IS_INSECURE)
|
||||
vimperator.statusline.setClass("insecure");
|
||||
else if(aState & nsIWebProgressListener.STATE_IS_BROKEN)
|
||||
vimperator.statusline.setClass("broken");
|
||||
else if(aState & nsIWebProgressListener.STATE_IS_SECURE)
|
||||
vimperator.statusline.setClass("secure");
|
||||
},
|
||||
onStatusChange: function(webProgress, request, status, message)
|
||||
{
|
||||
vimperator.statusline.updateUrl(message);
|
||||
},
|
||||
onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
|
||||
{
|
||||
vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress);
|
||||
},
|
||||
// happens when the users switches tabs
|
||||
onLocationChange: function()
|
||||
{
|
||||
// if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
||||
// hah.disableHahMode();
|
||||
|
||||
vimperator.statusline.updateUrl();
|
||||
vimperator.statusline.updateProgress();
|
||||
|
||||
// if this is not delayed we get the wrong position of the old buffer
|
||||
setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100);
|
||||
},
|
||||
// called at the very end of a page load
|
||||
asyncUpdateUI: function()
|
||||
{
|
||||
vimperator.statusline.updateUrl();
|
||||
},
|
||||
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.setMode(); // trick to reshow the mode in the command line
|
||||
}
|
||||
},
|
||||
|
||||
// stub functions for the interfaces
|
||||
setJSStatus : function(status) { },
|
||||
setJSDefaultStatus : function(status) { },
|
||||
setDefaultStatus : function(status) { },
|
||||
onLinkIconAvailable: function() { }
|
||||
}
|
||||
window.XULBrowserWindow = this.progressListener;
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
|
||||
@@ -198,130 +281,57 @@ function addEventListeners()
|
||||
.XULBrowserWindow = window.XULBrowserWindow;
|
||||
|
||||
// for onStateChange(), etc.:
|
||||
getBrowser().addProgressListener(buffer_changed_listener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
}
|
||||
getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
|
||||
function onPageLoad(event)
|
||||
{
|
||||
if (event.originalTarget instanceof HTMLDocument)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
function onPageLoad(event)
|
||||
{
|
||||
var doc = event.originalTarget;
|
||||
// document is part of a frameset
|
||||
if (doc.defaultView.frameElement)
|
||||
if (event.originalTarget instanceof HTMLDocument)
|
||||
{
|
||||
// hacky way to get rid of "Transfering data from ..." on sites with frames
|
||||
// when you click on a link inside a frameset, because asyncUpdateUI
|
||||
// is not triggered there (firefox bug?)
|
||||
setTimeout(vimperator.statusline.updateUrl, 10);
|
||||
return;
|
||||
}
|
||||
var doc = event.originalTarget;
|
||||
// document is part of a frameset
|
||||
if (doc.defaultView.frameElement)
|
||||
{
|
||||
// hacky way to get rid of "Transfering data from ..." on sites with frames
|
||||
// when you click on a link inside a frameset, because asyncUpdateUI
|
||||
// is not triggered there (firefox bug?)
|
||||
setTimeout(vimperator.statusline.updateUrl, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
// code which should happen for all (also background) newly loaded tabs goes here:
|
||||
updateBufferList();
|
||||
// code which should happen for all (also background) newly loaded tabs goes here:
|
||||
updateBufferList();
|
||||
|
||||
//update history
|
||||
var url = getCurrentLocation();
|
||||
var title = getCurrentTitle(); // not perfect "- Vimperator" in the title
|
||||
vimperator.history.add(url, title);
|
||||
//update history
|
||||
var url = getCurrentLocation();
|
||||
var title = getCurrentTitle(); // not perfect "- Vimperator" in the title
|
||||
vimperator.history.add(url, title);
|
||||
|
||||
// code which is only relevant if the page load is the current tab goes here:
|
||||
if(doc == getBrowser().selectedBrowser.contentDocument)
|
||||
{
|
||||
/* none yet */
|
||||
// code which is only relevant if the page load is the current tab goes here:
|
||||
if(doc == getBrowser().selectedBrowser.contentDocument)
|
||||
{
|
||||
/* none yet */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var buffer_changed_listener =
|
||||
{
|
||||
QueryInterface: function(aIID)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
this.onEscape = function()
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) || // for setOverLink();
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
// XXX: function may later be needed to detect a canceled synchronous openURL()
|
||||
onStateChange: function(webProgress, aRequest, flags, aStatus)
|
||||
{
|
||||
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
|
||||
// receive statechange events for loading images and other parts of the web page
|
||||
if(flags & (Components.interfaces.nsIWebProgressListener.STATE_IS_DOCUMENT |
|
||||
Components.interfaces.nsIWebProgressListener.STATE_IS_WINDOW))
|
||||
if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY))
|
||||
{
|
||||
// This fires when the load event is initiated
|
||||
if(flags & Components.interfaces.nsIWebProgressListener.STATE_START)
|
||||
{
|
||||
vimperator.statusline.updateProgress(0);
|
||||
}
|
||||
else if (flags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
|
||||
;// vimperator.statusline.updateUrl();
|
||||
vimperator.setMode(vimperator.modes.NORMAL);
|
||||
vimperator.echo("");
|
||||
hah.disableHahMode();
|
||||
vimperator.focusContent();
|
||||
vimperator.statusline.updateUrl();
|
||||
}
|
||||
},
|
||||
// for notifying the user about secure web pages
|
||||
onSecurityChange: function (webProgress, aRequest, aState)
|
||||
{
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
if(aState & nsIWebProgressListener.STATE_IS_INSECURE)
|
||||
vimperator.statusline.setClass("insecure");
|
||||
else if(aState & nsIWebProgressListener.STATE_IS_BROKEN)
|
||||
vimperator.statusline.setClass("broken");
|
||||
else if(aState & nsIWebProgressListener.STATE_IS_SECURE)
|
||||
vimperator.statusline.setClass("secure");
|
||||
},
|
||||
onStatusChange: function(webProgress, request, status, message)
|
||||
{
|
||||
vimperator.statusline.updateUrl(message);
|
||||
},
|
||||
onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
|
||||
{
|
||||
vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress);
|
||||
},
|
||||
// happens when the users switches tabs
|
||||
onLocationChange: function()
|
||||
{
|
||||
// if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
||||
// hah.disableHahMode();
|
||||
|
||||
vimperator.statusline.updateUrl();
|
||||
vimperator.statusline.updateProgress();
|
||||
|
||||
// if this is not delayed we get the wrong position of the old buffer
|
||||
setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100);
|
||||
},
|
||||
// called at the very end of a page load
|
||||
asyncUpdateUI: function()
|
||||
{
|
||||
vimperator.statusline.updateUrl();
|
||||
},
|
||||
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.setMode(); // trick to reshow the mode in the command line
|
||||
}
|
||||
},
|
||||
|
||||
// stub functions for the interfaces
|
||||
setJSStatus : function(status) { },
|
||||
setJSDefaultStatus : function(status) { },
|
||||
setDefaultStatus : function(status) { },
|
||||
onLinkIconAvailable: function() { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -532,7 +542,7 @@ function getLinkNodes(doc)
|
||||
return links;
|
||||
}//}}}
|
||||
|
||||
function Vimperator()
|
||||
function Vimperator() //{{{1
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
@@ -910,7 +920,7 @@ function Vimperator()
|
||||
* Firefox 3.0, then this class should go away and their tab methods should be used
|
||||
* @deprecated
|
||||
*/
|
||||
function Tabs()
|
||||
function Tabs() //{{{1
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
|
||||
@@ -104,7 +104,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_open_vimbar" key=":" oncommand="vimperator.commandline.open(':', '', MODE_EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="onEscape();"/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="vimperator.events.onEscape();"/>
|
||||
<!-- other keys are handled inside vimperator.js event loop -->
|
||||
</keyset>
|
||||
</window>
|
||||
|
||||
Reference in New Issue
Block a user