mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 23:58:00 +01:00
many small style improvements, some useless test functions added (yeah, that's why it's called "pre" software :))
This commit is contained in:
1
TODO
1
TODO
@@ -10,6 +10,7 @@ BUGS:
|
||||
- searching backwards incrementally does not work i.e. with 'incsearch' set
|
||||
- http://msdn2.microsoft.com/en-us/library/ms535258.aspx does not scroll with j/k/etc.
|
||||
same for http://forum.mootools.net/topic.php?id=3458
|
||||
- insert abbreviations broken on <space>
|
||||
|
||||
FEATURES:
|
||||
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
|
||||
|
||||
@@ -38,80 +38,6 @@ vimperator.Buffer = function () //{{{
|
||||
var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100,
|
||||
120, 150, 200, 300, 500, 1000, 2000 ];
|
||||
|
||||
// TODO: rename
|
||||
function followFrameRelationship(relationship, parsedFrame)
|
||||
{
|
||||
var regexps;
|
||||
var relText;
|
||||
var patternText;
|
||||
var revString;
|
||||
switch (relationship)
|
||||
{
|
||||
case "next":
|
||||
regexps = vimperator.options["nextpattern"].split(",");
|
||||
revString = "previous";
|
||||
break;
|
||||
case "previous":
|
||||
// TODO: accept prev\%[ious]
|
||||
regexps = vimperator.options["previouspattern"].split(",");
|
||||
revString = "next";
|
||||
break;
|
||||
default:
|
||||
vimperator.echoerr("Bad document relationship: " + relationship);
|
||||
}
|
||||
|
||||
relText = new RegExp(relationship, "i");
|
||||
revText = new RegExp(revString, "i");
|
||||
var elems = parsedFrame.document.getElementsByTagName("link");
|
||||
// links have higher priority than normal <a> hrefs
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (relText.test(elems[i].rel) || revText.test(elems[i].rev))
|
||||
{
|
||||
vimperator.open(elems[i].href);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no links? ok, look for hrefs
|
||||
elems = parsedFrame.document.getElementsByTagName("a");
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (relText.test(elems[i].rel) || revText.test(elems[i].rev))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (var pattern = 0; pattern < regexps.length; pattern++)
|
||||
{
|
||||
patternText = new RegExp(regexps[pattern], "i");
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (patternText.test(elems[i].textContent))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// images with alt text being href
|
||||
var children = elems[i].childNodes;
|
||||
for (var j = 0; j < children.length; j++)
|
||||
{
|
||||
if (patternText.test(children[j].alt))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setZoom(value, fullZoom)
|
||||
{
|
||||
if (value < 1 || value > 2000)
|
||||
@@ -216,6 +142,26 @@ vimperator.Buffer = function () //{{{
|
||||
win.scrollTo(h, v);
|
||||
}
|
||||
|
||||
vimperator.commands.add(new vimperator.Command(["test"],
|
||||
function (args, special)
|
||||
{
|
||||
alert(args)
|
||||
},
|
||||
{
|
||||
shortHelp: "Test command"
|
||||
}
|
||||
));
|
||||
vimperator.options.add(new vimperator.Option(["test"], "boolean",
|
||||
{
|
||||
shortHelp: "Test option",
|
||||
defaultValue: false
|
||||
}
|
||||
));
|
||||
vimperator.mappings.addDefault([vimperator.modes.NORMAL], ["w"], "Test",
|
||||
function () { alert("test"); }
|
||||
);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
@@ -310,7 +256,7 @@ vimperator.Buffer = function () //{{{
|
||||
},
|
||||
|
||||
// quick function to get elements inside the document reliably
|
||||
// argument "args" is something like: @id='myid' or @type='text' (don't forget the quoted around myid)
|
||||
// argument "args" is something like: @id='myid' or @type='text' (don't forget the quotes around myid)
|
||||
getElement: function (args, index)
|
||||
{
|
||||
return vimperator.buffer.evaluateXPath("//*[" + (args || "") + "]").snapshotItem(index || 0)
|
||||
@@ -434,11 +380,12 @@ vimperator.Buffer = function () //{{{
|
||||
return selection;
|
||||
},
|
||||
|
||||
// TODO: move to tabs.js
|
||||
list: function (fullmode)
|
||||
{
|
||||
if (fullmode)
|
||||
{
|
||||
// toggle the special buffer previw window
|
||||
// toggle the special buffer preview window
|
||||
if (vimperator.bufferwindow.visible())
|
||||
{
|
||||
vimperator.bufferwindow.hide();
|
||||
@@ -644,6 +591,7 @@ vimperator.Buffer = function () //{{{
|
||||
setTimeout(function () { doc.body.removeChild(indicator); }, 500);
|
||||
},
|
||||
|
||||
// XXX: probably remove this method/functionality
|
||||
// updates the buffer preview in place only if list is visible
|
||||
updateBufferList: function ()
|
||||
{
|
||||
@@ -655,7 +603,7 @@ vimperator.Buffer = function () //{{{
|
||||
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
|
||||
},
|
||||
|
||||
// XXX: should this be in v.buffers. or v.tabs.?
|
||||
// TODO: move to v.tabs.?
|
||||
// "buffer" is a string which matches the URL or title of a buffer, if it
|
||||
// is null, the last used string is used again
|
||||
switchTo: function (buffer, allowNonUnique, count, reverse)
|
||||
@@ -995,6 +943,79 @@ vimperator.Buffer = function () //{{{
|
||||
|
||||
followDocumentRelationship: function (relationship)
|
||||
{
|
||||
function followFrameRelationship(relationship, parsedFrame)
|
||||
{
|
||||
var regexps;
|
||||
var relText;
|
||||
var patternText;
|
||||
var revString;
|
||||
switch (relationship)
|
||||
{
|
||||
case "next":
|
||||
regexps = vimperator.options["nextpattern"].split(",");
|
||||
revString = "previous";
|
||||
break;
|
||||
case "previous":
|
||||
// TODO: accept prev\%[ious]
|
||||
regexps = vimperator.options["previouspattern"].split(",");
|
||||
revString = "next";
|
||||
break;
|
||||
default:
|
||||
vimperator.echoerr("Bad document relationship: " + relationship);
|
||||
}
|
||||
|
||||
relText = new RegExp(relationship, "i");
|
||||
revText = new RegExp(revString, "i");
|
||||
var elems = parsedFrame.document.getElementsByTagName("link");
|
||||
// links have higher priority than normal <a> hrefs
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (relText.test(elems[i].rel) || revText.test(elems[i].rev))
|
||||
{
|
||||
vimperator.open(elems[i].href);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// no links? ok, look for hrefs
|
||||
elems = parsedFrame.document.getElementsByTagName("a");
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (relText.test(elems[i].rel) || revText.test(elems[i].rev))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (var pattern = 0; pattern < regexps.length; pattern++)
|
||||
{
|
||||
patternText = new RegExp(regexps[pattern], "i");
|
||||
for (var i = 0; i < elems.length; i++)
|
||||
{
|
||||
if (patternText.test(elems[i].textContent))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// images with alt text being href
|
||||
var children = elems[i].childNodes;
|
||||
for (var j = 0; j < children.length; j++)
|
||||
{
|
||||
if (patternText.test(children[j].alt))
|
||||
{
|
||||
vimperator.buffer.followLink(elems[i], vimperator.CURRENT_TAB);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var retVal;
|
||||
if (window.content.frames.length != 0)
|
||||
{
|
||||
|
||||
@@ -470,6 +470,31 @@ vimperator.Editor = function () //{{{
|
||||
}
|
||||
},
|
||||
|
||||
// System for adding abbreviations:
|
||||
//
|
||||
// filter == ! delete all, and set first (END)
|
||||
//
|
||||
// if filter == ! remove all and add it as only END
|
||||
//
|
||||
// variant 1: rhs matches anywere in loop
|
||||
//
|
||||
// 1 mod matches anywhere in loop
|
||||
// a) simple replace and
|
||||
// I) (maybe there's another rhs that matches? not possible)
|
||||
// (when there's another item, it's opposite mod with different rhs)
|
||||
// (so do nothing further but END)
|
||||
//
|
||||
// 2 mod does not match
|
||||
// a) the opposite is there -> make a ! and put it as only and END
|
||||
// (b) a ! is there. do nothing END)
|
||||
//
|
||||
// variant 2: rhs matches *no*were in loop and filter is c or i
|
||||
// everykind of current combo is possible to 1 {c,i,!} or two {c and i}
|
||||
//
|
||||
// 1 mod is ! split into two i + c END
|
||||
// 1 not !: opposite mode (first), add/change 'second' and END
|
||||
// 1 not !: same mode (first), overwrite first this END
|
||||
//
|
||||
addAbbreviation: function (filter, lhs, rhs)
|
||||
{
|
||||
if (!abbrev[lhs])
|
||||
@@ -525,33 +550,6 @@ vimperator.Editor = function () //{{{
|
||||
abbrev[lhs][1] = [filter, rhs];
|
||||
else
|
||||
abbrev[lhs][0] = [filter, rhs];
|
||||
|
||||
return;
|
||||
|
||||
// System above:
|
||||
// filter == ! delete all, and set first (END)
|
||||
//
|
||||
// if filter == ! remove all and add it as only END
|
||||
//
|
||||
// variant 1: rhs matches anywere in loop
|
||||
//
|
||||
// 1 mod matches anywhere in loop
|
||||
// a) simple replace and
|
||||
// I) (maybe there's another rhs that matches? not possible)
|
||||
// (when there's another item, it's opposite mod with different rhs)
|
||||
// (so do nothing further but END)
|
||||
//
|
||||
// 2 mod does not match
|
||||
// a) the opposite is there -> make a ! and put it as only and END
|
||||
// (b) a ! is there. do nothing END)
|
||||
//
|
||||
// variant 2: rhs matches *no*were in loop and filter is c or i
|
||||
// everykind of current combo is possible to 1 {c,i,!} or two {c and i}
|
||||
//
|
||||
// 1 mod is ! split into two i + c END
|
||||
// 1 not !: opposite mode (first), add/change 'second' and END
|
||||
// 1 not !: same mode (first), overwrite first this END
|
||||
//
|
||||
},
|
||||
|
||||
removeAbbreviation: function (filter, lhs)
|
||||
|
||||
@@ -55,11 +55,30 @@ vimperator.AutoCommands = function() //{{{
|
||||
return autoCommandsIterator();
|
||||
},
|
||||
|
||||
add: function (auEvent, regex, cmds)
|
||||
{
|
||||
var eventsIter = auEvent.split(",");
|
||||
for (var i = 0; i < eventsIter.length; i++)
|
||||
{
|
||||
if (!autoCommands[eventsIter[i]])
|
||||
autoCommands[eventsIter[i]] = [];
|
||||
|
||||
var flag = true;
|
||||
for (var y = 0; y < autoCommands[eventsIter[i]].length; y++)
|
||||
{
|
||||
if (autoCommands[eventsIter[i]][y][0] == regex && autoCommands[eventsIter[i]][y][1] == cmds)
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
autoCommands[eventsIter[i]].push([regex, cmds]);
|
||||
}
|
||||
},
|
||||
|
||||
remove: function (auEvent, regex) // arguments are filters (NULL = all)
|
||||
{
|
||||
if (!auEvent && !regex)
|
||||
{
|
||||
autoCommands = {}; // delete all TODO: rather delete.. or something?
|
||||
autoCommands = {}; // delete all
|
||||
}
|
||||
else if (!regex) // remove all on this auEvent
|
||||
{
|
||||
@@ -69,7 +88,7 @@ vimperator.AutoCommands = function() //{{{
|
||||
delete autoCommands[item];
|
||||
}
|
||||
}
|
||||
else if (!auEvent) // delete all match's to this regex
|
||||
else if (!auEvent) // delete all matches to this regex
|
||||
{
|
||||
for (var item in autoCommands)
|
||||
{
|
||||
@@ -79,7 +98,7 @@ vimperator.AutoCommands = function() //{{{
|
||||
if (regex == autoCommands[item][i][0])
|
||||
{
|
||||
autoCommands[item].splice(i, 1); // remove array
|
||||
// keep `i' since this is removed, so a possible next one is at this place now)
|
||||
// keep `i' since this is removed, so a possible next one is at this place now
|
||||
}
|
||||
else
|
||||
i++;
|
||||
@@ -135,25 +154,6 @@ vimperator.AutoCommands = function() //{{{
|
||||
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
add: function (auEvent, regex, cmds)
|
||||
{
|
||||
var eventsIter = auEvent.split(",");
|
||||
for (var i = 0; i < eventsIter.length; i++)
|
||||
{
|
||||
if (!autoCommands[eventsIter[i]])
|
||||
autoCommands[eventsIter[i]] = [];
|
||||
|
||||
var flag = true;
|
||||
for (var y = 0; y < autoCommands[eventsIter[i]].length; y++)
|
||||
{
|
||||
if (autoCommands[eventsIter[i]][y][0] == regex && autoCommands[eventsIter[i]][y][1] == cmds)
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
autoCommands[eventsIter[i]].push([regex, cmds]);
|
||||
}
|
||||
},
|
||||
|
||||
trigger: function (auEvent, url)
|
||||
{
|
||||
if (autoCommands[auEvent])
|
||||
@@ -176,7 +176,7 @@ vimperator.Events = function () //{{{
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
var inputBufferLength = 0; // counts the number of keys in v.input.buffer (can be different from v.input.buffer.length)
|
||||
var inputBufferLength = 0; // count the number of keys in v.input.buffer (can be different from v.input.buffer.length)
|
||||
var skipMap = false; // while feeding the keys (stored in v.input.buffer | no map found) - ignore mappings
|
||||
|
||||
var macros = {};
|
||||
@@ -270,7 +270,7 @@ vimperator.Events = function () //{{{
|
||||
// NOTE: the order of ["Esc", "Escape"] or ["Escape", "Esc"]
|
||||
// matters, so use that string as the first item, that you
|
||||
// want to refer to within Vimperator's source code for
|
||||
// comparisons like if (key == "Esc") { ... }
|
||||
// comparisons like if (key == "<Esc>") { ... }
|
||||
var keyTable = [
|
||||
[ KeyEvent.DOM_VK_ESCAPE, ["Esc", "Escape"] ],
|
||||
[ KeyEvent.DOM_VK_LEFT_SHIFT, ["<"] ],
|
||||
@@ -390,8 +390,8 @@ vimperator.Events = function () //{{{
|
||||
// code which is only relevant if the page load is the current tab goes here:
|
||||
if (doc == getBrowser().selectedBrowser.contentDocument)
|
||||
{
|
||||
// // FIXME: this currently causes window map events which is _very_ annoying
|
||||
// // we want to stay in command mode after a page has loaded
|
||||
// we want to stay in command mode after a page has loaded
|
||||
// XXX: Does this still causes window map events which is _very_ annoying
|
||||
setTimeout(function () {
|
||||
var focused = document.commandDispatcher.focusedElement;
|
||||
if (focused && focused.value.length == 0)
|
||||
@@ -412,12 +412,12 @@ vimperator.Events = function () //{{{
|
||||
// if (vimperator.buffer.loaded == 1)
|
||||
// return true;
|
||||
|
||||
var ms = 10000; // maximum time to wait - TODO: add option
|
||||
var ms = 15000; // maximum time to wait - TODO: add option
|
||||
var then = new Date().getTime();
|
||||
for (var now = then; now - then < ms; now = new Date().getTime())
|
||||
{
|
||||
mainThread.processNextEvent(true);
|
||||
if ((now -then) % 1000 < 10)
|
||||
if ((now - then) % 1000 < 10)
|
||||
dump("waited: " + (now - then) + " ms\n");
|
||||
|
||||
if (vimperator.buffer.loaded > 0)
|
||||
@@ -615,7 +615,7 @@ vimperator.Events = function () //{{{
|
||||
{
|
||||
charCode = 0;
|
||||
}
|
||||
else //an invalid key like <A-xxx> was found, stop propagation here (like Vim)
|
||||
else // an invalid key like <A-xxx> was found, stop propagation here (like Vim)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -716,7 +716,6 @@ vimperator.Events = function () //{{{
|
||||
|
||||
// a key like F1 is always enclosed in < and >
|
||||
return "<" + modifier + key + ">";
|
||||
|
||||
},
|
||||
|
||||
isAcceptKey: function (key)
|
||||
@@ -797,18 +796,20 @@ vimperator.Events = function () //{{{
|
||||
{
|
||||
if (couldCopy)
|
||||
{
|
||||
if ((vimperator.mode == vimperator.modes.TEXTAREA || (vimperator.modes.extended & vimperator.modes.TEXTAREA))
|
||||
if ((vimperator.mode == vimperator.modes.TEXTAREA ||
|
||||
(vimperator.modes.extended & vimperator.modes.TEXTAREA))
|
||||
&& !vimperator.options["insertmode"])
|
||||
vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.TEXTAREA);
|
||||
else if (vimperator.mode == vimperator.modes.CARET)
|
||||
vimperator.modes.set(vimperator.modes.VISUAL, vimperator.modes.CARET);
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// XXX: disabled, as i think automatically starting visual caret mode does more harm than help
|
||||
// else
|
||||
// {
|
||||
// if (!couldCopy && vimperator.modes.extended & vimperator.modes.CARET)
|
||||
// vimperator.mode = vimperator.modes.CARET;
|
||||
//}
|
||||
// }
|
||||
},
|
||||
|
||||
// global escape handler, is called in ALL modes
|
||||
@@ -824,10 +825,18 @@ vimperator.Events = function () //{{{
|
||||
|
||||
switch (vimperator.mode)
|
||||
{
|
||||
case vimperator.modes.HINTS:
|
||||
case vimperator.modes.CUSTOM:
|
||||
case vimperator.modes.COMMAND_LINE:
|
||||
case vimperator.modes.NORMAL:
|
||||
// clear any selection made
|
||||
var selection = window.content.getSelection();
|
||||
try
|
||||
{ // a simple if (selection) does not seem to work
|
||||
selection.collapseToStart();
|
||||
}
|
||||
catch (e) { }
|
||||
vimperator.commandline.clear();
|
||||
|
||||
vimperator.modes.reset();
|
||||
vimperator.focusContent(true);
|
||||
break;
|
||||
|
||||
case vimperator.modes.VISUAL:
|
||||
@@ -855,19 +864,9 @@ vimperator.Events = function () //{{{
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
// clear any selection made
|
||||
var selection = window.content.getSelection();
|
||||
try
|
||||
{ // a simple if (selection) does not seem to work
|
||||
selection.collapseToStart();
|
||||
}
|
||||
catch (e) { }
|
||||
vimperator.commandline.clear();
|
||||
|
||||
default: // HINTS, CUSTOM or COMMAND_LINE
|
||||
vimperator.modes.reset();
|
||||
vimperator.focusContent(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -925,16 +924,9 @@ vimperator.Events = function () //{{{
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIXME: proper way is to have a better onFocus handler which also handles events for the XUL
|
||||
if (!vimperator.mode == vimperator.modes.TEXTAREA &&
|
||||
!vimperator.mode == vimperator.modes.INSERT &&
|
||||
!vimperator.mode == vimperator.modes.COMMAND_LINE &&
|
||||
isFormElemFocused()) // non insert mode, but e.g. the location bar has focus
|
||||
return false;
|
||||
|
||||
// just forward event, without checking any mappings
|
||||
// just forward event without checking any mappings when the MOW is open
|
||||
if (vimperator.mode == vimperator.modes.COMMAND_LINE &&
|
||||
vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE)
|
||||
(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE))
|
||||
{
|
||||
vimperator.commandline.onMultilineOutputEvent(event);
|
||||
return false;
|
||||
@@ -1007,12 +999,12 @@ vimperator.Events = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME (maybe): (is an ESC or C-] here): on HINTS mode, it enters
|
||||
//into 'if (map && !skipMap) below. With that (or however) it
|
||||
//triggers the onEscape part, where it resets mode. Here I just
|
||||
//return true, with the effect that it also gets to there (for
|
||||
//whatever reason). if that happens to be correct, well..
|
||||
//XXX: why not just do that as well for HINTS mode actually?
|
||||
// FIXME (maybe): (is an ESC or C-] here): on HINTS mode, it enters
|
||||
// into 'if (map && !skipMap) below. With that (or however) it
|
||||
// triggers the onEscape part, where it resets mode. Here I just
|
||||
// return true, with the effect that it also gets to there (for
|
||||
// whatever reason). if that happens to be correct, well..
|
||||
// XXX: why not just do that as well for HINTS mode actually?
|
||||
|
||||
if (vimperator.mode == vimperator.modes.CUSTOM)
|
||||
return true;
|
||||
@@ -1045,7 +1037,7 @@ vimperator.Events = function () //{{{
|
||||
vimperator.input.buffer = "";
|
||||
inputBufferLength = 0;
|
||||
var tmp = vimperator.input.pendingArgMap; // must be set to null before .execute; if not
|
||||
vimperator.input.pendingArgMap = null; // v.inputpendingArgMap is still 'true' also for new feeded keys
|
||||
vimperator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys
|
||||
if (key != "<Esc>" && key != "<C-[>")
|
||||
{
|
||||
if (vimperator.modes.isReplaying && !waitForPageLoaded())
|
||||
@@ -1267,7 +1259,9 @@ vimperator.Events = function () //{{{
|
||||
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
if (aTopic != "nsPref:changed") return;
|
||||
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)
|
||||
|
||||
@@ -90,6 +90,12 @@ vimperator.Mappings = function () //{{{
|
||||
map.modes.forEach(function (mode) { main[mode].push(map); });
|
||||
}
|
||||
|
||||
function addMap(map, userMap)
|
||||
{
|
||||
var where = userMap ? user : main;
|
||||
map.modes.forEach(function (mode) { where[mode].push(map); });
|
||||
}
|
||||
|
||||
function getMap(mode, cmd, stack)
|
||||
{
|
||||
var maps = stack[mode];
|
||||
@@ -192,9 +198,15 @@ vimperator.Mappings = function () //{{{
|
||||
return user[mode].some(function (map) { return map.hasName(cmd); });
|
||||
},
|
||||
|
||||
addDefault: function (modes, keys, description, action, extra)
|
||||
{
|
||||
addMap (new vimperator.Map([vimperator.modes.NORMAL], keys,
|
||||
action, { shortHelp: description }), false);
|
||||
},
|
||||
|
||||
add: function (map)
|
||||
{
|
||||
// a map can have multiple names (see default-map sections, there are many multiples)
|
||||
// a map can have multiple names
|
||||
for (var i = 0; i < map.names.length; i++)
|
||||
{
|
||||
// only store keysyms with uppercase modifier strings
|
||||
@@ -223,7 +235,6 @@ vimperator.Mappings = function () //{{{
|
||||
return getMap(mode, cmd, user) || getMap(mode, cmd, main);
|
||||
},
|
||||
|
||||
// TODO: move default maps to their own v.normal namespace
|
||||
getDefault: function (mode, cmd)
|
||||
{
|
||||
return getMap(mode, cmd, main);
|
||||
|
||||
@@ -32,14 +32,6 @@ const vimperator = (function () //{{{
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
|
||||
// our services
|
||||
var soundService = Components.classes["@mozilla.org/sound;1"]
|
||||
.getService(Components.interfaces.nsISound);
|
||||
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
||||
.getService(Components.interfaces.nsIConsoleService);
|
||||
var environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||
.getService(Components.interfaces.nsIEnvironment);
|
||||
|
||||
var callbacks = [];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////}}}
|
||||
@@ -107,6 +99,8 @@ const vimperator = (function () //{{{
|
||||
}
|
||||
else
|
||||
{
|
||||
var soundService = Components.classes["@mozilla.org/sound;1"].
|
||||
getService(Components.interfaces.nsISound);
|
||||
soundService.beep();
|
||||
}
|
||||
},
|
||||
@@ -299,6 +293,8 @@ const vimperator = (function () //{{{
|
||||
if (typeof msg == "object")
|
||||
msg = this.objectToString(msg, false);
|
||||
|
||||
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].
|
||||
getService(Components.interfaces.nsIConsoleService);
|
||||
consoleService.logStringMessage("vimperator: " + msg);
|
||||
},
|
||||
|
||||
@@ -435,6 +431,9 @@ const vimperator = (function () //{{{
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
var environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||
.getService(Components.interfaces.nsIEnvironment);
|
||||
|
||||
var dirs = environmentService.get("PATH").split(WINDOWS ? ";" : ":");
|
||||
for (var i = 0; i < dirs.length; i++)
|
||||
{
|
||||
@@ -622,7 +621,7 @@ const vimperator = (function () //{{{
|
||||
vimperator.quickmarks = vimperator.QuickMarks();
|
||||
vimperator.log("Loading module hints...", 3);
|
||||
vimperator.hints = vimperator.Hints();
|
||||
vimperator.log("Loading module autocommands...", 3); //XXX: what the 3 there, I didn't check
|
||||
vimperator.log("Loading module autocommands...", 3);
|
||||
vimperator.autocommands = vimperator.AutoCommands();
|
||||
vimperator.log("Loading module io...", 3);
|
||||
vimperator.io = vimperator.IO();
|
||||
|
||||
@@ -28,6 +28,8 @@ HEADER=<span style="float: right; padding-top: 10px;"><form action="https://www.
|
||||
\[arg2\]=<span class="argument">[arg2]</span>
|
||||
\[url\]=<span class="argument">[url]</span>
|
||||
\[file\]=<span class="argument">[file]</span>
|
||||
\[value\]=<span class="argument">[value]</span>
|
||||
\[filter\]=<span class="argument">[filter]</span>
|
||||
\[!\]=<span class="argument">[!]</span>
|
||||
|
||||
# [macros]
|
||||
|
||||
@@ -50,13 +50,13 @@ section:Help{nbsp}topics[overview]
|
||||
a browsing session (how to open a web page or go back in history).
|
||||
- help:Motion{nbsp}commands[motion.html]: How to efficiently scroll in
|
||||
Vimperator.
|
||||
- help:Options[options.html]: A description of all options.
|
||||
- help:Tabs[tabs.html]: Manage your tabbed browsing session.
|
||||
- help:Marks[marks.html]: Usage of bookmarks, QuickMarks, and history.
|
||||
- help:Repeating{nbsp}commands[repeat.html]: Usage of macros to repeat
|
||||
recurring workflows.
|
||||
- help:Autocommands[autocommands.html]: Automatically execute code on ceratain
|
||||
events.
|
||||
- help:Options[options.html]: A description of all options.
|
||||
- help:Developer{nbsp}Information[developer.html]: How to write docs or
|
||||
plugins.
|
||||
- help:Various[various.html]: Other help which didn't fit into any other category.
|
||||
|
||||
@@ -45,6 +45,12 @@ ________________________________________________________________________________
|
||||
Show help on Normal mode commands. Added to simulate the Nvi command.
|
||||
________________________________________________________________________________
|
||||
|
||||
|42| +
|
||||
|
||||
What is the meaning of life, the universe and everything?
|
||||
Douglas Adams, the only person who knew what this question really was about is
|
||||
now dead, unfortunately. So now you might wonder what the meaning of death
|
||||
is...
|
||||
|
||||
|
||||
|
||||
@@ -982,13 +988,6 @@ command.. Example: [c]:execute echo "test"[c] shows a message with the text
|
||||
________________________________________________________________________________
|
||||
|
||||
|
||||
|:exu| |:exusage|
|
||||
||:exu[sage]||
|
||||
________________________________________________________________________________
|
||||
Show help for Ex commands.
|
||||
________________________________________________________________________________
|
||||
|
||||
|
||||
|:fw| |:fo| |:forward|
|
||||
||:[count]fo[rward][!] [url]|| +
|
||||
________________________________________________________________________________
|
||||
@@ -1510,9 +1509,9 @@ ________________________________________________________________________________
|
||||
|
||||
|
||||
|:time|
|
||||
||:{count} time[!] {code|:command}|| +
|
||||
||:[count]time[!] {code|:command}|| +
|
||||
________________________________________________________________________________
|
||||
Profile a piece of code or a command. Runs {code} {count} times (default 1)
|
||||
Profile a piece of code or a command. Run {code} [count] times (default 1)
|
||||
and returns the elapsed time. {code} is always passed to JavaScript's eval(),
|
||||
which might be slow, so take the results with a grain of salt.
|
||||
|
||||
@@ -1583,13 +1582,6 @@ external editor.
|
||||
________________________________________________________________________________
|
||||
|
||||
|
||||
|:viu| |:viusage|
|
||||
||:viu[sage]||
|
||||
________________________________________________________________________________
|
||||
Show help for normal mode commands.
|
||||
________________________________________________________________________________
|
||||
|
||||
|
||||
|:wc| |:wclose| |:winc| |:winclose|
|
||||
||:winc[ose] [url] [, url]|| +
|
||||
________________________________________________________________________________
|
||||
@@ -1612,9 +1604,9 @@ ________________________________________________________________________________
|
||||
||:zo[om][!] [value]|| +
|
||||
||:zo[om][!] +{value} | -{value}|| +
|
||||
________________________________________________________________________________
|
||||
Set zoom value of current web page. If {value} can be an absolute value
|
||||
Set zoom value of current web page. If [value] can be an absolute value
|
||||
between 1 and 2000% or a relative value if prefixed with '-' or '+'. If
|
||||
{value} is omitted, zoom is reset to 100%.
|
||||
[value] is omitted, zoom is reset to 100%.
|
||||
|
||||
Normally this command operates on the text zoom, if used with [!] it operates
|
||||
on full zoom.
|
||||
|
||||
@@ -290,7 +290,6 @@ span.tag, span.hiddentag {
|
||||
font-weight: bold;
|
||||
color: rgb(255, 0, 255); /* magenta */
|
||||
padding-left: 15px;
|
||||
/*padding-top: -5px;*/
|
||||
float: right;
|
||||
}
|
||||
/* inside a table cell means this tag is part of a section */
|
||||
|
||||
Reference in New Issue
Block a user