diff --git a/ChangeLog b/ChangeLog
index 7d42c941..f6ef512c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
-date:
+17/04/2007:
* version 0.3
+ * added 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 and 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
diff --git a/Donators b/Donators
index 82c30a43..b0fffa91 100644
--- a/Donators
+++ b/Donators
@@ -1 +1,6 @@
+
+Note: 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
+
diff --git a/TODO b/TODO
index a38155af..f2abc513 100644
--- a/TODO
+++ b/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)
diff --git a/build.sh b/build.sh
index f23aa325..852b72b2 100755
--- a/build.sh
+++ b/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
diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js
index 8452bdf0..428f3d52 100644
--- a/chrome/content/vimperator/commands.js
+++ b/chrome/content/vimperator/commands.js
@@ -365,14 +365,14 @@ var g_mappings = [/*{{{*/
function(count) { openURLsInNewTab(readFromClipboard(), false); }
],
[
- ["gt", ""],
+ ["gt", "", ""],
"Go to next tab",
"Cycles to the first tab, when the last is selected.
"+
"Count is supported, 3gt goes to the third tab.",
function(count) { tab_go(count > 0 ? count : 0); }
],
[
- ["gT", ""],
+ ["gT", "", ""],
"Go to previous tab",
"Cycles to the last tab, when the first is selected.
"+
"Count is supported, 3gt 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 'activate' setting."+
- "You can also just select some non-URL text, and search for it with the default search engine with p",
+ "Works like p, but opens a new tab.
"+
+ "Whether the new buffer is activated, depends on the 'activate' setting.",
function(count) { openURLsInNewTab(readFromClipboard(), true); }
],
[
@@ -625,7 +625,7 @@ var g_mappings = [/*{{{*/
[""],
"Open help window",
"The default section is shown, if you need help for a specific topic, try :help <F1> (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); }
],
[
- ["", ""],
+ ["I"],
+ "Disable vimperator keys",
+ "Starts an 'ignorekeys' mode, where all keys except <Esc> are passed to the next event handler.
"+
+ "This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore." +
+ "To exit this mode, press <Esc>. If you also need to pass <Esc>"+
+ "<Esc> in this mode to the webpage, prepend it with <C-v>.",
+ function(count) { addMode(MODE_ESCAPE_ALL_KEYS); echo("Vimperator keys disabled. Press to reenable.");}
+ ],
+ [
+ [""], // 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 <C-v>.
"+
+ "Also works to unshadow Firefox shortcuts like <C-o> which are otherwise hidden in Vimperator.
"+
+ "When in 'ignorekeys' mode (activated by <I>), <C-v> will pass the next key to Vimperator instead of the webpage.",
+ function(count) { addMode(MODE_ESCAPE_ONE_KEY); }
+ ],
+ [
+ ["", ""], // 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.
"+
"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) {
diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js
index 4971f393..919c63ed 100644
--- a/chrome/content/vimperator/vimperator.js
+++ b/chrome/content/vimperator/vimperator.js
@@ -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 == "" || key == "" || key == "")
+ ; // 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()
{
- BrowserStop();
- focusContent(true, true);
- hah.disableHahMode();
-}
-
-function onBlur() // FIXME: needed?
-{
- //alert('blur');
- //focusContent(false, false);
+ if (!hasMode(MODE_ESCAPE_ONE_KEY))
+ {
+ setCurrentMode(MODE_NORMAL);
+ BrowserStop();
+ focusContent(true, true);
+ hah.disableHahMode();
+ }
}
////////////////////////////////////////////////////////////////////////
@@ -845,78 +869,87 @@ 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 ""
+// e.g. pressing ctrl+n would result in the string ""
+// null if unknown key
function keyToString(event)
{
var key = String.fromCharCode(event.charCode);
var modifier = "";
+ if (event.ctrlKey)
+ modifier += "C-";
+ if (event.altKey)
+ modifier += "A-";
+ 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 (event.ctrlKey)
- modifier += "C-";
- if (event.altKey)
- modifier += "A-";
- if (event.metaKey)
- modifier += "M-";
-
if (modifier.length > 0)
return "<" + modifier + key + ">";
else
return key;
}
- else if (event.keyCode == KeyEvent.DOM_VK_ESCAPE)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_RETURN)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_TAB)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_DELETE)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_BACK_SPACE)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_HOME)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_END)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_LEFT)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_RIGHT)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_UP)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_DOWN)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_PAGE_UP)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_PAGE_DOWN)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F1)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F2)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F3)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F4)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F5)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F6)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F7)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F8)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F9)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F10)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F11)
- return "";
- else if (event.keyCode == KeyEvent.DOM_VK_F12)
- return "";
-
- // if nothing matches
- return null;
+ else // a key like F1 is always enclosed in < and >
+ return "<" + modifier + key + ">";
}
////////////////////////////////////////////////////////////////////////
diff --git a/install.rdf b/install.rdf
index 61e6eda0..e4ec614d 100644
--- a/install.rdf
+++ b/install.rdf
@@ -5,7 +5,7 @@
{f9570b26-e246-4753-9b68-61aa95994237}
Vimperator
- 0.2
+ 0.3
Make Firefox work like Vim
Martin Stubenschrott
http://vimperator.mozdev.org