diff --git a/NEWS b/NEWS index 3b0c63e1..a0a409d8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@
2007-xx-xx: * version 0.6 + * initial start of caret mode. Start with 'i', stop with* vimperator trys to stay in command mode after loading pages instead of having a text field focused * added a visual bell and replaced 'beep' with 'visualbell' * added vimperator logo (can be seen in the addons manager) diff --git a/chrome/content/vimperator/events.js b/chrome/content/vimperator/events.js index 62ab73e6..f3cbfe05 100644 --- a/chrome/content/vimperator/events.js +++ b/chrome/content/vimperator/events.js @@ -382,6 +382,10 @@ function Events() //{{{ { if (!vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY)) { + // setting this option will trigger an observer which will care about all other details + if (vimperator.hasMode(vimperator.modes.CARET)) + Options.setFirefoxPref("accessibility.browsewithcaret", false); + vimperator.setMode(vimperator.modes.NORMAL); vimperator.commandline.clear(); vimperator.hints.disableHahMode(); @@ -711,6 +715,41 @@ function Events() //{{{ .getInterface(Components.interfaces.nsIXULWindow) .XULBrowserWindow = window.XULBrowserWindow; getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); + + + this.prefObserver = + { + register: function() + { + var prefService = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + this._branch = prefService.getBranch(""); // better way to monitor all changes? + this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2); + this._branch.addObserver("", this, false); + }, + + unregister: function() + { + if(!this._branch) return; + this._branch.removeObserver("", this); + }, + + observe: function(aSubject, aTopic, aData) + { + if(aTopic != "nsPref:changed") return; + // aSubject is the nsIPrefBranch we're observing (after appropriate QI) + // aData is the name of the pref that's been changed (relative to aSubject) + switch (aData) + { + case "accessibility.browsewithcaret": + var value = Options.getFirefoxPref("accessibility.browsewithcaret", false); + vimperator.setMode(value ? vimperator.modes.CARET : vimperator.modes.NORMAL, null); + break; + } + } + } + this.prefObserver.register(); + //}}} } //}}} diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 40fdf6da..7f7fd0af 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -309,6 +309,18 @@ function Mappings() //{{{ help: "In command line mode, you can perform extended commands, which may require arguments." } )); + addDefaultMap(new Map(vimperator.modes.NORMAL, ["i"], + function() + { + Options.setFirefoxPref("accessibility.browsewithcaret", true); + vimperator.setMode(vimperator.modes.CARET, null); + }, + { + short_help: "Start caret mode", + help: "This mode resembles the vim normal mode where you see a text cursor and can move around. " + + "NOTE: Movement keys are not really working for the moment." + } + )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["I"], function() { vimperator.addMode(null, vimperator.modes.ESCAPE_ALL_KEYS); }, { diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 7fe4b3b7..1110193e 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -40,6 +40,7 @@ const vimperator = (function() //{{{ VISUAL: 1 << 2, HINTS: 1 << 3, COMMAND_LINE: 1 << 4, + CARET: 1 << 5, // text cursor is visible // extended modes EX: 1 << 10, READ_MULTILINE: 1 << 11, @@ -58,6 +59,7 @@ const vimperator = (function() //{{{ mode_messages[modes.INSERT] = "INSERT"; mode_messages[modes.VISUAL] = "VISUAL"; mode_messages[modes.HINTS] = "HINTS"; + mode_messages[modes.CARET] = "CARET"; // XXX: not a perfect name mode_messages[modes.ESCAPE_ONE_KEY] = "escape one key"; mode_messages[modes.ESCAPE_ALL_KEYS] = "escape all keys"; mode_messages[modes.ESCAPE_ONE_KEY | modes.ESCAPE_ALL_KEYS] = "pass one key"; @@ -92,13 +94,10 @@ const vimperator = (function() //{{{ return; } - if (str_mode && str_extended) + if (str_extended) str_extended = " (" + str_extended + ")"; else - { - str_extended = "(" + str_extended + ")"; - str_mode = ""; - } + str_extended = ""; vimperator.echo("-- " + str_mode + str_extended + " --"); } @@ -293,7 +292,10 @@ const vimperator = (function() //{{{ popup.height = box.height; popup.width = box.width; - popup.showPopup(win, box.screenX, box.screenY, "popup"); + ////popup.showPopup(win, box.screenX, box.screenY, "popup"); + //popup.showPopup(win, -1, -1, "popup", "topleft", "topleft"); + + popup.openPopup(win, "overlap", 0, 0, false, false) setTimeout(function() { popup.hidePopup(); }, 50); }, diff --git a/chrome/content/vimperator/vimperator.xul b/chrome/content/vimperator/vimperator.xul index 069f794e..baac399d 100644 --- a/chrome/content/vimperator/vimperator.xul +++ b/chrome/content/vimperator/vimperator.xul @@ -117,9 +117,12 @@ the terms of any one of the MPL, the GPL or the LGPL. + +