1
0
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:
Martin Stubenschrott
2007-06-09 13:39:13 +00:00
parent 2e143ffe1a
commit 36a2ec59ec
5 changed files with 154 additions and 148 deletions

View File

@@ -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
View File

@@ -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

View File

@@ -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/>" +

View File

@@ -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,52 +179,10 @@ function addEventListeners()
//alert("titlechanged");
}, null);
// for setOverLink() XXX: maybe there is an addEventListener way
window.XULBrowserWindow = buffer_changed_listener;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow;
// for onStateChange(), etc.:
getBrowser().addProgressListener(buffer_changed_listener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
}
function onPageLoad(event)
{
if (event.originalTarget instanceof HTMLDocument)
this.progressListener =
{
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();
//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 */
}
}
}
var buffer_changed_listener =
{
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
@@ -322,6 +271,67 @@ var buffer_changed_listener =
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
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow;
// for onStateChange(), etc.:
getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function onPageLoad(event)
{
if (event.originalTarget instanceof HTMLDocument)
{
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();
//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 */
}
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////// PUBLIC SECTION //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
this.onEscape = function()
{
if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY))
{
vimperator.setMode(vimperator.modes.NORMAL);
vimperator.echo("");
hah.disableHahMode();
vimperator.focusContent();
vimperator.statusline.updateUrl();
}
}
}
@@ -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 /////////////////////////////////////////

View File

@@ -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>