diff --git a/AUTHORS b/AUTHORS index 6efbeec8..2f7b69c4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,4 +13,5 @@ Patches: * Bart Trojanowski (Makefile) * Hannes Rist (:set titlestring support) * Marco Candrian (shift-insert patch) + * Nikolai Weibull ($VIMPERATOR_HOME) diff --git a/ChangeLog b/ChangeLog index d7b2bbeb..5427cfd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 help - "I" + mapping is now "" + +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 * Donators, chrome/content/vimperator/events.js: allow number input diff --git a/chrome/content/vimperator/editor.js b/chrome/content/vimperator/editor.js index 7df70cb8..050a1e2d 100644 --- a/chrome/content/vimperator/editor.js +++ b/chrome/content/vimperator/editor.js @@ -25,16 +25,19 @@ 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() { - var el = window.document.commandDispatcher.focusedElement; - if (!el || !el.controllers) + var editor = editor(); + if (!editor || !editor.controllers) return null; - return el.controllers.getControllerAt(0); + return editor.controllers.getControllerAt(0); } this.line = function() diff --git a/chrome/content/vimperator/events.js b/chrome/content/vimperator/events.js index b5ac3af5..a2c72a08 100644 --- a/chrome/content/vimperator/events.js +++ b/chrome/content/vimperator/events.js @@ -231,10 +231,11 @@ function Events() //{{{ /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + this.wantsModeReset = true; // used in onFocusChange since Firefox is so buggy here this.destroy = function() { - // BIG TODO: removeEventListeners() to avoid mem leaks + // removeEventListeners() to avoid mem leaks window.dump("TODO: remove all eventlisteners\n"); getBrowser().removeProgressListener(this.progressListener); @@ -243,6 +244,9 @@ function Events() //{{{ window.removeEventListener("popuphidden", exitPopupMode, true); window.removeEventListener("DOMMenuBarActive", enterMenuMode, 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 @@ -253,7 +257,7 @@ function Events() //{{{ // if you want < to be taken literally, prepend it with a \\ this.feedkeys = function(keys) { - var doc = window.content.document; + var doc = window.document; var view = window.document.defaultView; var escapeKey = false; // \ to escape some special keys @@ -295,13 +299,13 @@ function Events() //{{{ 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; 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); } } @@ -401,8 +405,12 @@ function Events() //{{{ // argument "event" is delibarately not used, as i don't seem to have // access to the real focus target + // + // the ugly wantsModeReset is needed, because firefox generates a massive + // amount of focus changes for things like (focusing the search field) this.onFocusChange = function(event) { + // command line has it's own focus change handler if (vimperator.mode == vimperator.modes.COMMAND_LINE) return; @@ -413,11 +421,13 @@ function Events() //{{{ if (elem && elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) { + this.wantsModeReset = false; vimperator.mode = vimperator.modes.INSERT; vimperator.buffer.lastInputField = elem; } else if (elem && elem instanceof HTMLTextAreaElement) { + this.wantsModeReset = false; if (vimperator.options["insertmode"]) vimperator.modes.set(vimperator.modes.INSERT, vimperator.modes.TEXTAREA); else if (elem.selectionEnd - elem.selectionStart > 0) @@ -429,7 +439,13 @@ function Events() //{{{ else if (vimperator.mode == vimperator.modes.INSERT || vimperator.mode == vimperator.modes.TEXTAREA || vimperator.mode == vimperator.modes.VISUAL) - vimperator.modes.reset(); + { + this.wantsModeReset = true; + setTimeout(function() { + if (vimperator.events.wantsModeReset) + vimperator.modes.reset(); + }, 10); + } } 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 - // menus have their own command handlers if (vimperator.modes.extended & vimperator.modes.MENU) return true; @@ -740,7 +755,6 @@ function Events() //{{{ if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused()) return true; - event.preventDefault(); event.stopPropagation(); return false; } diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 43cd8d6b..36b0d7c0 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -51,10 +51,13 @@ const vimperator = (function() //{{{ if (WINDOWS) 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)) { - var home = environment_service.get("HOME"); + var home = environment_service.get("VIMPERATOR_HOME"); + + if (!home) + home = environment_service.get("HOME"); if (WINDOWS && !home) home = environment_service.get("USERPROFILE") || @@ -250,56 +253,59 @@ const vimperator = (function() //{{{ // partial sixth level expression evaluation eval: function(string) { - string = string.toString().replace(/^\s*/, '').replace(/\s*$/, ''); + string = string.toString().replace(/^\s*/, "").replace(/\s*$/, ""); var match = string.match(/^&(\w+)/); if (match) { var opt = this.options.get(match[1]); if (!opt) { - this.echoerr('E113: Unknown option: ' + match[1]); + this.echoerr("E113: Unknown option: " + match[1]); return; } var type = opt.type; var value = opt.getter(); - if (type != 'boolean' && type != 'number') + if (type != "boolean" && type != "number") value = value.toString(); return value; } // String - if (match = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) + else if (match = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) { if (match) return match[2].toString(); else { - this.echoerr('E115: Missing quote: ' + string); + this.echoerr("E115: Missing quote: " + string); return; } } // Number - if (match = string.match(/^(\d+)$/)) + else if (match = string.match(/^(\d+)$/)) { return parseInt(match[1]); } var reference = this.variableReference(string); if (!reference[0]) - this.echoerr('E121: Undefined variable: ' + string); + this.echoerr("E121: Undefined variable: " + string); else return reference[0][reference[1]]; return; }, + variableReference: function(string) { - if (!string) return [null, null, null]; - if (match = string.match(/^([bwtglsv]):(\w+)/)) // Variable + if (!string) + return [null, null, null]; + + if (match = string.match(/^([bwtglsv]):(\w+)/)) // Variable { // Other variables should be implemented - if (match[1] == 'g') + if (match[1] == "g") { if (match[2] in this.globalVariables) return [this.globalVariables, match[2], match[1]]; @@ -307,12 +313,12 @@ const vimperator = (function() //{{{ return [null, match[2], match[1]]; } } - else // Global variable + else // Global variable { if (string in this.globalVariables) - return [this.globalVariables, string, 'g']; + return [this.globalVariables, string, "g"]; else - return [null, string, 'g']; + return [null, string, "g"]; } }, @@ -340,12 +346,13 @@ const vimperator = (function() //{{{ } catch (e) { - value = ''; + value = ""; } - string += i + ': ' + value + '\n'; + string += i + ": " + value + "\n"; } vimperator.log(string, level); + return string; }, // open one or more URLs