1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 12:37:58 +01:00

- fixed generating artificial firefox commands with feedkeys()/:norm/:map

- home/end/etc. keys work again in the location bar
- <c-v><c-k>, etc. work again to focus special form fields
- small formatting improvements
This commit is contained in:
Martin Stubenschrott
2007-09-18 22:27:52 +00:00
parent 6060c59359
commit 1e15906810
5 changed files with 240 additions and 29 deletions

View File

@@ -13,4 +13,5 @@ Patches:
* Bart Trojanowski (Makefile) * Bart Trojanowski (Makefile)
* Hannes Rist (:set titlestring support) * Hannes Rist (:set titlestring support)
* Marco Candrian (shift-insert patch) * Marco Candrian (shift-insert patch)
* Nikolai Weibull ($VIMPERATOR_HOME)
</pre> </pre>

186
ChangeLog
View File

@@ -1,3 +1,189 @@
2007-09-18 22:23 vkojouharov
* chrome/content/vimperator/: commands.js, vimperator.js: basic
eval function and variable let/unlet
2007-09-18 18:30 dougkearns
* chrome/content/vimperator/completion.js: use
build_longest_common_substring rather than
build_longest_starting_substring for :sidebar completion
2007-09-18 18:20 dougkearns
* chrome/content/vimperator/completion.js: only call
build_longest_common_substring() for :sidebar completion if a
completion filter is passed
2007-09-18 13:33 dougkearns
* chrome/content/vimperator/commands.js: use toggleSidebar for
closing the sidebar so that the menu state is properly updated
2007-09-18 13:21 dougkearns
* chrome/content/vimperator/completion.js: revert to using
build_longest_starting_substring until an infinite loop bugin
build_longest_common_substring is resolved
2007-09-18 11:33 dougkearns
* chrome/content/vimperator/commands.js: use toggleSidebar for
closing the sidebar so that the menu state is properly updated
2007-09-18 11:31 dougkearns
* chrome/content/vimperator/completion.js: fix typo - use
build_longest_common_substring for :sidebar completion
2007-09-18 10:49 dougkearns
* NEWS, TODO, chrome/content/vimperator/commands.js,
chrome/content/vimperator/vimperator.xul: merge :sbclose and
viewSidebarMenu menuitem additions
2007-09-18 10:25 dougkearns
* NEWS, TODO, chrome/content/vimperator/commands.js: add :sbclose
to close the sidebar and :sbar, :sbopen aliases for :sidebar
2007-09-18 09:19 dougkearns
* chrome/content/vimperator/vimperator.xul: add Add-ons,
Preferences, and Downloads to :sidebar
2007-09-17 15:26 dougkearns
* NEWS, chrome/content/vimperator/commands.js,
chrome/content/vimperator/completion.js: add an initial
implementation of :sidebar
2007-09-17 14:43 dougkearns
* NEWS, TODO, chrome/content/vimperator/commands.js,
chrome/content/vimperator/completion.js: add an initial
implementation of :sidebar
2007-09-17 07:49 dougkearns
* NEWS, chrome/content/vimperator/events.js,
chrome/content/vimperator/options.js,
chrome/content/vimperator/ui.js,
chrome/content/vimperator/vimperator.js,
chrome/content/vimperator/vimperator.xul: merge new 'more' option
and more-prompt improvements
2007-09-17 07:37 dougkearns
* chrome/content/vimperator/: events.js, ui.js, vimperator.xul:
enable vimperator.events.toString() to return keysyms for mouse
events
2007-09-17 03:37 dougkearns
* chrome/content/vimperator/ui.js: when closing the more-prompt
don't pass through accept keys
2007-09-17 03:33 dougkearns
* chrome/content/vimperator/events.js: fix onKeyDown handler to use
0.5 style mode handling - bad merge
2007-09-16 19:11 dougkearns
* chrome/content/vimperator/modes.js: add Vim modeline and
whitespace formatting
2007-09-16 17:38 dougkearns
* chrome/content/vimperator/ui.js: add "f" as a page-down key
mapping in the more-prompt pager
2007-09-16 14:18 dougkearns
* NEWS, chrome/content/vimperator/options.js,
chrome/content/vimperator/ui.js,
chrome/content/vimperator/vimperator.xul: add 'more' option and
standard more-prompt key mappings
2007-09-14 15:38 dougkearns
* NEWS, chrome/content/vimperator/find.js,
chrome/content/vimperator/mappings.js,
chrome/content/vimperator/options.js: add a 'hlsearchstyle'
option to allow for match styling and a 'linksearch' option to
restrict page searches to link text
2007-09-14 15:24 dougkearns
* NEWS, chrome/content/vimperator/find.js,
chrome/content/vimperator/mappings.js,
chrome/content/vimperator/options.js: add a 'hlsearchstyle'
option to allow for match styling and a 'linksearch' option to
restrict page searches to link text
2007-09-14 14:53 stubenschrott
* chrome/content/vimperator/mappings.js: small help refinements to
help remember the ctrl-q setting by having the word "quit" in the
help
2007-09-14 12:39 dougkearns
* chrome/content/vimperator/mappings.js: update <C-v> help - "I"
mapping is now "<C-q>"
2007-09-14 08:00 stubenschrott
* chrome/content/vimperator/events.js: do not go into insert mode
on readOnly elems
2007-09-14 06:42 stubenschrott
* chrome/content/vimperator/editor.js: fixed motion commands in
textarea
2007-09-14 06:37 dougkearns
* chrome/content/vimperator/events.js: merge keyDown event handling
from MAIN - helps with sites such as yahoo.com which trap all
keyDown events
2007-09-14 06:30 dougkearns
* chrome/content/vimperator/: vimperator.js: allow single line :js
commands to be source from RC files
2007-09-14 06:23 stubenschrott
* chrome/content/vimperator/events.js: fixed visual->caret
transistion on escape
2007-09-14 05:59 stubenschrott
* chrome/content/vimperator/ui.js: only allow g and G mapping in
the MOW if scrollable
2007-09-14 05:56 stubenschrott
* chrome/content/vimperator/: buffers.js, find.js, modes.js, ui.js:
commands in the -- more -- prompt are now passed to vimperator if
they don't make sense in the MOW
2007-09-14 05:35 stubenschrott
* ChangeLog, NEWS, TODO, chrome/content/vimperator/editor.js,
chrome/content/vimperator/events.js,
chrome/content/vimperator/find.js,
chrome/content/vimperator/hints.js,
chrome/content/vimperator/mappings.js,
chrome/content/vimperator/modes.js,
chrome/content/vimperator/options.js,
chrome/content/vimperator/ui.js,
chrome/content/vimperator/vimperator.js,
chrome/content/vimperator/vimperator.xul: major mode rewrite,
still not fully complete, but usable
2007-09-13 01:49 stubenschrott 2007-09-13 01:49 stubenschrott
* Donators, chrome/content/vimperator/events.js: allow number input * Donators, chrome/content/vimperator/events.js: allow number input

View File

@@ -25,16 +25,19 @@ function Editor() //{{{
function editor() function editor()
{ {
return window.document.commandDispatcher.focusedElement; var editor = window.document.commandDispatcher.focusedElement;
if (editor && editor.mInputField)
editor = editor.mInputField;
return editor;
} }
function getController() function getController()
{ {
var el = window.document.commandDispatcher.focusedElement; var editor = editor();
if (!el || !el.controllers) if (!editor || !editor.controllers)
return null; return null;
return el.controllers.getControllerAt(0); return editor.controllers.getControllerAt(0);
} }
this.line = function() this.line = function()

View File

@@ -231,10 +231,11 @@ function Events() //{{{
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.wantsModeReset = true; // used in onFocusChange since Firefox is so buggy here
this.destroy = function() this.destroy = function()
{ {
// BIG TODO: removeEventListeners() to avoid mem leaks // removeEventListeners() to avoid mem leaks
window.dump("TODO: remove all eventlisteners\n"); window.dump("TODO: remove all eventlisteners\n");
getBrowser().removeProgressListener(this.progressListener); getBrowser().removeProgressListener(this.progressListener);
@@ -243,6 +244,9 @@ function Events() //{{{
window.removeEventListener("popuphidden", exitPopupMode, true); window.removeEventListener("popuphidden", exitPopupMode, true);
window.removeEventListener("DOMMenuBarActive", enterMenuMode, true); window.removeEventListener("DOMMenuBarActive", enterMenuMode, true);
window.removeEventListener("DOMMenuBarInactive", exitMenuMode, true); window.removeEventListener("DOMMenuBarInactive", exitMenuMode, true);
window.removeEventListener("keypress", this.onKeyPress, true);
window.removeEventListener("keydown", this.onKeyDown, true);
} }
// This method pushes keys into the event queue from vimperator // This method pushes keys into the event queue from vimperator
@@ -253,7 +257,7 @@ function Events() //{{{
// if you want < to be taken literally, prepend it with a \\ // if you want < to be taken literally, prepend it with a \\
this.feedkeys = function(keys) this.feedkeys = function(keys)
{ {
var doc = window.content.document; var doc = window.document;
var view = window.document.defaultView; var view = window.document.defaultView;
var escapeKey = false; // \ to escape some special keys var escapeKey = false; // \ to escape some special keys
@@ -295,13 +299,13 @@ function Events() //{{{
i += matches[0].length + 1; i += matches[0].length + 1;
} }
} }
var evt = doc.createEvent('KeyEvents');
evt.initKeyEvent('keypress', true, true, view, ctrl, alt, shift, meta, keyCode, charCode );
var elem = window.document.commandDispatcher.focusedElement; var elem = window.document.commandDispatcher.focusedElement;
if (!elem) if (!elem)
elem = window; elem = window.content;
var evt = doc.createEvent("KeyEvents");
evt.initKeyEvent("keypress", true, true, view, ctrl, alt, shift, meta, keyCode, charCode );
elem.dispatchEvent(evt); elem.dispatchEvent(evt);
} }
} }
@@ -401,8 +405,12 @@ function Events() //{{{
// argument "event" is delibarately not used, as i don't seem to have // argument "event" is delibarately not used, as i don't seem to have
// access to the real focus target // access to the real focus target
//
// the ugly wantsModeReset is needed, because firefox generates a massive
// amount of focus changes for things like <C-v><C-k> (focusing the search field)
this.onFocusChange = function(event) this.onFocusChange = function(event)
{ {
// command line has it's own focus change handler
if (vimperator.mode == vimperator.modes.COMMAND_LINE) if (vimperator.mode == vimperator.modes.COMMAND_LINE)
return; return;
@@ -413,11 +421,13 @@ function Events() //{{{
if (elem && elem instanceof HTMLInputElement && if (elem && elem instanceof HTMLInputElement &&
(elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password"))
{ {
this.wantsModeReset = false;
vimperator.mode = vimperator.modes.INSERT; vimperator.mode = vimperator.modes.INSERT;
vimperator.buffer.lastInputField = elem; vimperator.buffer.lastInputField = elem;
} }
else if (elem && elem instanceof HTMLTextAreaElement) else if (elem && elem instanceof HTMLTextAreaElement)
{ {
this.wantsModeReset = false;
if (vimperator.options["insertmode"]) if (vimperator.options["insertmode"])
vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA);
else if (elem.selectionEnd - elem.selectionStart > 0) else if (elem.selectionEnd - elem.selectionStart > 0)
@@ -429,7 +439,13 @@ function Events() //{{{
else if (vimperator.mode == vimperator.modes.INSERT || else if (vimperator.mode == vimperator.modes.INSERT ||
vimperator.mode == vimperator.modes.TEXTAREA || vimperator.mode == vimperator.modes.TEXTAREA ||
vimperator.mode == vimperator.modes.VISUAL) vimperator.mode == vimperator.modes.VISUAL)
{
this.wantsModeReset = true;
setTimeout(function() {
if (vimperator.events.wantsModeReset)
vimperator.modes.reset(); vimperator.modes.reset();
}, 10);
}
} }
this.onSelectionChange = function(event) this.onSelectionChange = function(event)
@@ -512,7 +528,6 @@ function Events() //{{{
var stop = true; // set to false if we should NOT consume this event but let also firefox handle it var stop = true; // set to false if we should NOT consume this event but let also firefox handle it
// menus have their own command handlers // menus have their own command handlers
if (vimperator.modes.extended & vimperator.modes.MENU) if (vimperator.modes.extended & vimperator.modes.MENU)
return true; return true;
@@ -740,7 +755,6 @@ function Events() //{{{
if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused()) if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused())
return true; return true;
event.preventDefault();
event.stopPropagation(); event.stopPropagation();
return false; return false;
} }

View File

@@ -51,10 +51,13 @@ const vimperator = (function() //{{{
if (WINDOWS) if (WINDOWS)
path = path.replace('/', '\\', 'g'); path = path.replace('/', '\\', 'g');
// expand "~" to HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set) // expand "~" to VIMPERATOR_HOME or HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set)
if (/^~/.test(path)) if (/^~/.test(path))
{ {
var home = environment_service.get("HOME"); var home = environment_service.get("VIMPERATOR_HOME");
if (!home)
home = environment_service.get("HOME");
if (WINDOWS && !home) if (WINDOWS && !home)
home = environment_service.get("USERPROFILE") || home = environment_service.get("USERPROFILE") ||
@@ -250,56 +253,59 @@ const vimperator = (function() //{{{
// partial sixth level expression evaluation // partial sixth level expression evaluation
eval: function(string) eval: function(string)
{ {
string = string.toString().replace(/^\s*/, '').replace(/\s*$/, ''); string = string.toString().replace(/^\s*/, "").replace(/\s*$/, "");
var match = string.match(/^&(\w+)/); var match = string.match(/^&(\w+)/);
if (match) if (match)
{ {
var opt = this.options.get(match[1]); var opt = this.options.get(match[1]);
if (!opt) if (!opt)
{ {
this.echoerr('E113: Unknown option: ' + match[1]); this.echoerr("E113: Unknown option: " + match[1]);
return; return;
} }
var type = opt.type; var type = opt.type;
var value = opt.getter(); var value = opt.getter();
if (type != 'boolean' && type != 'number') if (type != "boolean" && type != "number")
value = value.toString(); value = value.toString();
return value; return value;
} }
// String // String
if (match = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) else if (match = string.match(/^(['"])([^\1]*?[^\\]?)\1/))
{ {
if (match) if (match)
return match[2].toString(); return match[2].toString();
else else
{ {
this.echoerr('E115: Missing quote: ' + string); this.echoerr("E115: Missing quote: " + string);
return; return;
} }
} }
// Number // Number
if (match = string.match(/^(\d+)$/)) else if (match = string.match(/^(\d+)$/))
{ {
return parseInt(match[1]); return parseInt(match[1]);
} }
var reference = this.variableReference(string); var reference = this.variableReference(string);
if (!reference[0]) if (!reference[0])
this.echoerr('E121: Undefined variable: ' + string); this.echoerr("E121: Undefined variable: " + string);
else else
return reference[0][reference[1]]; return reference[0][reference[1]];
return; return;
}, },
variableReference: function(string) variableReference: function(string)
{ {
if (!string) return [null, null, null]; if (!string)
return [null, null, null];
if (match = string.match(/^([bwtglsv]):(\w+)/)) // Variable if (match = string.match(/^([bwtglsv]):(\w+)/)) // Variable
{ {
// Other variables should be implemented // Other variables should be implemented
if (match[1] == 'g') if (match[1] == "g")
{ {
if (match[2] in this.globalVariables) if (match[2] in this.globalVariables)
return [this.globalVariables, match[2], match[1]]; return [this.globalVariables, match[2], match[1]];
@@ -310,9 +316,9 @@ const vimperator = (function() //{{{
else // Global variable else // Global variable
{ {
if (string in this.globalVariables) if (string in this.globalVariables)
return [this.globalVariables, string, 'g']; return [this.globalVariables, string, "g"];
else else
return [null, string, 'g']; return [null, string, "g"];
} }
}, },
@@ -340,12 +346,13 @@ const vimperator = (function() //{{{
} }
catch (e) catch (e)
{ {
value = ''; value = "";
} }
string += i + ': ' + value + '\n'; string += i + ": " + value + "\n";
} }
vimperator.log(string, level); vimperator.log(string, level);
return string;
}, },
// open one or more URLs // open one or more URLs