mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 20:27:58 +01:00
version 0.3, added ignorekeys support
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,9 +1,16 @@
|
||||
<pre>
|
||||
date:
|
||||
17/04/2007:
|
||||
* version 0.3
|
||||
* added <C-v> support to pass one key to firefox (patch by Muthu Kannan)
|
||||
* also 'I' will go to 'ignorekeys' mode until esc is pressed, presenting a workaround
|
||||
for many javascript form fields like GMail, until something better comes along.
|
||||
* Vimperator can now be automatically updated in the :addons screen like other extensions
|
||||
* fixed :tabnext/:tabprevious commands
|
||||
* documented 's' guioptions flag for statusbar
|
||||
* documented 's' and 'b' guioptions flag for statusbar/bookmark bar
|
||||
* implemented the possibility to use CTRL-[ as an alternative to ESC, to leave the command line
|
||||
* added <C-Tab> and <C-S-Tab> support for switching tabs without beeping
|
||||
* ability to use shift and ctrl with special keys like F1 in mappings
|
||||
* small documentation and other fixes
|
||||
|
||||
11/04/2007:
|
||||
* version 0.2
|
||||
|
||||
5
Donators
5
Donators
@@ -1 +1,6 @@
|
||||
<pre>
|
||||
<b>Note:</b> If you don't wish to appear on this list when making a donation, please tell me.
|
||||
Also if you want the amount or email adress or whatever listet, send me an email.
|
||||
|
||||
* Andrew Pantyukhin
|
||||
</pre>
|
||||
|
||||
4
TODO
4
TODO
@@ -6,6 +6,7 @@ BUGS:
|
||||
- switching tabs while HINT_MODE_ALWAYS is on does not redisplay hints in new tabs, but exits hint mode
|
||||
- hints are not placed correctly when zoom is used
|
||||
- flashing frame is not perfect
|
||||
- The RSS feed button in the address bar no longer works.
|
||||
|
||||
FEATURES:
|
||||
9 marks of a Location (also should work with directories), [m a-zA-Z] to set it, [' a-zA-Z] to go there
|
||||
@@ -19,6 +20,7 @@ FEATURES:
|
||||
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
|
||||
8 [ctrl-o/i] to Go back to a Previous Position (done partly, however currenty does not use a per tab jumplist)
|
||||
8 Use our own find-as-you-type mechanism (like conkeror does)
|
||||
8 A way to temporaily disable vimperator keys (for sites like gmail)
|
||||
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 :hardcopy -> printing
|
||||
@@ -38,9 +40,11 @@ FEATURES:
|
||||
6 make a real one-tab-mode, divert _all_ other targets, possible by setting a firefox option (set popup=0-3)
|
||||
6 Shift-Insert in textboxes pastes clipboard contents
|
||||
5 Use arrow keys in preview window
|
||||
5 Sort :open completion by date?
|
||||
5 make use of the ] and [ keys to e.g. jump to the next heading ]], next image ]i, previous textbox [t and so on
|
||||
5 add tag support to adding/deleting bookmarks
|
||||
4 Support multiple top-level windows?
|
||||
4 :restart command to restart firefox
|
||||
3 Splitting Windows with [:sp :vsp ctrl-w,s ctrl-w,v] and closing with [ctrl-w,q], moving with [ctrl-w,w or tab]
|
||||
3 :set should also set about:config options (with autocomplete)
|
||||
</pre>
|
||||
|
||||
4
build.sh
4
build.sh
@@ -1,4 +1,4 @@
|
||||
VERSION=0.2
|
||||
VERSION=0.3
|
||||
FILES="chrome/content/ chrome.manifest"
|
||||
|
||||
# echo Building XPI...
|
||||
@@ -14,7 +14,7 @@ cp -v chrome/vimperator.jar '/home/maxauthority/.mozilla/firefox/kc3gnd7k.defaul
|
||||
if [ x$1 = xxpi ]; then
|
||||
echo Building XPI...
|
||||
zip -r vimperator_$VERSION.xpi chrome/vimperator.jar install.rdf chrome.manifest TODO
|
||||
#mv vimperator-firefox-$VERSION.xpi ../downloads
|
||||
mv vimperator-firefox-$VERSION.xpi ../downloads
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -365,14 +365,14 @@ var g_mappings = [/*{{{*/
|
||||
function(count) { openURLsInNewTab(readFromClipboard(), false); }
|
||||
],
|
||||
[
|
||||
["gt", "<C-n>"],
|
||||
["gt", "<C-n>", "<C-Tab>"],
|
||||
"Go to next tab",
|
||||
"Cycles to the first tab, when the last is selected.<br>"+
|
||||
"Count is supported, <code class=mapping>3gt</code> goes to the third tab.",
|
||||
function(count) { tab_go(count > 0 ? count : 0); }
|
||||
],
|
||||
[
|
||||
["gT", "<C-p>"],
|
||||
["gT", "<C-p>", "<C-S-Tab>"],
|
||||
"Go to previous tab",
|
||||
"Cycles to the last tab, when the first is selected.<br>"+
|
||||
"Count is supported, <code class=mapping>3gt</code> goes to the third tab.",
|
||||
@@ -399,8 +399,8 @@ var g_mappings = [/*{{{*/
|
||||
[
|
||||
["P"],
|
||||
"Open (put) an URL based on the current Clipboard contents in a new buffer",
|
||||
"If the new buffer is activated, depends on the <code class=setting>'activate'</code> setting."+
|
||||
"You can also just select some non-URL text, and search for it with the default search engine with <code class=mapping>p</code>",
|
||||
"Works like <code class=mapping>p</code>, but opens a new tab.<br>"+
|
||||
"Whether the new buffer is activated, depends on the <code class=setting>'activate'</code> setting.",
|
||||
function(count) { openURLsInNewTab(readFromClipboard(), true); }
|
||||
],
|
||||
[
|
||||
@@ -625,7 +625,7 @@ var g_mappings = [/*{{{*/
|
||||
["<F1>"],
|
||||
"Open help window",
|
||||
"The default section is shown, if you need help for a specific topic, try <code class=command>:help <F1></code> (jumping to a specific section not implemented yet).",
|
||||
function(count) { execute_command(0, 'help', false, ''); }
|
||||
function(count) { help(null); }
|
||||
],
|
||||
[
|
||||
[":"],
|
||||
@@ -634,7 +634,24 @@ var g_mappings = [/*{{{*/
|
||||
function(count) { openVimperatorBar(null); }
|
||||
],
|
||||
[
|
||||
["<Esc>", "<C-[>"],
|
||||
["I"],
|
||||
"Disable vimperator keys",
|
||||
"Starts an 'ignorekeys' mode, where all keys except <code class=mapping><Esc></code> are passed to the next event handler.<br>"+
|
||||
"This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore." +
|
||||
"To exit this mode, press <code class=mapping><Esc></code>. If you also need to pass <code class=mapping><Esc></code>"+
|
||||
"<code class=mapping><Esc></code> in this mode to the webpage, prepend it with <code class=mapping><C-v></code>.",
|
||||
function(count) { addMode(MODE_ESCAPE_ALL_KEYS); echo("Vimperator keys disabled. Press <Esc> to reenable.");}
|
||||
],
|
||||
[
|
||||
["<C-v>"], // if you ever add/remove keys here, also check them in the onVimperatorKeypress() function
|
||||
"Escape next key",
|
||||
"If you need to pass a certain key to a javascript form field or another extension prefix the key with <code class=mapping><C-v></code>.<br>"+
|
||||
"Also works to unshadow Firefox shortcuts like <code class=mapping><C-o></code> which are otherwise hidden in Vimperator.<br>"+
|
||||
"When in 'ignorekeys' mode (activated by <code class=mapping><I></code>), <code class=mapping><C-v></code> will pass the next key to Vimperator instead of the webpage.",
|
||||
function(count) { addMode(MODE_ESCAPE_ONE_KEY); }
|
||||
],
|
||||
[
|
||||
["<Esc>", "<C-[>"], // if you ever add/remove keys here, also check them in the onVimperatorKeypress() function
|
||||
"Cancel any operation",
|
||||
"Stops loading the current webpage and exits any command line or hint mode.<br>"+
|
||||
"Also focuses the web page, in case a form field has focus, and eats our key presses.",
|
||||
@@ -1665,6 +1682,33 @@ function toggle_images() {
|
||||
message ("imageBehavior set to " + pref);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// mode related functions ///////////////////////////////////////// {{{1
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// set current mode
|
||||
function setCurrentMode(mode)
|
||||
{
|
||||
g_current_mode = mode;
|
||||
}
|
||||
// get current mode
|
||||
function hasMode(mode)
|
||||
{
|
||||
return g_current_mode & mode;
|
||||
}
|
||||
// add to current mode
|
||||
function addMode(mode)
|
||||
{
|
||||
g_current_mode |= mode;
|
||||
return g_current_mode;
|
||||
}
|
||||
// get current mode
|
||||
function removeMode(mode)
|
||||
{
|
||||
g_current_mode = (g_current_mode | mode) ^ mode;
|
||||
return g_current_mode;
|
||||
}
|
||||
|
||||
|
||||
// function keycodeToName(keyCode) {
|
||||
// for (keyName in KeyboardEvent.prototype) {
|
||||
|
||||
@@ -26,12 +26,13 @@ the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the MPL, the GPL or the LGPL.
|
||||
}}} ***** END LICENSE BLOCK *****/
|
||||
|
||||
var Modes = { // XXX: not yet used
|
||||
MODE_NORMAL: 1,
|
||||
MODE_INSERT: 2,
|
||||
MODE_HAH_MAGIC: 3 // when we are holding space for hah input
|
||||
};
|
||||
var current_mode = Modes.MODE_NORMAL;
|
||||
const MODE_NORMAL = 1;
|
||||
const MODE_INSERT = 2;
|
||||
const MODE_VISUAL = 4;
|
||||
const MODE_ESCAPE_ONE_KEY = 8;
|
||||
const MODE_ESCAPE_ALL_KEYS = 16;
|
||||
|
||||
var g_current_mode = MODE_NORMAL;
|
||||
var popup_allowed_events; // need to change and reset this firefox pref
|
||||
|
||||
var g_inputbuffer = ""; // here we store partial commands (e.g. 'g' if you want to type 'gg')
|
||||
@@ -199,6 +200,9 @@ function init()
|
||||
updateStatusbar();
|
||||
}, false);
|
||||
|
||||
// we always start in normal mode
|
||||
setCurrentMode(MODE_NORMAL);
|
||||
|
||||
/*** load our preferences ***/
|
||||
load_history();
|
||||
|
||||
@@ -280,10 +284,32 @@ function unload()
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
function onVimperatorKeypress(event)/*{{{*/
|
||||
{
|
||||
// change the event to a usable string representation
|
||||
var key = keyToString(event);
|
||||
// alert(key);
|
||||
if (key == null)
|
||||
return false;
|
||||
|
||||
// XXX: for now only, later: input mappings if form element focused
|
||||
if (isFormElemFocused())
|
||||
return false;
|
||||
|
||||
// handle Escape-one-key mode (Ctrl-v)
|
||||
if (hasMode(MODE_ESCAPE_ONE_KEY) && !hasMode(MODE_ESCAPE_ALL_KEYS))
|
||||
{
|
||||
removeMode(MODE_ESCAPE_ONE_KEY);
|
||||
return false;
|
||||
}
|
||||
// handle Escape-all-keys mode (I)
|
||||
if (hasMode(MODE_ESCAPE_ALL_KEYS))
|
||||
{
|
||||
if(hasMode(MODE_ESCAPE_ONE_KEY))
|
||||
removeMode(MODE_ESCAPE_ONE_KEY); // and then let flow continue
|
||||
else if (key == "<Esc>" || key == "<C-[>" || key == "<C-v>")
|
||||
; // let flow continue to handle these keys
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// // FIXME: handle middle click in content area {{{
|
||||
// // alert(event.target.id);
|
||||
@@ -305,10 +331,7 @@ function onVimperatorKeypress(event)/*{{{*/
|
||||
// return true;
|
||||
// } }}}
|
||||
|
||||
// change the event to a usable string representation
|
||||
var key = keyToString(event);
|
||||
if (key == null)
|
||||
return false;
|
||||
|
||||
|
||||
// if Hit-a-hint mode is on, special handling of keys is required
|
||||
// g_hint_mappings is used
|
||||
@@ -460,6 +483,9 @@ function onVimperatorKeypress(event)/*{{{*/
|
||||
{
|
||||
g_inputbuffer = "";
|
||||
beep();
|
||||
// event.preventDefault();
|
||||
// event.preventBubble(); XXX:
|
||||
// event.stopPropagation();
|
||||
}
|
||||
|
||||
updateStatusbar();
|
||||
@@ -722,15 +748,13 @@ function openVimperatorBar(str)
|
||||
|
||||
function onEscape()
|
||||
{
|
||||
if (!hasMode(MODE_ESCAPE_ONE_KEY))
|
||||
{
|
||||
setCurrentMode(MODE_NORMAL);
|
||||
BrowserStop();
|
||||
focusContent(true, true);
|
||||
hah.disableHahMode();
|
||||
}
|
||||
|
||||
function onBlur() // FIXME: needed?
|
||||
{
|
||||
//alert('blur');
|
||||
//focusContent(false, false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -845,13 +869,12 @@ function logMessage(msg)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// this function gets an event as the input and converts it to
|
||||
// a keycode which can be used in mappings
|
||||
// e.g. pressing ctrl+n would result in the string "<c-n>"
|
||||
// e.g. pressing ctrl+n would result in the string "<C-n>"
|
||||
// null if unknown key
|
||||
function keyToString(event)
|
||||
{
|
||||
var key = String.fromCharCode(event.charCode);
|
||||
var modifier = "";
|
||||
if (event.charCode > 0)
|
||||
{
|
||||
if (event.ctrlKey)
|
||||
modifier += "C-";
|
||||
if (event.altKey)
|
||||
@@ -859,64 +882,74 @@ function keyToString(event)
|
||||
if (event.metaKey)
|
||||
modifier += "M-";
|
||||
|
||||
if (event.charCode == 0)
|
||||
{
|
||||
if (event.shiftKey)
|
||||
modifier += "S-";
|
||||
if (event.keyCode == KeyEvent.DOM_VK_ESCAPE)
|
||||
key = "Esc";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_RETURN)
|
||||
key = "Return";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_TAB)
|
||||
key = "Tab";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_DELETE)
|
||||
key = "Del";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_BACK_SPACE)
|
||||
key = "BS";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_HOME)
|
||||
key = "Home";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_END)
|
||||
key = "End";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_LEFT)
|
||||
key = "Left";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_RIGHT)
|
||||
key = "Right";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_UP)
|
||||
key = "Up";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_DOWN)
|
||||
key = "Down";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_PAGE_UP)
|
||||
key = "PageUp";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)
|
||||
key = "PageDown";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F1)
|
||||
key = "F1";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F2)
|
||||
key = "F2";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F3)
|
||||
key = "F3";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F4)
|
||||
key = "F4";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F5)
|
||||
key = "F5";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F6)
|
||||
key = "F6";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F7)
|
||||
key = "F7";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F8)
|
||||
key = "F8";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F9)
|
||||
key = "F9";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F10)
|
||||
key = "F10";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F11)
|
||||
key = "F11";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F12)
|
||||
key = "F12";
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
// a normal key like a, b, c, 0, etc.
|
||||
if (event.charCode > 0)
|
||||
{
|
||||
if (modifier.length > 0)
|
||||
return "<" + modifier + key + ">";
|
||||
else
|
||||
return key;
|
||||
}
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_ESCAPE)
|
||||
return "<Esc>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_RETURN)
|
||||
return "<Return>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_TAB)
|
||||
return "<Tab>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_DELETE)
|
||||
return "<Del>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_BACK_SPACE)
|
||||
return "<BS>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_HOME)
|
||||
return "<Home>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_END)
|
||||
return "<End>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_LEFT)
|
||||
return "<Left>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_RIGHT)
|
||||
return "<Right>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_UP)
|
||||
return "<Up>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_DOWN)
|
||||
return "<Down>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_PAGE_UP)
|
||||
return "<PageUp>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)
|
||||
return "<PageDown>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F1)
|
||||
return "<F1>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F2)
|
||||
return "<F2>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F3)
|
||||
return "<F3>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F4)
|
||||
return "<F4>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F5)
|
||||
return "<F5>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F6)
|
||||
return "<F6>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F7)
|
||||
return "<F7>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F8)
|
||||
return "<F8>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F9)
|
||||
return "<F9>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F10)
|
||||
return "<F10>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F11)
|
||||
return "<F11>";
|
||||
else if (event.keyCode == KeyEvent.DOM_VK_F12)
|
||||
return "<F12>";
|
||||
|
||||
// if nothing matches
|
||||
return null;
|
||||
else // a key like F1 is always enclosed in < and >
|
||||
return "<" + modifier + key + ">";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>{f9570b26-e246-4753-9b68-61aa95994237}</em:id>
|
||||
<em:name>Vimperator</em:name>
|
||||
<em:version>0.2</em:version>
|
||||
<em:version>0.3</em:version>
|
||||
<em:description>Make Firefox work like Vim</em:description>
|
||||
<em:creator>Martin Stubenschrott</em:creator>
|
||||
<em:homepageURL>http://vimperator.mozdev.org</em:homepageURL>
|
||||
|
||||
Reference in New Issue
Block a user