1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 02:24:12 +01:00

start of a caret mode

This commit is contained in:
Martin Stubenschrott
2007-09-06 14:24:18 +00:00
parent 3ff2cccc37
commit 5f6958521e
5 changed files with 63 additions and 6 deletions

View File

@@ -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();
//}}}
} //}}}

View File

@@ -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); },
{

View File

@@ -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);
},

View File

@@ -117,9 +117,12 @@ the terms of any one of the MPL, the GPL or the LGPL.
<!-- other keys are handled inside vimperator.js event loop -->
</keyset>
<!--
<popupset id="vimperator-popupset">
<popup id="vimperator-visualbell"/>
</popupset>
-->
<panel id="vimperator-visualbell"/>
</window>
</overlay>