From 2fea92e31db28cb9fc1d0f3c336c7556ac5dc473 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 17 Dec 2008 11:30:56 -0500 Subject: [PATCH 01/41] Add :ha >file.ps --- common/content/buffer.js | 33 +++++++++++++++++-------- common/content/commands.js | 44 ++++++++++++++++++--------------- common/content/io.js | 3 +-- common/content/options.js | 37 +++++++++++++++++++++++++-- vimperator/content/bookmarks.js | 1 + 5 files changed, 84 insertions(+), 34 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index e6a15cd7..4a95beb5 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -483,21 +483,34 @@ function Buffer() //{{{ "Print current document", function (args) { - let aps = options.getPref("print.always_print_silent"); - let spp = options.getPref("print.show_print_progress"); + options.temporaryContext(function () { + if (args[0]) + { + if (args[0][0] != ">") + return liberator.echoerr("E488: Trailing characters"); + options.setPref("print.print_to_file", "true"); + options.setPref("print.print_to_filename", io.getFile(args[0].substr(1)).path); + liberator.echomsg("Printing to file: " + args[0].substr(1)); + } + else + { + liberator.echomsg("Sending to printer..."); + } - liberator.echomsg("Sending to printer..."); - options.setPref("print.always_print_silent", args.bang); - options.setPref("print.show_print_progress", !args.bang); + options.setPref("print.always_print_silent", args.bang); + options.setPref("print.show_print_progress", !args.bang); - getBrowser().contentWindow.print(); + getBrowser().contentWindow.print(); + }); - options.setPref("print.always_print_silent", aps); - options.setPref("print.show_print_progress", spp); - liberator.echomsg("Print job sent."); + if (args[0]) + liberator.echomsg("Printed: " + args[0].substr(1)); + else + liberator.echomsg("Print job sent."); }, { - argCount: "0", + argCount: "?", + literal: 0, bang: true }); diff --git a/common/content/commands.js b/common/content/commands.js index c5d7c3ae..67540eb9 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -758,9 +758,30 @@ function Commands() //{{{ if (completeOpt) { if (/^custom,/.test(completeOpt)) - completeFunc = completeOpt.substr(7); + { + completeFunc = function () + { + try + { + var completer = liberator.eval(completeOpt.substr(7)); + + if (!(completer instanceof Function)) + throw new TypeError("User-defined custom completer '" + completeOpt.substr(7) + "' is not a function"); + } + catch (e) + { + // FIXME: should be pushed to the MOW + liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7)); + liberator.log(e); + return undefined; + } + return completer.apply(this, Array.slice(arguments)); + } + } else - completeFunc = "completion." + completeOptionMap[completeOpt]; + { + completeFunc = function () completion[completeOptionMap[completeOpt]].apply(this, Array.slice(arguments)); + } } if (!commands.addUserCommand( @@ -773,24 +794,7 @@ function Commands() //{{{ count: countOpt, completer: function (context, args) { if (completeFunc) - { - try - { - var completer = liberator.eval(completeFunc); - - if (!(completer instanceof Function)) - throw new TypeError("User-defined custom completer '" + completeFunc + "' is not a function"); - } - catch (e) - { - // FIXME: should be pushed to the MOW - liberator.echoerr("E117: Unknown function: " + completeFunc); - liberator.log(e); - return; - } - - completer.call(completion, context, args) - } + return completeFunc(context, args) }, replacementText: args.literalArg }, diff --git a/common/content/io.js b/common/content/io.js index d6bf284a..52fd0ed7 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -99,8 +99,7 @@ function IO() //{{{ return []; else // empty list item means the current directory - return list.replace(/,$/, "") - .split(",") + return list.replace(/,$/, "").split(",") .map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir); } diff --git a/common/content/options.js b/common/content/options.js index 34828e18..54cc90a2 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -302,7 +302,9 @@ function Options() //{{{ const SAVED = "liberator.saved."; const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); - var optionHash = {}; + const optionHash = {}; + + const prefContexts = []; function optionObserver(key, event, option) { @@ -320,6 +322,13 @@ function Options() //{{{ function storePreference(name, value) { + if (prefContexts.length) + { + let val = loadPreference(name, null); + if (val != null) + prefContexts[prefContexts.length - 1][name] = val; + } + var type = prefService.getPrefType(name); switch (typeof value) { @@ -988,7 +997,31 @@ function Options() //{{{ this.setPref(name, !this.getPref(name)); else liberator.echoerr("E488: Trailing characters: " + name + "!"); - } + }, + + pushContext: function () + { + prefContexts.push({}); + }, + + popContext: function () + { + for (let [k, v] in Iterator(prefContexts.pop())) + storePreference(k, v); + }, + + temporaryContext: function (fn, self) + { + try + { + this.pushContext(); + return fn.call(self); + } + finally + { + this.popContext(); + } + }, }; //}}} }; //}}} diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index fbcd419f..53c37601 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -701,6 +701,7 @@ function History() //{{{ context.completions = [sh.getEntryAtIndex(i, false) for (i in util.range(sh.index, 0, true))]; context.keys = { text: function (item) item.URI.spec, description: "title" }; + liberator.dump(context.items); }, count: true, literal: 0 From b7e6103d56972ccec4305395ba3d707f0618f58a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 17 Dec 2008 22:36:56 -0500 Subject: [PATCH 02/41] Add :silent command --- common/content/ui.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/content/ui.js b/common/content/ui.js index 89e5009a..dc2c314b 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -841,6 +841,17 @@ function CommandLine() //{{{ }, { argCount: "0" }); + commands.add(["sil[ent]"], + "Run a command silently", + function (args) + { + commandline.runSilently(function () liberator.execute(args[0])); + }, + { + completer: function (context) completion.ex(context), + literal: 0 + }); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ From cdcfb68e3b02af206c2bf971292abe2cab853433 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 17 Dec 2008 23:16:20 -0500 Subject: [PATCH 03/41] Add '' --- common/content/buffer.js | 34 ++++++++++++++++++++++++---------- common/content/liberator.js | 2 +- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 4a95beb5..af08876c 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -115,6 +115,7 @@ function Buffer() //{{{ else v = win.scrollMaxY / 100 * vertical; + marks.add("'", true); win.scrollTo(h, v); } @@ -1156,6 +1157,17 @@ function Buffer() //{{{ scrollToPercentiles(-1, percentage); }, + scrollToRatio: function (x, y) + { + scrollToPercentiles(x * 100, y * 100); + }, + + scrollTo: function (x, y) + { + marks.add("'", true); + content.scrollTo(x, y); + }, + scrollStart: function () { scrollToPercentiles(0, -1); @@ -1340,12 +1352,11 @@ function Marks() //{{{ function onPageLoad(event) { let win = event.originalTarget.defaultView; - for (let i = 0, length = pendingJumps.length; i < length; i++) + for (let [i, mark] in Iterator(pendingJumps)) { - let mark = pendingJumps[i]; if (win && win.location.href == mark.location) { - win.scrollTo(mark.position.x * win.scrollMaxX, mark.position.y * win.scrollMaxY); + buffer.scrollToRatio(mark.position.x, mark.position.y); pendingJumps.splice(i, 1); return; } @@ -1390,7 +1401,7 @@ function Marks() //{{{ } } - function isLocalMark(mark) /^[a-z]$/.test(mark); + function isLocalMark(mark) /^['"a-z]$/.test(mark); function isURLMark(mark) /^[A-Z0-9]$/.test(mark); function localMarkIter() @@ -1537,13 +1548,14 @@ function Marks() //{{{ return { // TODO: add support for frameset pages - add: function (mark) + add: function (mark, silent) { let win = window.content; if (win.document.body.localName.toLowerCase() == "frameset") { - liberator.echoerr("Marks support for frameset pages not implemented yet"); + if (!silent) + liberator.echoerr("Marks support for frameset pages not implemented yet"); return; } @@ -1554,7 +1566,8 @@ function Marks() //{{{ if (isURLMark(mark)) { urlMarks.set(mark, { location: win.location.href, position: position, tab: tabs.getTab() }); - liberator.log("Adding URL mark: " + markToString(mark, urlMarks.get(mark)), 5); + if (!silent) + liberator.log("Adding URL mark: " + markToString(mark, urlMarks.get(mark)), 5); } else if (isLocalMark(mark)) { @@ -1564,7 +1577,8 @@ function Marks() //{{{ localMarks.set(mark, []); let vals = { location: win.location.href, position: position }; localMarks.get(mark).push(vals); - liberator.log("Adding local mark: " + markToString(mark, vals), 5); + if (!silent) + liberator.log("Adding local mark: " + markToString(mark, vals), 5); } }, @@ -1621,7 +1635,7 @@ function Marks() //{{{ return; } liberator.log("Jumping to URL mark: " + markToString(mark, slice), 5); - win.scrollTo(slice.position.x * win.scrollMaxX, slice.position.y * win.scrollMaxY); + buffer.scrollToRatio(slice.position.x, slice.position.y); ok = true; } } @@ -1636,7 +1650,7 @@ function Marks() //{{{ if (win.location.href == lmark.location) { liberator.log("Jumping to local mark: " + markToString(mark, lmark), 5); - win.scrollTo(lmark.position.x * win.scrollMaxX, lmark.position.y * win.scrollMaxY); + buffer.scrollToRatio(lmark.position.x, lmark.position.y); ok = true; break; } diff --git a/common/content/liberator.js b/common/content/liberator.js index 6b009c12..bf7a14f2 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -952,7 +952,7 @@ const liberator = (function () //{{{ setTimeout(function () { let elem = buffer.evaluateXPath('//*[@class="tag" and text()="' + tag + '"]').snapshotItem(0); if (elem) - window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context + buffer.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context else liberator.dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' ); }, 500); From 26f362af57f9909edd85d75f0c31d08d9b5b2bcf Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Dec 2008 00:16:49 -0500 Subject: [PATCH 04/41] Check asciidoc version on 'make doc' --- common/Makefile.common | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/Makefile.common b/common/Makefile.common index 110a1163..4cac38e4 100644 --- a/common/Makefile.common +++ b/common/Makefile.common @@ -63,7 +63,8 @@ info: @echo -e "jar files $(shell echo ${JAR_FILES} | sed 's/ /\\n /g' )" @echo "xpi files ${XPI_FILES}" -doc: ${DOC_FILES} +.PHONY: check-asciidoc +doc: check-asciidoc ${DOC_FILES} xpi: ${XPI} jar: ${JAR} @@ -104,6 +105,10 @@ $(JAR): doc #### doc +check-asciidoc: + @asciidoc --version | awk '{ exit $$2 !~ /^8\.2\./ }' || \ + echo >&2 "Warning: asciidoc versions other 8.2.x are unsupported" + ${DOC_FILES}: %.html: %.txt $(BASE)/Makefile.common locale/en-US/asciidoc.conf @echo "DOC $@" ${ASCIIDOC} --unsafe -a linkcss -a quirks! -a doctitle="$(shell basename $@)" -o $@ $< From e082160a21f7e447ef717d3ef61829301e01a8fe Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Dec 2008 13:59:59 -0500 Subject: [PATCH 05/41] Don't anchor help completions. --- common/content/completion.js | 1 + 1 file changed, 1 insertion(+) diff --git a/common/content/completion.js b/common/content/completion.js index f008e7ff..bf4a9622 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1374,6 +1374,7 @@ function Completion() //{{{ help: function help(context) { context.title = ["Help"]; + context.anchored = false; context.generate = function () { let res = config.helpFiles.map(function (file) { From b18b1634fcda9c24a3466464ec462b756cb05134 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Dec 2008 21:27:33 -0500 Subject: [PATCH 06/41] Kludge the stupid urlbar focus bug better --- common/content/events.js | 123 +++++++++++++++++++++------------------ common/content/modes.js | 10 +--- 2 files changed, 68 insertions(+), 65 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 3eadb398..401244ba 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -33,6 +33,7 @@ function AutoCommands() //{{{ /////////////////////////////////////////////////////////////////////////////{{{ var store = []; + var lastFocus = null; function matchAutoCmd(autoCmd, event, regex) { @@ -1086,65 +1087,77 @@ function Events() //{{{ if (win && win.top == content && liberator.has("tabs")) tabs.localStore.focusedFrame = win; - if (elem && elem.readOnly) - return; - - if (elem && ( - (elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) || - (elem instanceof HTMLSelectElement) - )) + try { - this.wantsModeReset = false; - liberator.mode = modes.INSERT; - if (hasHTMLDocument(win)) - buffer.lastInputField = elem; - return; - } + if (elem && elem.readOnly) + return; - if (elem && elem instanceof HTMLTextAreaElement) - { - this.wantsModeReset = false; - if (options["insertmode"]) - modes.set(modes.INSERT, modes.TEXTAREA); - else if (elem.selectionEnd - elem.selectionStart > 0) - modes.set(modes.VISUAL, modes.TEXTAREA); - else - modes.main = modes.TEXTAREA; - if (hasHTMLDocument(win)) - buffer.lastInputField = elem; - return; - } - - if (config.name == "Muttator") - { - // we switch to -- MESSAGE -- mode for muttator, when the main HTML widget gets focus - if (hasHTMLDocument(win) || elem instanceof HTMLAnchorElement) + if ((elem instanceof HTMLInputElement && /^(text|password)$/.test(elem.type)) || + (elem instanceof HTMLSelectElement)) { - if (config.isComposeWindow) - { - liberator.dump("Compose editor got focus"); - modes.set(modes.INSERT, modes.TEXTAREA); - } - else if (liberator.mode != modes.MESSAGE) - liberator.mode = modes.MESSAGE; + this.wantsModeReset = false; + liberator.mode = modes.INSERT; + if (hasHTMLDocument(win)) + buffer.lastInputField = elem; return; } - } - if (liberator.mode == modes.INSERT || - liberator.mode == modes.TEXTAREA || - liberator.mode == modes.MESSAGE || - liberator.mode == modes.VISUAL) + if (elem instanceof HTMLTextAreaElement) + { + this.wantsModeReset = false; + if (options["insertmode"]) + modes.set(modes.INSERT, modes.TEXTAREA); + else if (elem.selectionEnd - elem.selectionStart > 0) + modes.set(modes.VISUAL, modes.TEXTAREA); + else + modes.main = modes.TEXTAREA; + if (hasHTMLDocument(win)) + buffer.lastInputField = elem; + return; + } + + if (config.name == "Muttator") + { + // we switch to -- MESSAGE -- mode for muttator, when the main HTML widget gets focus + if (hasHTMLDocument(win) || elem instanceof HTMLAnchorElement) + { + if (config.isComposeWindow) + { + liberator.dump("Compose editor got focus"); + modes.set(modes.INSERT, modes.TEXTAREA); + } + else if (liberator.mode != modes.MESSAGE) + liberator.mode = modes.MESSAGE; + return; + } + } + + urlbar = document.getElementById("urlbar"); + if (focus == null && urlbar && urlbar.inputField == lastFocus) + liberator.threadYield(true); + + if (liberator.mode & (modes.INSERT | modes.TEXTAREA | modes.MESSAGE | modes.VISUAL)) + { + if (0) // FIXME: currently this hack is disabled to make macros work + { + this.wantsModeReset = true; + setTimeout(function () { + if (events.wantsModeReset) + { + events.wantsModeReset = false; + modes.reset(); + } + }, 0); + } + else + { + modes.reset(); + } + } + } + finally { - // FIXME: currently this hack is disabled to make macros work - // this.wantsModeReset = true; - // setTimeout(function () { - // if (events.wantsModeReset) - // { - // events.wantsModeReset = false; - modes.reset(); - // } - // }, 0); + lastFocus = elem; } }, @@ -1198,7 +1211,6 @@ function Events() //{{{ catch (e) {} modes.reset(); - liberator.focusContent(true); break; case modes.VISUAL: @@ -1216,14 +1228,9 @@ function Events() //{{{ case modes.INSERT: if ((modes.extended & modes.TEXTAREA) && !options["insertmode"]) - { liberator.mode = modes.TEXTAREA; - } else - { modes.reset(); - liberator.focusContent(true); - } break; default: // HINTS, CUSTOM or COMMAND_LINE diff --git a/common/content/modes.js b/common/content/modes.js index de88c3be..b016048b 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -116,13 +116,7 @@ const modes = (function () //{{{ options.setPref("accessibility.browsewithcaret", false); statusline.updateUrl(); - // Kludge to prevent the input field losing focus on MS/Mac - setTimeout(function () { - let focus = document.commandDispatcher.focusedElement; - let urlbar = document.getElementById("urlbar"); - if (!urlbar || focus != urlbar.inputField) - liberator.focusContent(false); - }, 0); + liberator.focusContent(false); } } @@ -137,6 +131,8 @@ const modes = (function () //{{{ get all() mainModes.slice(), + get inputMode() main & (this.COMMAND_LINE | this.INPUT | this.TEXTAREA | this.COMPOSE), + addMode: function (name, extended, display) { let disp = name.replace("_", " ", "g"); this[name] = 1 << lastMode++; From f2f8cdbea3bee03a4ff4d55cf6e6538ac44c96bd Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Dec 2008 21:41:56 -0500 Subject: [PATCH 07/41] Don't hide errors on bad URLs, they're useful feedback --- common/content/liberator.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index 819bc3a3..9ce88e78 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -1090,11 +1090,7 @@ const liberator = (function () //{{{ switch (where) { case liberator.CURRENT_TAB: - try - { - getBrowser().loadURIWithFlags(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, postdata); - } - catch (e) {} + getBrowser().loadURIWithFlags(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, postdata); break; case liberator.NEW_BACKGROUND_TAB: @@ -1111,11 +1107,7 @@ const liberator = (function () //{{{ const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); window.open(); whichwindow = wm.getMostRecentWindow("navigator:browser"); - try - { - whichwindow.loadURI(url, null, postdata); - } - catch (e) {} + whichwindow.loadURI(url, null, postdata); break; default: From 66bd21ec30a20bb6a3bbceeacdff7260c2b36aa4 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Dec 2008 21:47:36 -0500 Subject: [PATCH 08/41] Default to opening multiple URLs in windows instead of tabs when !has("tabs") --- common/content/liberator.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index 9ce88e78..242fde11 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -1099,6 +1099,7 @@ const liberator = (function () //{{{ return open(urls, liberator.NEW_WINDOW); let tab = getBrowser().addTab(url, null, null, postdata); + if (where == liberator.NEW_TAB) getBrowser().selectedTab = tab; break; @@ -1124,8 +1125,6 @@ const liberator = (function () //{{{ for (let [i, url] in Iterator(urls)) { open(url, where); - if (i == 0 && !liberator.has("tabs")) - break; where = liberator.NEW_BACKGROUND_TAB; } From e56a93a06040767844a746c0604513fecd33e795 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 00:17:18 -0500 Subject: [PATCH 09/41] Start documenting CompletionContext --- common/content/completion.js | 129 ++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/common/content/completion.js b/common/content/completion.js index bf4a9622..1ce28900 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -26,6 +26,25 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** + * Creates a new completion context. + * + * @class A class to provide contexts for command completion. + * Manages the filtering and formatting of completions, and keeps + * track of the positions and quoting of replacement text. Allows for + * the creation of sub-contexts with different headers and quoting + * rules. + * + * @param {nsIEditor} editor The editor for which completion is + * intended. May be a {CompletionContext} when forking a context, + * or a {string} when creating a new one. + * @param {string} name The name of this context. Used when the + * context is forked. + * @param {number} offset The offset from the parent context. + * @author Kris Maglione + * @constructor + */ + function CompletionContext(editor, name, offset) //{{{ { if (!(this instanceof arguments.callee)) @@ -44,7 +63,11 @@ function CompletionContext(editor, name, offset) //{{{ else self.contexts[name] = this; + /** + * @property {CompletionContext} This context's parent. {null} when this is a top-level context. + */ self.parent = parent; + ["filters", "keys", "title", "quote"].forEach(function (key) self[key] = parent[key] && util.cloneObject(parent[key])); ["anchored", "compare", "editor", "_filter", "filterFunc", "keys", "_process", "top"].forEach(function (key) @@ -55,10 +78,20 @@ function CompletionContext(editor, name, offset) //{{{ self.offset = parent.offset; self.advance(offset); + /** + * @property {boolean} Specifies that this context is not finished + * generating results. + * @default false + */ self.incomplete = false; self.message = null; + /** + * @property {boolean} Specifies that this context is waiting for the + * user to press . Useful when fetching completions could be + * dangerous or slow, and the user has enabled autocomplete. + */ self.waitingForTab = false; - //delete self._filter; // FIXME? + delete self._generate; delete self._ignoreCase; if (self != this) @@ -76,6 +109,11 @@ function CompletionContext(editor, name, offset) //{{{ this.editor = editor; this.compare = function (a, b) String.localeCompare(a.text, b.text); + /** + * @property {function} The function used to filter the results. + * @default Selects all results which match every predicate in the + * {@link #filters} array. + */ this.filterFunc = function (items) { let self = this; @@ -83,6 +121,10 @@ function CompletionContext(editor, name, offset) //{{{ reduce(function (res, filter) res.filter(function (item) filter.call(self, item)), items); } + /** + * @property {Array} An array of predicates on which to filter the + * results. + */ this.filters = [function (item) { let text = Array.concat(this.getKey(item, "text")); for (let [i, str] in Iterator(text)) @@ -95,22 +137,73 @@ function CompletionContext(editor, name, offset) //{{{ } return false; }]; + /** + * @property {boolean} Specifies whether this context results must + * match the filter at the begining of the string. + * @default true + */ this.anchored = true; + /** + * @property {Object} A map of all contexts, keyed on their names. + * Names are assigned when a context is forked, with its specified + * name appended, after a '/', to its parent's name. + */ this.contexts = { name: this }; + /** + * @property {Object} A mapping of keys, for {@link #getKey}. Given + * { key: value }, getKey(item, key) will return values as such: + * if value is a string, it will return item.item[value]. If it's a + * function, it will return value(item.item). + */ this.keys = { text: 0, description: 1, icon: "icon" }; + /** + * @property {number} This context's offset from the begining of + * {@link #editor}'s value. + */ this.offset = offset || 0; + /** + * @property {function} A function which is called when any subcontext + * changes its completion list. Only called when + * {@link #updateAsync} is true. + */ this.onUpdate = function () true; + /** + * @property {CompletionContext} The top-level completion context. + */ this.top = this; this.__defineGetter__("incomplete", function () this.contextList.some(function (c) c.parent && c.incomplete)); this.__defineGetter__("waitingForTab", function () this.contextList.some(function (c) c.parent && c.waitingForTab)); this.reset(); } + /** + * @property {Object} A general-purpose store for functions which need to + * cache data between calls. + */ this.cache = {}; + /** + * @private + * @property {Object} A cache for return values of {@link #generate}. + */ this.itemCache = {}; + /** + * @property {string} A key detailing when the cached value of + * {@link #generate} may be used. Every call to + * {@link #generate} stores its result in {@link #itemCache}. + * When itemCache[key] exists, its value is returned, and + * {@link #generate} is not called again. + */ this.key = ""; + /** + * @property {string} A message to be shown before any results. + */ this.message = null; this.name = name || ""; + /** @private */ this._completions = []; // FIXME + /** + * Returns a key, as detailed in {@link #keys}. + * @function + */ this.getKey = function (item, key) (typeof self.keys[key] == "function") ? self.keys[key].call(this, item.item) : key in self.keys ? item.item[self.keys[key]] : item.item[key]; @@ -118,6 +211,14 @@ function CompletionContext(editor, name, offset) //{{{ CompletionContext.prototype = { // Temporary + /** + * @property {Object} + * + * An object describing the results from all sub-contexts. Results are + * adjusted so that all have the same starting offset. + * + * @deprecated + */ get allItems() { try @@ -372,6 +473,19 @@ CompletionContext.prototype = { return this._substrings = substrings; }, + /** + * Advances the context count characters. {@link #filter} is + * advanced to match. If {@link #quote} is non-null, its prefix and suffix + * are set to the null-string. + * + * This function is still imperfect for quoted strings. When + * {@link #quote} is non-null, it adjusts the count based on the quoted + * size of the count-character substring of the filter, which is + * accurate so long as unquoting and quoting a string will always map to + * the original quoted string, which is often not the case. + * + * @param {number} count The number of characters to advance the context. + */ advance: function advance(count) { delete this._ignoreCase; @@ -386,6 +500,12 @@ CompletionContext.prototype = { this._filter = this._filter.substr(count); }, + /** + * Gets a key from {@link #cache}, setting it to defVal if it + * doesn't already exists. + * @param {string} key + * @param defVal + */ getCache: function (key, defVal) { if (!(key in this.cache)) @@ -511,6 +631,13 @@ CompletionContext.prototype = { } }, + /** + * Wait for all subcontexts to complete. + * + * @param {boolean} interruptable When true, the call may be interrupted + * via . In this case, "Interrupted" may be thrown. + * @param {number} timeout The maximum time, in milliseconds, to wait. + */ wait: function wait(interruptable, timeout) { let end = Date.now() + timeout; From 4fc2a56ddcf774c025baa45ab5bd0509c7fb4a4f Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 19:07:17 +1100 Subject: [PATCH 10/41] brace formatting fixes --- common/content/commands.js | 3 ++- common/content/completion.js | 3 ++- common/content/hints.js | 6 ++++-- common/content/mappings.js | 3 ++- common/content/modes.js | 5 +++-- common/content/style.js | 6 ++++-- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index 67540eb9..73beca92 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -792,7 +792,8 @@ function Commands() //{{{ argCount: nargsOpt, bang: bangOpt, count: countOpt, - completer: function (context, args) { + completer: function (context, args) + { if (completeFunc) return completeFunc(context, args) }, diff --git a/common/content/completion.js b/common/content/completion.js index 1ce28900..f9ddee03 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1552,7 +1552,8 @@ function Completion() //{{{ }); completionService.stopSearch(); completionService.startSearch(context.filter, "", context.result, { - onSearchResult: function onSearchResult(search, result) { + onSearchResult: function onSearchResult(search, result) + { context.result = result; timer.tell(result); if (result.searchResult <= result.RESULT_SUCCESS) diff --git a/common/content/hints.js b/common/content/hints.js index ca55ac9a..55e8f043 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -581,12 +581,14 @@ function Hints() //{{{ mappings.add(myModes, [";"], "Start an extended hint mode", - function (count) { + function (count) + { extendedhintCount = count; commandline.input(";", function (arg) { setTimeout(function () hints.show(arg), 0) }, { promptHighlight: "Normal", - completer: function (context) { + completer: function (context) + { context.compare = function () 0; context.completions = [[k, v.prompt] for ([k, v] in Iterator(hintModes))]; }, diff --git a/common/content/mappings.js b/common/content/mappings.js index 13bb318a..7e35b115 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -190,7 +190,8 @@ function Mappings() //{{{ [["", ""], commands.OPTION_NOARG] ], literal: 1, - serial: function () { + serial: function () + { let noremap = this.name.indexOf("noremap") > -1; return [ { diff --git a/common/content/modes.js b/common/content/modes.js index b016048b..0159dd24 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -125,7 +125,7 @@ const modes = (function () //{{{ /////////////////////////////////////////////////////////////////////////////{{{ var self = { - NONE: 0, + NONE: 0, __iterator__: function () util.Array.iterator(this.all), @@ -133,7 +133,8 @@ const modes = (function () //{{{ get inputMode() main & (this.COMMAND_LINE | this.INPUT | this.TEXTAREA | this.COMPOSE), - addMode: function (name, extended, display) { + addMode: function (name, extended, display) + { let disp = name.replace("_", " ", "g"); this[name] = 1 << lastMode++; modeMap[name] = modeMap[this[name]] = { diff --git a/common/content/style.js b/common/content/style.js index ea4b5533..ca9f0f1c 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -504,7 +504,8 @@ liberator.registerObserver("load_commands", function () }, { bang: true, - completer: function (context, args) { + completer: function (context, args) + { let compl = []; if (args.completeArg == 0) { @@ -541,7 +542,8 @@ liberator.registerObserver("load_commands", function () commands.add(["dels[tyle]"], "Remove a user stylesheet", - function (args) { + function (args) + { styles.removeSheet(args["-name"], args[0], args.literalArg, args["-index"], false); }, { From 83dc3857e901d26edf32de150e9eadb8ccbf1df4 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 19:12:55 +1100 Subject: [PATCH 11/41] whitespace fix --- common/content/events.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 401244ba..0007de2f 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -242,8 +242,8 @@ function AutoCommands() //{{{ liberator.echomsg("Executing " + event + " Auto commands for \"*\"", 8); let lastPattern = null; - let url = args.url || ""; + for (let [,autoCmd] in Iterator(autoCmds)) { if (autoCmd.pattern.test(url)) @@ -252,22 +252,24 @@ function AutoCommands() //{{{ liberator.echomsg("Executing " + event + " Auto commands for \"" + autoCmd.pattern.source + "\"", 8); lastPattern = autoCmd.pattern; - liberator.echomsg("autocommand " + autoCmd.command, 9); + if (typeof autoCmd.command == "function") { try { autoCmd.command.call(autoCmd, args); } - catch(e) + catch (e) { liberator.reportError(e); liberator.echoerr(e); } } else + { liberator.execute(commands.replaceTokens(autoCmd.command, args)); + } } } } From 35d1a756d860fd0e290c5d9b35829060685b24f4 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 19:13:34 +1100 Subject: [PATCH 12/41] prefer let over var in liberator --- common/content/liberator.js | 85 +++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index 242fde11..d11147c1 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -71,7 +71,7 @@ const liberator = (function () //{{{ let nError = 0; function loadModule(name, func) { - var message = "Loading module " + name + "..."; + let message = "Loading module " + name + "..."; try { liberator.log(message, 0); @@ -228,21 +228,23 @@ const liberator = (function () //{{{ "Open a " + config.name + " dialog", function (args) { - args = args[0]; + let arg = args[0]; try { - var dialogs = config.dialogs; + let dialogs = config.dialogs; + for (let i = 0; i < dialogs.length; i++) { - if (dialogs[i][0] == args) + if (dialogs[i][0] == arg) return dialogs[i][2](); } - liberator.echoerr(args ? "Dialog " + args.quote() + " not available" : "E474: Invalid argument"); + + liberator.echoerr("E475: Invalid argument: " + arg); } catch (e) { - liberator.echoerr("Error opening '" + args + "': " + e); + liberator.echoerr("Error opening '" + arg + "': " + e); } }, { @@ -321,7 +323,7 @@ const liberator = (function () //{{{ { try { - var cmd = liberator.eval(args.string); + let cmd = liberator.eval(args.string); liberator.execute(cmd); } catch (e) @@ -491,13 +493,13 @@ const liberator = (function () //{{{ } else { - var beforeTime = Date.now(); + let beforeTime = Date.now(); method(); if (special) return; - var afterTime = Date.now(); + let afterTime = Date.now(); if (afterTime - beforeTime >= 100) liberator.echo("Total time: " + ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec"); @@ -551,7 +553,7 @@ const liberator = (function () //{{{ // similar in his config function hideGUI() { - var guioptions = config.guioptions; + let guioptions = config.guioptions; for (let option in guioptions) { guioptions[option].forEach(function (elem) { @@ -629,7 +631,7 @@ const liberator = (function () //{{{ // liberator.dump("type: " + type + " mode: " + mode + "data: " + data + "\n"); for (let i = 0; i < callbacks.length; i++) { - var [thistype, thismode, thisfunc] = callbacks[i]; + let [thistype, thismode, thisfunc] = callbacks[i]; if (mode == thismode && type == thistype) return thisfunc.call(this, data); } @@ -803,19 +805,24 @@ const liberator = (function () //{{{ evalExpression: function (string) { string = string.toString().replace(/^\s*/, "").replace(/\s*$/, ""); - var matches = string.match(/^&(\w+)/); + let matches = string.match(/^&(\w+)/); + if (matches) { - var opt = this.options.get(matches[1]); + let opt = this.options.get(matches[1]); + if (!opt) { this.echoerr("E113: Unknown option: " + matches[1]); return; } - var type = opt.type; - var value = opt.getter(); + + let type = opt.type; + let value = opt.getter(); + if (type != "boolean" && type != "number") value = value.toString(); + return value; } @@ -823,7 +830,9 @@ const liberator = (function () //{{{ else if (matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) { if (matches) + { return matches[2].toString(); + } else { this.echoerr("E115: Missing quote: " + string); @@ -837,7 +846,8 @@ const liberator = (function () //{{{ return parseInt(match[1], 10); } - var reference = this.variableReference(string); + let reference = this.variableReference(string); + if (!reference[0]) this.echoerr("E121: Undefined variable: " + string); else @@ -929,12 +939,12 @@ const liberator = (function () //{{{ help: function (topic) { - var where = (options["newtab"] && options.get("newtab").has("all", "help")) + let where = (options["newtab"] && options.get("newtab").has("all", "help")) ? liberator.NEW_TAB : liberator.CURRENT_TAB; if (!topic) { - var helpFile = options["helpfile"]; + let helpFile = options["helpfile"]; if (config.helpFiles.indexOf(helpFile) != -1) liberator.open("chrome://liberator/locale/" + helpFile, where); @@ -957,8 +967,8 @@ const liberator = (function () //{{{ }, 500); } - var items = completion.runCompleter("help", topic); - var partialMatch = -1; + let items = completion.runCompleter("help", topic); + let partialMatch = -1; for (let [i, item] in Iterator(items)) { @@ -1032,8 +1042,8 @@ const liberator = (function () //{{{ // TODO: add proper level constants log: function (msg, level) { - var verbose = 0; - if (typeof level != "number") // XXX + let verbose = 0; + if (level == undefined) level = 1; // options does not exist at the very beginning @@ -1046,7 +1056,7 @@ const liberator = (function () //{{{ if (typeof msg == "object") msg = util.objectToString(msg, false); - var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); + const consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); consoleService.logStringMessage(config.name.toLowerCase() + ": " + msg); }, @@ -1183,8 +1193,8 @@ const liberator = (function () //{{{ const nsIAppStartup = Ci.nsIAppStartup; // notify all windows that an application quit has been requested. - var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); - var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); + const os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); + const cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); os.notifyObservers(cancelQuit, "quit-application-requested", null); // something aborted the quit process. @@ -1195,17 +1205,16 @@ const liberator = (function () //{{{ os.notifyObservers(null, "quit-application-granted", null); // enumerate all windows and call shutdown handlers - var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - var windows = wm.getEnumerator(null); + const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); + let windows = wm.getEnumerator(null); while (windows.hasMoreElements()) { - var win = windows.getNext(); + let win = windows.getNext(); if (("tryToClose" in win) && !win.tryToClose()) return; } - Cc["@mozilla.org/toolkit/app-startup;1"] - .getService(nsIAppStartup) - .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); + Cc["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup) + .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); }, // TODO: move to {muttator,vimperator,...}.js @@ -1357,7 +1366,7 @@ const liberator = (function () //{{{ if (!string) return [null, null, null]; - var matches = string.match(/^([bwtglsv]):(\w+)/); + let matches = string.match(/^([bwtglsv]):(\w+)/); if (matches) // Variable { // Other variables should be implemented @@ -1380,12 +1389,14 @@ const liberator = (function () //{{{ get windows() { - var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - var wa = []; - var enumerator = wm.getEnumerator("navigator:browser"); + const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); + let windows = []; + let enumerator = wm.getEnumerator("navigator:browser"); + while (enumerator.hasMoreElements()) - wa.push(enumerator.getNext()); - return wa; + windows.push(enumerator.getNext()); + + return windows; } }; //}}} From 67e5788fd56ba58c103e401f813f2ea4d7ba0948 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 19:14:38 +1100 Subject: [PATCH 13/41] prefer let over var in Hints --- common/content/hints.js | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/common/content/hints.js b/common/content/hints.js index 55e8f043..25803f34 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -107,19 +107,19 @@ function Hints() //{{{ if (!win) win = window.content; - var doc = win.document; - var height = win.innerHeight; - var width = win.innerWidth; - var scrollX = doc.defaultView.scrollX; - var scrollY = doc.defaultView.scrollY; + let doc = win.document; + let height = win.innerHeight; + let width = win.innerWidth; + let scrollX = doc.defaultView.scrollX; + let scrollY = doc.defaultView.scrollY; - var baseNodeAbsolute = util.xmlToDom(, doc); + let baseNodeAbsolute = util.xmlToDom(, doc); - var elem, tagname, text, span, rect; - var res = buffer.evaluateXPath(hintMode.tags(), doc, null, true); + let elem, tagname, text, span, rect; + let res = buffer.evaluateXPath(hintMode.tags(), doc, null, true); - var fragment = util.xmlToDom(
, doc); - var start = pageHints.length; + let fragment = util.xmlToDom(
, doc); + let start = pageHints.length; for (let elem in res) { // TODO: for iframes, this calculation is wrong @@ -131,7 +131,7 @@ function Hints() //{{{ if (!rect) continue; - var computedStyle = doc.defaultView.getComputedStyle(elem, null); + let computedStyle = doc.defaultView.getComputedStyle(elem, null); if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none") continue; @@ -171,11 +171,11 @@ function Hints() //{{{ // TODO: make it aware of imgspans function showActiveHint(newID, oldID) { - var oldElem = validHints[oldID - 1]; + let oldElem = validHints[oldID - 1]; if (oldElem) setClass(oldElem, false); - var newElem = validHints[newID - 1]; + let newElem = validHints[newID - 1]; if (newElem) setClass(newElem, true); } @@ -274,7 +274,7 @@ function Hints() //{{{ function removeHints(timeout) { - var firstElem = validHints[0] || null; + let firstElem = validHints[0] || null; for (let [,{ doc: doc, start: start, end: end }] in Iterator(docs)) { @@ -329,9 +329,9 @@ function Hints() //{{{ } } - var timeout = followFirst || events.feedingKeys ? 0 : 500; - var activeIndex = (hintNumber ? hintNumber - 1 : 0); - var elem = validHints[activeIndex]; + let timeout = followFirst || events.feedingKeys ? 0 : 500; + let activeIndex = (hintNumber ? hintNumber - 1 : 0); + let elem = validHints[activeIndex]; removeHints(timeout); if (timeout == 0) @@ -369,7 +369,7 @@ function Hints() //{{{ function tokenize(pat, string) string.split(pat).map(String.toLowerCase); function containsMatcher(hintString) //{{{ { - var tokens = tokenize(/\s+/, hintString); + let tokens = tokenize(/\s+/, hintString); return function (linkText) { linkText = linkText.toLowerCase(); @@ -379,14 +379,14 @@ function Hints() //{{{ function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{ { - var hintStrings = tokenize(/\s+/, hintString); - var wordSplitRegex = RegExp(options["wordseparators"]); + let hintStrings = tokenize(/\s+/, hintString); + let wordSplitRegex = RegExp(options["wordseparators"]); // What the **** does this do? --Kris function charsAtBeginningOfWords(chars, words, allowWordOverleaping) { - var charIdx = 0; - var numMatchedWords = 0; + let charIdx = 0; + let numMatchedWords = 0; for (let [,word] in Iterator(words)) { if (word.length == 0) @@ -414,7 +414,7 @@ function Hints() //{{{ } // the current word matches same characters as the previous word - var prevCharIdx; + let prevCharIdx; if (wcIdx > 0) { prevCharIdx = charIdx; @@ -468,7 +468,7 @@ function Hints() //{{{ function stringsAtBeginningOfWords(strings, words, allowWordOverleaping) { - var strIdx = 0; + let strIdx = 0; for (let [,word] in Iterator(words)) { if (word.length == 0) @@ -505,7 +505,7 @@ function Hints() //{{{ } } //}}} - var hintMatching = options["hintmatching"]; + let hintMatching = options["hintmatching"]; switch (hintMatching) { case "contains" : return containsMatcher(hintString); @@ -655,8 +655,8 @@ function Hints() //{{{ onEvent: function (event) { - var key = events.toString(event); - var followFirst = false; + let key = events.toString(event); + let followFirst = false; // clear any timeout which might be active after pressing a number if (activeTimeout) @@ -677,7 +677,7 @@ function Hints() //{{{ if (hintNumber == 0) hintNumber = 1; - var oldID = hintNumber; + let oldID = hintNumber; if (key == "") { if (++hintNumber > validHints.length) @@ -721,7 +721,7 @@ function Hints() //{{{ { prevInput = "number"; - var oldHintNumber = hintNumber; + let oldHintNumber = hintNumber; if (hintNumber == 0 || usedTabKey) { usedTabKey = false; From 01a7ead528502b2f1245b22a35d5d3e3627dcaab Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:00:14 +1100 Subject: [PATCH 14/41] add missing semicolons --- common/content/commands.js | 8 ++++---- common/content/editor.js | 2 +- common/content/eval.js | 2 +- common/content/events.js | 4 ++-- common/content/find.js | 2 +- common/content/hints.js | 10 +++++----- common/content/io.js | 2 +- common/content/liberator-overlay.js | 2 +- common/content/liberator.js | 2 +- common/content/options.js | 6 +++--- common/content/style.js | 20 ++++++++++---------- common/content/tabs.js | 2 +- vimperator/content/bookmarks.js | 18 ++++++++++++------ vimperator/content/config.js | 2 +- 14 files changed, 44 insertions(+), 38 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index 73beca92..75711744 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -120,7 +120,7 @@ Command.prototype = { if (matches && matches[2]) { commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"), - function (args) { exec(matches[1] + "\n" + args) }); + function (args) { exec(matches[1] + "\n" + args); }); return; } } @@ -169,7 +169,7 @@ function Commands() //{{{ const quoteMap = { "\n": "n", "\t": "t" - } + }; function quote(q, list) { let re = RegExp("[" + list + "]", "g"); @@ -184,7 +184,7 @@ function Commands() //{{{ '"': quote('"', '\n\t"\\\\'), "'": quote("'", "\\\\'"), "": quote("", "\\\\ ") - } + }; const ArgType = new Struct("description", "parse"); const argTypes = [ @@ -555,7 +555,7 @@ function Commands() //{{{ if (complete) { if (argCount == "0" || args.length > 0 && (/[1?]/.test(argCount))) - complete.highlight(i, sub.length, "SPELLCHECK") + complete.highlight(i, sub.length, "SPELLCHECK"); } if (args.length == literal) diff --git a/common/content/editor.js b/common/content/editor.js index be1b3aba..6219a4ea 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -857,7 +857,7 @@ function Editor() //{{{ editor.selection.deleteFromDocument(); editor.insertText(val); } - }, this) + }, this); if (res == false) throw "Couldn't create temporary file"; } diff --git a/common/content/eval.js b/common/content/eval.js index 14f5fd95..daf0dba6 100644 --- a/common/content/eval.js +++ b/common/content/eval.js @@ -1,4 +1,4 @@ -try { __liberator_eval_result = eval(__liberator_eval_string) +try { __liberator_eval_result = eval(__liberator_eval_string); } catch (e) { diff --git a/common/content/events.js b/common/content/events.js index 0007de2f..4c1d9f8c 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -689,7 +689,7 @@ function Events() //{{{ commands.add(["macros"], "List all macros", - function (args) { completion.listCompleter("macro", args[0]) }, + function (args) { completion.listCompleter("macro", args[0]); }, { argCount: "?", completer: function (context) completion.macro(context) @@ -1283,7 +1283,7 @@ function Events() //{{{ { events.feedingKeys = false; if (lastMacro) - setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + lastMacro + "'") }, 100); + setTimeout(function () { liberator.echomsg("Canceled playback of macro '" + lastMacro + "'"); }, 100); event.preventDefault(); event.stopPropagation(); return true; diff --git a/common/content/find.js b/common/content/find.js index 794476ac..41b15599 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -176,7 +176,7 @@ function Search() //{{{ return; } - var baseNode = + var baseNode = ; baseNode = util.xmlToDom(baseNode, window.content.document); var body = doc.body; diff --git a/common/content/hints.js b/common/content/hints.js index 25803f34..90c7e14f 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -237,7 +237,7 @@ function Hints() //{{{ hint[IMGSPAN] = imgspan; span.parentNode.appendChild(imgspan); } - setClass(imgspan, activeHint == hintnum) + setClass(imgspan, activeHint == hintnum); } span.setAttribute("number", hintnum); @@ -289,7 +289,7 @@ function Hints() //{{{ // animate the disappearance of the first hint if (timeout && firstElem) - setTimeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight") }, timeout); + setTimeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight"); }, timeout); } styles.removeSheet("hint-positions", null, null, null, true); @@ -374,7 +374,7 @@ function Hints() //{{{ { linkText = linkText.toLowerCase(); return tokens.every(function (token) linkText.indexOf(token) >= 0); - } + }; } //}}} function wordStartsWithMatcher(hintString, allowWordOverleaping) //{{{ @@ -502,7 +502,7 @@ function Hints() //{{{ return charsAtBeginningOfWords(hintStrings[0], words, allowWordOverleaping); else return stringsAtBeginningOfWords(hintStrings, words, allowWordOverleaping); - } + }; } //}}} let hintMatching = options["hintmatching"]; @@ -584,7 +584,7 @@ function Hints() //{{{ function (count) { extendedhintCount = count; - commandline.input(";", function (arg) { setTimeout(function () hints.show(arg), 0) }, + commandline.input(";", function (arg) { setTimeout(function () hints.show(arg), 0); }, { promptHighlight: "Normal", completer: function (context) diff --git a/common/content/io.js b/common/content/io.js index fd111d52..8a5e3d97 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -30,7 +30,7 @@ the terms of any one of the MPL, the GPL or the LGPL. plugins.contexts = {}; function Script(file) { - let self = plugins.contexts[file.path] + let self = plugins.contexts[file.path]; if (self) { if (self.onUnload) diff --git a/common/content/liberator-overlay.js b/common/content/liberator-overlay.js index 288559e2..9b0df22b 100644 --- a/common/content/liberator-overlay.js +++ b/common/content/liberator-overlay.js @@ -13,7 +13,7 @@ { try { - loader.loadSubScript(base + script, modules) + loader.loadSubScript(base + script, modules); return; } catch (e) diff --git a/common/content/liberator.js b/common/content/liberator.js index d11147c1..1e3d7037 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -109,7 +109,7 @@ const liberator = (function () //{{{ .forEach(function (elem) { if (elem) - elem.collapsed = (opts.indexOf(opt) == -1) + elem.collapsed = (opts.indexOf(opt) == -1); }); } } diff --git a/common/content/options.js b/common/content/options.js index 460490bb..6373dcb6 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -73,7 +73,7 @@ function Option(names, description, type, defaultValue, extraInfo) //{{{ } Option.prototype = { get globalvalue() options.store.get(this.name), - set globalvalue(val) { options.store.set(this.name, val) }, + set globalvalue(val) { options.store.set(this.name, val); }, parseValues: function (value) { @@ -164,8 +164,8 @@ Option.prototype = { if (this.checkHas) test = function (val) values.some(function (value) self.checkHas(value, val)); let values = this.values; - /* Return whether some argument matches */ - return Array.some(arguments, function (val) test(val)) + // return whether some argument matches + return Array.some(arguments, function (val) test(val)); }, hasName: function (name) this.names.indexOf(name) >= 0, diff --git a/common/content/style.js b/common/content/style.js index ca9f0f1c..62c14ef2 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -166,7 +166,7 @@ function Highlights(name, store, serial) return error; style.value = newStyle; highlight[style.class] = style; - } + }; this.selector = function (class) { @@ -200,7 +200,7 @@ function Highlights(name, store, serial) if (hl.value == hl.default) this.set(class); } - } + }; } function Styles(name, store, serial) @@ -264,7 +264,7 @@ function Styles(name, store, serial) names[name] = sheet; } return null; - } + }; this.findSheets = function (name, filter, css, index, system) { @@ -324,7 +324,7 @@ function Styles(name, store, serial) } } return matches.length; - } + }; this.registerSheet = function (uri, doCheckSyntax, reload) { @@ -336,14 +336,14 @@ function Styles(name, store, serial) uri = ios.newURI(uri, null, null); if (reload || !sss.sheetRegistered(uri, sss.USER_SHEET)) sss.loadAndRegisterSheet(uri, sss.USER_SHEET); - } + }; this.unregisterSheet = function (uri) { uri = ios.newURI(uri, null, null); if (sss.sheetRegistered(uri, sss.USER_SHEET)) sss.unregisterSheet(uri, sss.USER_SHEET); - } + }; // FIXME this.registerAgentSheet = function (uri) @@ -351,14 +351,14 @@ function Styles(name, store, serial) this.unregisterAgentSheet(uri); uri = ios.newURI(uri, null, null); sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET); - } + }; this.unregisterAgentSheet = function (uri) { uri = ios.newURI(uri, null, null); if (sss.sheetRegistered(uri, sss.AGENT_SHEET)) sss.unregisterSheet(uri, sss.AGENT_SHEET); - } + }; function wrapCSS(sheet) { @@ -425,7 +425,7 @@ function Styles(name, store, serial) if (errors.length) { let err = new Error("", errors[0].sourceName.replace(/^(chrome-data:text\/css,).*/, "$1..."), errors[0].lineNumber); - err.name = "CSSError" + err.name = "CSSError"; err.message = errors.reduce(function (msg, e) msg + "; " + e.lineNumber + ": " + e.errorMessage, errors.shift().errorMessage); err.echoerr = err.fileName + ":" + err.lineNumber + ": " + err.message; @@ -516,7 +516,7 @@ liberator.registerObserver("load_commands", function () } catch (e) {} context.anchored = false; - context.completions = compl.concat([[s, ""] for each (s in styles.sites)]) + context.completions = compl.concat([[s, ""] for each (s in styles.sites)]); } else if (args.completeArg == 1) { diff --git a/common/content/tabs.js b/common/content/tabs.js index 6fee2043..6cec525d 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -598,7 +598,7 @@ function Tabs() //{{{ function (args) { let count = args.count; - args = args[0] + args = args[0]; if (count < 1) count = 1; diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index 9dd6e9b1..8acac9f7 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -238,7 +238,7 @@ function Bookmarks() //{{{ var cache = storage.newObject("bookmark-cache", Cache, false); storage.addObserver("bookmark-cache", bookmarkObserver); liberator.registerObserver("shutdown", function () { - storage.removeObserver("bookmark-cache", bookmarkObserver) + storage.removeObserver("bookmark-cache", bookmarkObserver); }); liberator.registerObserver("enter", function () { @@ -358,7 +358,7 @@ function Bookmarks() //{{{ if (!args.bang) { context.completions = [[content.document.documentURI, "Current Location"]]; - return + return; } completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] }); }, @@ -784,7 +784,7 @@ function History() //{{{ function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); }, { bang: true, - completer: function (context) { context.quote = null, completion.history(context) }, + completer: function (context) { context.quote = null, completion.history(context); }, options: [[["-max", "-m"], options.OPTION_INT]] // completer: function (filter) completion.history(filter) }); @@ -823,7 +823,7 @@ function History() //{{{ url: node.uri, title: node.title, icon: node.icon ? node.icon.spec : DEFAULT_FAVICON - } + }; }); root.containerOpen = false; // close a container after using it! @@ -844,7 +844,10 @@ function History() //{{{ { let index = window.getWebNavigation().sessionHistory.index; if (index == 0) - return liberator.beep(); // really wanted? + { + liberator.beep(); // XXX: really wanted? + return; + } window.getWebNavigation().gotoIndex(0); }, @@ -853,7 +856,10 @@ function History() //{{{ { let index = window.getWebNavigation().sessionHistory.index; if (index == window.getWebNavigation().sessionHistory.count - 1) - return liberator.beep(); + { + liberator.beep(); + return; + } window.getWebNavigation().gotoIndex(max); }, diff --git a/vimperator/content/config.js b/vimperator/content/config.js index a11c8e2c..cc353a28 100644 --- a/vimperator/content/config.js +++ b/vimperator/content/config.js @@ -171,7 +171,7 @@ const config = { //{{{ + "}", true); delete img; - } + }; //////////////////////////////////////////////////////////////////////////////// ////////////////////// MAPPINGS //////////////////////////////////////////////// From 98cc66c5695f5ab71176e4adffb3a248a2d25c96 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:09:37 +1100 Subject: [PATCH 15/41] remove some ancient cruft --- common/content/events.js | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 4c1d9f8c..c477cb80 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1339,25 +1339,7 @@ function Events() //{{{ return false; } - // // FIXME: handle middle click in content area {{{ - // // alert(event.target.id); - // if (/*event.type == 'mousedown' && */event.button == 1 && event.target.id == 'content') - // { - // //echo("foo " + event.target.id); - // //if (document.commandDispatcher.focusedElement == command_line.inputField) - // { - // //alert(command_line.value.substring(0, command_line.selectionStart)); - // command_line.value = command_line.value.substring(0, command_line.selectionStart) + - // window.readFromClipboard() + - // command_line.value.substring(command_line.selectionEnd, command_line.value.length); - // alert(command_line.value); - // } - // //else - // // { - // // openURLs(window.readFromClipboard()); - // // } - // return true; - // } }}} + // TODO: handle middle click in content area if (key != "" && key != "") { From b08f9053b3c24b167e3ffcf1388a4d0e438a192e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:12:06 +1100 Subject: [PATCH 16/41] declare variable in getMenuItems#addChildren() --- common/content/liberator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index 1e3d7037..30283ee6 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -268,7 +268,7 @@ const liberator = (function () //{{{ } else { - path = parent; + let path = parent; if (item.localName == "menu") path += item.label + "."; addChildren(item, path); From b2799ebeddd4e4a14b10958179123e1259d8ec63 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:17:52 +1100 Subject: [PATCH 17/41] minor refactoring of "b" action --- common/content/tabs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/content/tabs.js b/common/content/tabs.js index 6cec525d..4e8512f2 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -252,8 +252,9 @@ function Tabs() //{{{ function (count) { if (count != -1) - return tabs.switchTo(String(count)); - commandline.open(":", "buffer! ", modes.EX); + tabs.switchTo(String(count)); + else + commandline.open(":", "buffer! ", modes.EX); }, { flags: Mappings.flags.COUNT }); From d277dd5c1cfe9ef2265fdd02af4341879268efb2 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:24:31 +1100 Subject: [PATCH 18/41] minor refactoring of :dialog action --- common/content/liberator.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index 30283ee6..2edaa653 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -232,12 +232,16 @@ const liberator = (function () //{{{ try { + // TODO: why are these sorts of properties arrays? --djk let dialogs = config.dialogs; - for (let i = 0; i < dialogs.length; i++) + for (let [,dialog] in Iterator(dialogs)) { - if (dialogs[i][0] == arg) - return dialogs[i][2](); + if (arg == dialog[0]) + { + dialog[2](); + return; + } } liberator.echoerr("E475: Invalid argument: " + arg); From 39d6542e80b6cd610c43209c68a16fad72207d7b Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:50:12 +1100 Subject: [PATCH 19/41] minor refactoring of :command action --- common/content/commands.js | 42 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index 75711744..7486d344 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -759,19 +759,20 @@ function Commands() //{{{ { if (/^custom,/.test(completeOpt)) { + completeOpt = completeOpt.substr(7); completeFunc = function () { try { - var completer = liberator.eval(completeOpt.substr(7)); + var completer = liberator.eval(completeOpt); if (!(completer instanceof Function)) - throw new TypeError("User-defined custom completer '" + completeOpt.substr(7) + "' is not a function"); + throw new TypeError("User-defined custom completer '" + completeOpt + "' is not a function"); } catch (e) { // FIXME: should be pushed to the MOW - liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7)); + liberator.echoerr("E117: Unknown function: " + completeOpt); liberator.log(e); return undefined; } @@ -784,26 +785,23 @@ function Commands() //{{{ } } - if (!commands.addUserCommand( - [cmd], - "User defined command", - userCommand, - { - argCount: nargsOpt, - bang: bangOpt, - count: countOpt, - completer: function (context, args) - { - if (completeFunc) - return completeFunc(context, args) - }, - replacementText: args.literalArg - }, - args.bang) - ) - { + let added = commands.addUserCommand([cmd], + "User defined command", + userCommand, + { + argCount: nargsOpt, + bang: bangOpt, + count: countOpt, + completer: function (context, args) + { + if (completeFunc) + return completeFunc(context, args) + }, + replacementText: args.literalArg + }, args.bang); + + if (!added) liberator.echoerr("E174: Command already exists: add ! to replace it"); - } } else { From 89dc3c2078baeefd494f529cc4b11c40b40f6fbc Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 19 Dec 2008 23:59:25 +1100 Subject: [PATCH 20/41] trivial refactoring of :emenu and :chdir actions --- common/content/io.js | 20 ++++++++++---------- common/content/liberator.js | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/content/io.js b/common/content/io.js index 8a5e3d97..136b2b13 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -194,17 +194,17 @@ function IO() //{{{ "Change the current directory", function (args) { - args = args.literalArg; + let arg = args.literalArg; - if (!args) + if (!arg) { - args = "~"; + arg = "~"; } - else if (args == "-") + else if (arg == "-") { if (oldcwd) { - args = oldcwd.path; + arg = oldcwd.path; } else { @@ -213,14 +213,14 @@ function IO() //{{{ } } - args = io.expandPath(args); + arg = io.expandPath(arg); // go directly to an absolute path or look for a relative path // match in 'cdpath' // TODO: handle ../ and ./ paths - if (isAbsolutePath(args)) + if (isAbsolutePath(arg)) { - if (io.setCurrentDirectory(args)) + if (io.setCurrentDirectory(arg)) liberator.echomsg(io.getCurrentDirectory().path); } else @@ -230,7 +230,7 @@ function IO() //{{{ for (let [,dir] in Iterator(dirs)) { - dir = joinPaths(dir, args); + dir = joinPaths(dir, arg); if (dir.exists() && dir.isDirectory() && dir.isReadable()) { @@ -243,7 +243,7 @@ function IO() //{{{ if (!found) { - liberator.echoerr("E344: Can't find directory " + args.quote() + " in cdpath\n" + liberator.echoerr("E344: Can't find directory " + arg.quote() + " in cdpath\n" + "E472: Command failed"); } } diff --git a/common/content/liberator.js b/common/content/liberator.js index 2edaa653..e5c8cfa8 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -289,18 +289,18 @@ const liberator = (function () //{{{ "Execute the specified menu item from the command line", function (args) { - args = args.literalArg; + let arg = args.literalArg; let items = getMenuItems(); - if (!items.some(function (i) i.fullMenuPath == args)) + if (!items.some(function (i) i.fullMenuPath == arg)) { - liberator.echoerr("E334: Menu not found: " + args); + liberator.echoerr("E334: Menu not found: " + arg); return; } for (let [,item] in Iterator(items)) { - if (item.fullMenuPath == args) + if (item.fullMenuPath == arg) item.doCommand(); } }, From 9df54a457267d9f2c599cb9803f61fc87b83a460 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 20 Dec 2008 00:15:13 +1100 Subject: [PATCH 21/41] fix transposed defaults in showmode and shell help --- vimperator/locale/en-US/options.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt index 71056576..2d017a69 100644 --- a/vimperator/locale/en-US/options.txt +++ b/vimperator/locale/en-US/options.txt @@ -614,7 +614,7 @@ ____ |\'shell'| |\'sh'| -||'shell' 'sh'|| string (default: on) +||'shell' 'sh'|| string (default: "-c", Win32: "/c") ____ Shell to use for executing :! and :run commands. ____ @@ -630,7 +630,7 @@ ____ |\'nosmd'| |\'noshowmode'| |\'smd'| |\'showmode'| -||'showmode' 'smd'|| boolean (default: "-c", Win32: "/c") +||'showmode' 'smd'|| boolean (default: on) ____ Show the current mode in the command-line. ____ From abf6bafaf7272415b7ca16ebd8c4347d14a21f82 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 20 Dec 2008 00:31:13 +1100 Subject: [PATCH 22/41] fix search highlighting when 'incsearch' is set - Algardas --- common/content/find.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/content/find.js b/common/content/find.js index 41b15599..923426f5 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -408,11 +408,10 @@ function Search() //{{{ if (!command) command = lastSearchPattern; + this.clear(); + if (!options["incsearch"] || !found) - { - this.clear(); this.find(command, backwards); - } lastSearchBackwards = backwards; //lastSearchPattern = command.replace(backwards ? /\?.*/ : /\/.*/, ""); // XXX From 6e9262ef6472b1aa2c2ce2c278d2f28e47680a6b Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 20 Dec 2008 01:08:24 +1100 Subject: [PATCH 23/41] document :hardcopy >{filename}...since it was committed --- common/content/buffer.js | 18 +++++++++++------- vimperator/NEWS | 1 + vimperator/locale/en-US/print.txt | 6 ++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 7527f7ad..0843ecb6 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -468,14 +468,18 @@ function Buffer() //{{{ "Print current document", function (args) { + let arg = args[0]; + + // FIXME: arg handling is a bit of a mess, check for filename + if (arg && (liberator.has("Win32") || arg[0] != ">")) + return liberator.echoerr("E488: Trailing characters"); + options.temporaryContext(function () { - if (args[0]) + if (arg) { - if (args[0][0] != ">") - return liberator.echoerr("E488: Trailing characters"); options.setPref("print.print_to_file", "true"); - options.setPref("print.print_to_filename", io.getFile(args[0].substr(1)).path); - liberator.echomsg("Printing to file: " + args[0].substr(1)); + options.setPref("print.print_to_filename", io.getFile(arg.substr(1)).path); + liberator.echomsg("Printing to file: " + arg.substr(1)); } else { @@ -488,8 +492,8 @@ function Buffer() //{{{ getBrowser().contentWindow.print(); }); - if (args[0]) - liberator.echomsg("Printed: " + args[0].substr(1)); + if (arg) + liberator.echomsg("Printed: " + arg.substr(1)); else liberator.echomsg("Print job sent."); }, diff --git a/vimperator/NEWS b/vimperator/NEWS index c850ec2b..f982feda 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -21,6 +21,7 @@ VimperatorLeave respectively * IMPORTANT: 'verbose' is now by default at 1, set to 0 to not show any status messages + * :hardcopy now supports output redirection to a file on Unix and MacUnix * add ";f" extended hint mode to focus a frame * add "r", "l", and "b" to 'guioptions' to toggle the scrollbars. * remove spaces and newlines when open urls starting with http:// or similar diff --git a/vimperator/locale/en-US/print.txt b/vimperator/locale/en-US/print.txt index aad69e18..397f9dbb 100644 --- a/vimperator/locale/en-US/print.txt +++ b/vimperator/locale/en-US/print.txt @@ -10,6 +10,12 @@ number of copies, orientation, etc. When used with [!], the dialog is skipped and the default printer used. ________________________________________________________________________________ + +||:ha[rdcopy][!] >{filename}|| + +________________________________________________________________________________ +As above, but write the output to {filename}. +________________________________________________________________________________ + section:Firefox{nbsp}printing{nbsp}dialogs[firefox-print-dialogs] The "Print Preview" and "Page Setup" dialogs can be opened via the :dialog command From 073383ef1225e5429f68f8dd11dd11c3b740e165 Mon Sep 17 00:00:00 2001 From: Ted Pavlic Date: Fri, 19 Dec 2008 10:49:56 -0500 Subject: [PATCH 24/41] Allow empty defsearch. --- common/content/completion.js | 2 +- vimperator/content/bookmarks.js | 7 +++++++ vimperator/locale/en-US/options.txt | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/content/completion.js b/common/content/completion.js index f9ddee03..f7594214 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1645,7 +1645,7 @@ function Completion() //{{{ let engines = bookmarks.getSearchEngines(); context.title = ["Search Keywords"]; - context.completions = keywords.concat(engines); + context.completions = [ bookmarks.makeKeyword("", "No default search engine", null, "") ].concat( keywords.concat(engines) ); context.keys = { text: 0, description: 1, icon: 2 }; if (!space || noSuggest) diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index 8acac9f7..e887a580 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -589,6 +589,13 @@ function Bookmarks() //{{{ return process(resp); }, + // Allows for creation of anonymous keyword (e.g., for empty + // defsearch's) + makeKeyword: function makeKeyword(keyword, title, icon, url) + { + return new Keyword( keyword, title, icon, url ); + }, + // TODO: add filtering // format of returned array: // [keyword, helptext, url] diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt index 2d017a69..22cdd8c7 100644 --- a/vimperator/locale/en-US/options.txt +++ b/vimperator/locale/en-US/options.txt @@ -247,6 +247,9 @@ This means, it you set 'defsearch' to "youtube", then [c]:open arnold schwarzenegger[c] will be exactly the same as [c]:open youtube arnold schwarzenegger[c]. Therefore, you need to add a keyword or search engine "youtube" first. + +If 'defsearch' is empty, then Firefox will always attempt to open the +raw [[arg]]. ____ From da5db4429e7a68c8c49614350bcec2a674d17e38 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 12:29:13 -0500 Subject: [PATCH 25/41] Revert "Allow empty defsearch." This reverts commit 3cab7c16a0ef5e39f9aeeb8ea1ed9602a6a152f4. --- common/content/completion.js | 2 +- vimperator/content/bookmarks.js | 7 ------- vimperator/locale/en-US/options.txt | 3 --- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/common/content/completion.js b/common/content/completion.js index f7594214..f9ddee03 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1645,7 +1645,7 @@ function Completion() //{{{ let engines = bookmarks.getSearchEngines(); context.title = ["Search Keywords"]; - context.completions = [ bookmarks.makeKeyword("", "No default search engine", null, "") ].concat( keywords.concat(engines) ); + context.completions = keywords.concat(engines); context.keys = { text: 0, description: 1, icon: 2 }; if (!space || noSuggest) diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index e887a580..8acac9f7 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -589,13 +589,6 @@ function Bookmarks() //{{{ return process(resp); }, - // Allows for creation of anonymous keyword (e.g., for empty - // defsearch's) - makeKeyword: function makeKeyword(keyword, title, icon, url) - { - return new Keyword( keyword, title, icon, url ); - }, - // TODO: add filtering // format of returned array: // [keyword, helptext, url] diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt index 22cdd8c7..2d017a69 100644 --- a/vimperator/locale/en-US/options.txt +++ b/vimperator/locale/en-US/options.txt @@ -247,9 +247,6 @@ This means, it you set 'defsearch' to "youtube", then [c]:open arnold schwarzenegger[c] will be exactly the same as [c]:open youtube arnold schwarzenegger[c]. Therefore, you need to add a keyword or search engine "youtube" first. - -If 'defsearch' is empty, then Firefox will always attempt to open the -raw [[arg]]. ____ From 669043da71e53298932eecd8978b9b1dca2a065c Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 12:33:22 -0500 Subject: [PATCH 26/41] Add completion for empty 'defsearch' --- vimperator/content/bookmarks.js | 6 +++++- vimperator/locale/en-US/options.txt | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js index 8acac9f7..afb276e4 100644 --- a/vimperator/content/bookmarks.js +++ b/vimperator/content/bookmarks.js @@ -258,7 +258,11 @@ function Bookmarks() //{{{ "Set the default search engine", "string", "google", { - completer: function completer(context) completion.search(context, true), + completer: function completer(context) + { + completion.search(context, true) + context.completions = [["", "Don't perform searches by default"]].concat(context.completions); + }, validator: Option.validateCompleter }); diff --git a/vimperator/locale/en-US/options.txt b/vimperator/locale/en-US/options.txt index 2d017a69..22cdd8c7 100644 --- a/vimperator/locale/en-US/options.txt +++ b/vimperator/locale/en-US/options.txt @@ -247,6 +247,9 @@ This means, it you set 'defsearch' to "youtube", then [c]:open arnold schwarzenegger[c] will be exactly the same as [c]:open youtube arnold schwarzenegger[c]. Therefore, you need to add a keyword or search engine "youtube" first. + +If 'defsearch' is empty, then Firefox will always attempt to open the +raw [[arg]]. ____ From 057d66ce65f4bd9037960986a42d0993e791398f Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 13:27:01 -0500 Subject: [PATCH 27/41] Document some more crap. --- common/content/buffer.js | 152 ++++++++++++++++++++++++++++++---- common/content/commands.js | 5 ++ common/content/completion.js | 5 ++ common/content/editor.js | 5 ++ common/content/events.js | 8 ++ common/content/find.js | 5 ++ common/content/hints.js | 5 ++ common/content/io.js | 7 +- common/content/liberator.js | 2 + common/content/mappings.js | 5 ++ common/content/modes.js | 2 + common/content/options.js | 5 ++ common/content/style.js | 155 ++++++++++++++++++++--------------- common/content/tabs.js | 2 + common/content/template.js | 3 + common/content/ui.js | 2 + common/content/util.js | 2 + 17 files changed, 285 insertions(+), 85 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 0843ecb6..81b75a68 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -26,8 +26,16 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + const Point = new Struct("x", "y"); +/** + * A class to manage the primary web content buffer. The name comes + * from vim's term, 'buffer', which signifies instances of open + * files. + * @instance buffer + */ function Buffer() //{{{ { //////////////////////////////////////////////////////////////////////////////// @@ -809,6 +817,10 @@ function Buffer() //{{{ return { + /** + * The alternative stylesheets for the current buffer. Only + * returns stylesheets for the 'screen' media type. + */ get alternateStyleSheets() { let stylesheets = window.getAllStyleSheets(window.content); @@ -818,9 +830,18 @@ function Buffer() //{{{ ); }, + /** + * @property {Object} A map of page info sections to their + * content generating functions. + */ get pageInfo() pageInfo, - // 0 if loading, 1 if loaded or 2 if load failed + /** + * Returns whether the buffer is loaded. Values may be: + * 0 - Loading. + * 1 - Fully loaded. + * 2 - Load failed. + */ get loaded() { if (window.content.document.pageIsFullyLoaded !== undefined) @@ -833,7 +854,10 @@ function Buffer() //{{{ window.content.document.pageIsFullyLoaded = value; }, - // used to keep track of the right field for "gi" + /** + * The last focused input field in the buffer. Used by the + * "gi" key binding. + */ get lastInputField() { if (window.content.document.lastInputField) @@ -846,6 +870,9 @@ function Buffer() //{{{ window.content.document.lastInputField = value; }, + /** + * The current top-level document's URL. + */ get URL() { return window.content.document.location.href; @@ -856,6 +883,10 @@ function Buffer() //{{{ return window.content.innerHeight; }, + /** + * The current browser's text zoom level, as a percentage with + * 100 as 'normal'. Only affects text size. + */ get textZoom() { return getBrowser().markupDocumentViewer.textZoom * 100; @@ -865,6 +896,11 @@ function Buffer() //{{{ setZoom(value, false); }, + /** + * The current browser's text zoom level, as a percentage with + * 100 as 'normal'. Affects text size, as well as image size + * and block size. + */ get fullZoom() { return getBrowser().markupDocumentViewer.fullZoom * 100; @@ -874,14 +910,37 @@ function Buffer() //{{{ setZoom(value, true); }, + /** + * The current document's title. + */ get title() { return window.content.document.title; }, + /** + * + * @param {string} option The section's value in 'pageinfo'. + * @param {string} title The heading for this section's + * output. + * @param {function} fn The function to generate this + * section's output. + */ addPageInfoSection: addPageInfoSection, - // returns an XPathResult object + /** + * Evaluates an XPath expression in the current or provided + * document. It provides the xhtml and liberator XML + * namespaces. The result may be used as an iterator. + * + * @param {string} expression The XPath expression to evaluate. + * @param {Document} doc The document to evaluate the expression in. + * @default The current document. + * @param {Node} elem The context element. + * @default doc + * @param {boolean} asIterator Whether to return the results as an XPath + * iterator. + */ evaluateXPath: function (expression, doc, elem, asIterator) { if (!doc) @@ -892,15 +951,10 @@ function Buffer() //{{{ let result = doc.evaluate(expression, elem, function lookupNamespaceURI(prefix) { - switch (prefix) - { - case "xhtml": - return "http://www.w3.org/1999/xhtml"; - case "liberator": - return NS.uri; - default: - return null; - } + return { + xhtml: "http://www.w3.org/1999/xhtml", + liberator: NS.uri + }[prefix] || null; }, asIterator ? XPathResult.ORDERED_NODE_ITERATOR_TYPE : XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null @@ -913,9 +967,13 @@ function Buffer() //{{{ return result; }, - // in contrast to vim, returns the selection if one is made, - // otherwise tries to guess the current word under the text cursor - // NOTE: might change the selection + /** + * Returns the currently selected word. If the selection is + * null, it tries to guess the word that the caret is + * positioned in. + * + * NOTE: might change the selection + */ // FIXME: getSelection() doesn't always preserve line endings, see: // https://www.mozdev.org/bugs/show_bug.cgi?id=19303 getCurrentWord: function () @@ -937,8 +995,13 @@ function Buffer() //{{{ return String(selection); }, - // more advanced than a simple elem.focus() as it also works for iframes - // and image maps + /** + * Focuses the given element. In contrast to a simple + * elem.focus() call, this function works for iframes and + * image maps. + * + * @param {Node} elem The element to focus. + */ // TODO: merge with followLink()? focusElement: function (elem) { @@ -963,6 +1026,17 @@ function Buffer() //{{{ elem.dispatchEvent(evt); }, + /** + * Try to guess links the like of "next" and "prev". Though it + * has a singularly horrendous name, it turns out to be quite + * useful. + * + * @param {string} rel The relationship to look for. Looks for + * links with matching @rel or @rev attributes, and, + * failing that, looks for an option named rel + + * "pattern", and finds the last link matching that + * RegExp. + */ followDocumentRelationship: function (rel) { let regexps = options.get(rel + "pattern").values @@ -1019,7 +1093,13 @@ function Buffer() //{{{ liberator.beep(); }, - // artificially "clicks" a link in order to open it + /** + * Fakes a click on a link. + * + * @param {Node} elem The element to click. + * @param {number} where Where to open the link. See + * {@link liberator.open}. + */ followLink: function (elem, where) { let doc = elem.ownerDocument; @@ -1067,6 +1147,9 @@ function Buffer() //{{{ }); }, + /** + * The current document's selection controller. + */ get selectionController() getBrowser().docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) @@ -1091,11 +1174,19 @@ function Buffer() //{{{ } }, + /** + * Scrolls to the bottom of the current buffer. + */ scrollBottom: function () { scrollToPercentiles(-1, 100); }, + /** + * Scrolls the window laterally cols columns. + * + * @param {number} cols The number of columns to scroll. + */ scrollColumns: function (cols) { let win = findScrollableWindow(); @@ -1107,11 +1198,19 @@ function Buffer() //{{{ win.scrollBy(COL_WIDTH * cols, 0); }, + /** + * Scrolls the buffer to its rightmost position. + */ scrollEnd: function () { scrollToPercentiles(100, -1); }, + /** + * Scrolls the buffer vertically lines rows. + * + * @param {number} lines The number of lines to scroll. + */ scrollLines: function (lines) { let win = findScrollableWindow(); @@ -1119,6 +1218,11 @@ function Buffer() //{{{ win.scrollByLines(lines); }, + /** + * Scrolls the buffer vertically pages pages. + * + * @param {number} pages The number of pages to scroll. + */ scrollPages: function (pages) { let win = findScrollableWindow(); @@ -1140,6 +1244,9 @@ function Buffer() //{{{ win.scrollBy(0, win.innerHeight / 2 * direction); }, + /** + * Scrolls the current buffer vertically to percentage + */ scrollToPercentile: function (percentage) { scrollToPercentiles(-1, percentage); @@ -1156,11 +1263,17 @@ function Buffer() //{{{ content.scrollTo(x, y); }, + /** + * Scrolls the current buffer laterally to its leftmost. + */ scrollStart: function () { scrollToPercentiles(0, -1); }, + /** + * Scrolls the current buffer vertically to its top. + */ scrollTop: function () { scrollToPercentiles(-1, 0); @@ -1322,6 +1435,9 @@ function Buffer() //{{{ //}}} }; //}}} +/** + * @instance marks + */ function Marks() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/commands.js b/common/content/commands.js index 7486d344..d357918d 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // Do NOT create instances of this class yourself, use the helper method // commands.add() instead function Command(specs, description, action, extraInfo) //{{{ @@ -147,6 +149,9 @@ Command.prototype = { }; //}}} +/** + * @instance commands + */ function Commands() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/completion.js b/common/content/completion.js index f9ddee03..2c119f95 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + /** * Creates a new completion context. * @@ -647,6 +649,9 @@ CompletionContext.prototype = { } }; //}}} +/** + * @instance completion + */ function Completion() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/editor.js b/common/content/editor.js index 6219a4ea..5c9ffedb 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -26,9 +26,14 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // command names taken from: // http://developer.mozilla.org/en/docs/Editor_Embedding_Guide +/** + * @instance editor + */ function Editor() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/events.js b/common/content/events.js index c477cb80..3009eee6 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -26,6 +26,11 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + +/** + * @instance autocommands + */ function AutoCommands() //{{{ { //////////////////////////////////////////////////////////////////////////////// @@ -277,6 +282,9 @@ function AutoCommands() //{{{ //}}} }; //}}} +/** + * @instance events + */ function Events() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/find.js b/common/content/find.js index 923426f5..72c77388 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // TODO: proper backwards search - implement our own component? // : implement our own highlighter? // : frameset pages @@ -37,6 +39,9 @@ the terms of any one of the MPL, the GPL or the LGPL. // : incremental searches shouldn't permanently update search modifiers // make sure you only create this object when the "liberator" object is ready +/** + * @instance search + */ function Search() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/hints.js b/common/content/hints.js index 90c7e14f..38f36436 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -26,6 +26,11 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + +/** + * @instance hints + */ function Hints() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/io.js b/common/content/io.js index 136b2b13..ba62b137 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -27,6 +27,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + plugins.contexts = {}; function Script(file) { @@ -52,6 +54,9 @@ function Script(file) Script.prototype = plugins; // TODO: why are we passing around strings rather than file objects? +/** + * @instance io + */ function IO() //{{{ { //////////////////////////////////////////////////////////////////////////////// @@ -838,7 +843,7 @@ lookup: } else if (/\.css$/.test(filename)) { - storage.styles.registerSheet(uri.spec, !silent, true); + storage.styles.registerSheet(uri.spec, true); } else { diff --git a/common/content/liberator.js b/common/content/liberator.js index e5c8cfa8..015adf07 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + const Cc = Components.classes; const Ci = Components.interfaces; const Cr = Components.results; diff --git a/common/content/mappings.js b/common/content/mappings.js index 7e35b115..d409ba79 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // Do NOT create instances of this class yourself, use the helper method // mappings.add() instead function Map(modes, cmds, description, action, extraInfo) //{{{ @@ -76,6 +78,9 @@ Map.prototype = { }; //}}} +/** + * @instance mappings + */ function Mappings() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/modes.js b/common/content/modes.js index 0159dd24..e79a67f4 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + const modes = (function () //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/options.js b/common/content/options.js index 6373dcb6..a1844a5f 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // do NOT create instances of this class yourself, use the helper method // options.add() instead function Option(names, description, type, defaultValue, extraInfo) //{{{ @@ -293,6 +295,9 @@ Option.validateCompleter = function (values) function (value) res.some(function (item) item[0] == value)); }; //}}} +/** + * @instance options + */ function Options() //{{{ { //////////////////////////////////////////////////////////////////////////////// diff --git a/common/content/style.js b/common/content/style.js index 62c14ef2..d2ef4d57 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -6,6 +6,19 @@ it under any or all of those licenseses. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + +/** + * @constant + * @property {string} The default highlighting rules. They have the + * form: + * rule ::= selector space css + * selector ::= group + * | group "," css-selector + * | group "," css-selector "," scope + * group ::= groupname + * | groupname css-selector + */ // Highlights.prototype.CSS = .toString(); +/** + * A class to manage highlighting rules. The parameters are the + * standard paramaters for any {@link Storage} object. + * + * @author Kris Maglione + */ function Highlights(name, store, serial) { var self = this; @@ -161,25 +180,35 @@ function Highlights(name, store, serial) .replace(";!important;", ";", "g"); // Seeming Spidermonkey bug css = style.selector + " { " + css + " }"; - let error = styles.addSheet(style.selector, style.filter, css, true, force); + let error = styles.addSheet(style.selector, style.filter, css, true); if (error) return error; style.value = newStyle; highlight[style.class] = style; }; + /** + * Gets a CSS selector given a highlight group. + */ this.selector = function (class) { let [, hl, rest] = class.match(/^(\w*)(.*)/); return "[liberator|highlight~=" + hl + "]" + rest }; + /** + * Clears all highlighting rules. Rules with default values are + * reset. + */ this.clear = function () { for (let [k, v] in Iterator(highlight)) this.set(k, null, true); }; + /** + * Reloads the values in {@link #CSS}. + */ this.reload = function () { this.CSS.replace(/\{((?:.|\n)*?)\}/g, function (_, _1) _1.replace(/\n\s*/g, " ")) @@ -203,6 +232,13 @@ function Highlights(name, store, serial) }; } +/** + * Manages named and unnamed user stylesheets, which apply to both + * chrome and content pages. The parameters are the standard + * paramaters for any {@link Storage} object. + * + * @author Kris Maglione + */ function Styles(name, store, serial) { /* Can't reference liberator or Components inside Styles -- @@ -233,7 +269,20 @@ function Styles(name, store, serial) this.__defineGetter__("systemNames", function () Iterator(systemNames)); this.__defineGetter__("userNames", function () Iterator(userNames)); - this.addSheet = function (name, filter, css, system, force) + /** + * Add a new stylesheet. + * + * @param {string} name The name given to the stylesheet by + * which it may be later referenced. + * @param {string} filter The sites to which this sheet will + * apply. Can be a domain name or a URL. Any URL ending in + * "*" is matched as a prefix. + * @param {string} css The CSS to be applied. + * @param {boolean} system Declares whether this is a system or + * user sheet. System sheets are used internally by + * @liberator. + */ + this.addSheet = function (name, filter, css, system) { let sheets = system ? systemSheets : userSheets; let names = system ? systemNames : userNames; @@ -249,7 +298,7 @@ function Styles(name, store, serial) sheet.ref = []; try { - this.registerSheet(cssUri(wrapCSS(sheet)), !force); + this.registerSheet(cssUri(wrapCSS(sheet))); this.registerAgentSheet(cssUri(wrapCSS(sheet))) } catch (e) @@ -266,6 +315,10 @@ function Styles(name, store, serial) return null; }; + /** + * Find sheets matching the parameters. See {@link #addSheet} + * for parameters. + */ this.findSheets = function (name, filter, css, index, system) { let sheets = system ? systemSheets : userSheets; @@ -284,6 +337,12 @@ function Styles(name, store, serial) return matches.map(function (i) sheets[i]); }; + /** + * Remove a stylesheet. See {@link #addSheet} for parameters. + * In cases where filter is supplied, the given filters + * are removed from matching sheets. If any remain, the sheet is + * left in place. + */ this.removeSheet = function (name, filter, css, index, system) { let self = this; @@ -326,11 +385,15 @@ function Styles(name, store, serial) return matches.length; }; - this.registerSheet = function (uri, doCheckSyntax, reload) + /** + * Register a user stylesheet at the given URI. + * + * @param {string} uri The UrI of the sheet to register. + * @param {boolean} reload Whether to reload any sheets that are + * already registered. + */ + this.registerSheet = function (uri, reload) { - //dump (uri + "\n\n"); - if (doCheckSyntax) - checkSyntax(uri); if (reload) this.unregisterSheet(uri); uri = ios.newURI(uri, null, null); @@ -338,6 +401,9 @@ function Styles(name, store, serial) sss.loadAndRegisterSheet(uri, sss.USER_SHEET); }; + /** + * Unregister a sheet at the given URI. + */ this.unregisterSheet = function (uri) { uri = ios.newURI(uri, null, null); @@ -346,6 +412,10 @@ function Styles(name, store, serial) }; // FIXME + /** + * Register an agent stylesheet. + * @deprecated + */ this.registerAgentSheet = function (uri) { this.unregisterAgentSheet(uri); @@ -353,6 +423,10 @@ function Styles(name, store, serial) sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET); }; + /** + * Unregister an agent stylesheet. + * @deprecated + */ this.unregisterAgentSheet = function (uri) { uri = ios.newURI(uri, null, null); @@ -373,65 +447,6 @@ function Styles(name, store, serial) .join(", "); return namespace + "@-moz-document " + selectors + "{\n" + css + "\n}\n"; } - - let queryinterface = XPCOMUtils.generateQI([Ci.nsIConsoleListener]); - /* What happens if more than one thread tries to use this? */ - let testDoc = document.implementation.createDocument(XHTML, "doc", null); - function checkSyntax(uri) - { - let errors = []; - let listener = { - QueryInterface: queryinterface, - observe: function (message) - { - try - { - message = message.QueryInterface(Ci.nsIScriptError); - if (message.sourceName == uri) - errors.push(message); - } - catch (e) {} - } - }; - - try - { - consoleService.registerListener(listener); - if (testDoc.documentElement.firstChild) - testDoc.documentElement.removeChild(testDoc.documentElement.firstChild); - testDoc.documentElement.appendChild(util.xmlToDom( - , testDoc)); - - while (true) - { - try - { - // Throws NS_ERROR_DOM_INVALID_ACCESS_ERR if not finished loading - testDoc.styleSheets[0].cssRules.length; - break; - } - catch (e) - { - if (e.name != "NS_ERROR_DOM_INVALID_ACCESS_ERR") - return [e.toString()]; - sleep(10); - } - } - } - finally - { - consoleService.unregisterListener(listener); - } - if (errors.length) - { - let err = new Error("", errors[0].sourceName.replace(/^(chrome-data:text\/css,).*/, "$1..."), errors[0].lineNumber); - err.name = "CSSError"; - err.message = errors.reduce(function (msg, e) msg + "; " + e.lineNumber + ": " + e.errorMessage, - errors.shift().errorMessage); - err.echoerr = err.fileName + ":" + err.lineNumber + ": " + err.message; - throw err; - } - } } let (array = util.Array) { @@ -440,8 +455,16 @@ let (array = util.Array) }; } +/** + * @property {Styles} + */ const styles = storage.newObject("styles", Styles, false); + +/** + * @property {Highlights} + */ const highlight = storage.newObject("highlight", Highlights, false); + highlight.CSS = Highlights.prototype.CSS; highlight.reload(); diff --git a/common/content/tabs.js b/common/content/tabs.js index 4e8512f2..fd3c6a24 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + // TODO: many methods do not work with Thunderbird correctly yet function Tabs() //{{{ diff --git a/common/content/template.js b/common/content/template.js index 7b937537..0f7a08a3 100644 --- a/common/content/template.js +++ b/common/content/template.js @@ -1,3 +1,6 @@ + +/** @scope modules */ + const template = { add: function add(a, b) a + b, join: function join(c) function (a, b) a + c + b, diff --git a/common/content/ui.js b/common/content/ui.js index 56fd1852..f046cce6 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + /* * This class is used for prompting of user input and echoing of messages * diff --git a/common/content/util.js b/common/content/util.js index d6499e57..3d3995f4 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -26,6 +26,8 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ +/** @scope modules */ + const XHTML = "http://www.w3.org/1999/xhtml"; const NS = Namespace("liberator", "http://vimperator.org/namespaces/liberator"); default xml namespace = XHTML; From c51e3e4707e7c9065817fef5ccf42fff247516c8 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 14:57:34 -0500 Subject: [PATCH 28/41] Make sure that the hint number is in the viewport --- common/content/events.js | 81 ++++++++++++++++++++-------------------- common/content/hints.js | 4 +- common/content/util.js | 9 +++++ 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 3009eee6..c1432bbe 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1201,52 +1201,51 @@ function Events() //{{{ // global escape handler, is called in ALL modes onEscape: function () { - if (!modes.passNextKey) + if (modes.passNextKey) + return; + if (modes.passAllKeys) { - if (modes.passAllKeys) - { - modes.passAllKeys = false; - return; - } + modes.passAllKeys = false; + return; + } - switch (liberator.mode) - { - case modes.NORMAL: - // clear any selection made - let selection = window.content.getSelection(); - try - { // a simple if (selection) does not seem to work - selection.collapseToStart(); - } - catch (e) {} + switch (liberator.mode) + { + case modes.NORMAL: + // clear any selection made + let selection = window.content.getSelection(); + try + { // a simple if (selection) does not seem to work + selection.collapseToStart(); + } + catch (e) {} + modes.reset(); + break; + + case modes.VISUAL: + if (modes.extended & modes.TEXTAREA) + liberator.mode = modes.TEXTAREA; + else if (modes.extended & modes.CARET) + liberator.mode = modes.CARET; + break; + + case modes.CARET: + // setting this option will trigger an observer which will + // care about all other details like setting the NORMAL mode + options.setPref("accessibility.browsewithcaret", false); + break; + + case modes.INSERT: + if ((modes.extended & modes.TEXTAREA) && !options["insertmode"]) + liberator.mode = modes.TEXTAREA; + else modes.reset(); - break; + break; - case modes.VISUAL: - if (modes.extended & modes.TEXTAREA) - liberator.mode = modes.TEXTAREA; - else if (modes.extended & modes.CARET) - liberator.mode = modes.CARET; - break; - - case modes.CARET: - // setting this option will trigger an observer which will - // care about all other details like setting the NORMAL mode - options.setPref("accessibility.browsewithcaret", false); - break; - - case modes.INSERT: - if ((modes.extended & modes.TEXTAREA) && !options["insertmode"]) - liberator.mode = modes.TEXTAREA; - else - modes.reset(); - break; - - default: // HINTS, CUSTOM or COMMAND_LINE - modes.reset(); - break; - } + default: // HINTS, CUSTOM or COMMAND_LINE + modes.reset(); + break; } }, diff --git a/common/content/hints.js b/common/content/hints.js index 38f36436..511e1894 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -154,8 +154,8 @@ function Hints() //{{{ text = elem.textContent.toLowerCase(); span = baseNodeAbsolute.cloneNode(true); - span.style.left = (rect.left + scrollX) + "px"; - span.style.top = (rect.top + scrollY) + "px"; + span.style.left = Math.max((rect.left + scrollX), scrollX) + "px"; + span.style.top = Math.max((rect.top + scrollY), scrollY) + "px"; fragment.appendChild(span); pageHints.push([elem, text, span, null, elem.style.backgroundColor, elem.style.color]); diff --git a/common/content/util.js b/common/content/util.js index 3d3995f4..cf5bdcb3 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -311,6 +311,15 @@ const util = { //{{{ identity: function identity(k) k, + intersection: function (r1, r2) ({ + get width() this.right - this.left, + get height() this.bottom - this.top, + left: Math.max(r1.left, r2.left), + right: Math.min(r1.right, r2.right), + top: Math.max(r1.top, r2.top), + bottom: Math.min(r1.bottom, r2.bottom) + }), + map: function map(obj, fn) { let ary = []; From 20265324bcf50bfc2983fc093703753e59e22c6a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 15:00:52 -0500 Subject: [PATCH 29/41] Fix ;f --- common/content/hints.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/content/hints.js b/common/content/hints.js index 511e1894..283e153b 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -66,7 +66,7 @@ function Hints() //{{{ const hintModes = { ";": Mode("Focus hint", function (elem) buffer.focusElement(elem), extended), a: Mode("Save hint with prompt", function (elem) buffer.saveLink(elem, false)), - f: Mode("Focus frame", function (elem) elem.ownerDocument.defaultView.focus(), function () "//body | //html|body"), + f: Mode("Focus frame", function (elem) elem.ownerDocument.defaultView.focus(), function () "//body | //xhtml:body"), s: Mode("Save hint", function (elem) buffer.saveLink(elem, true)), o: Mode("Follow hint", function (elem) buffer.followLink(elem, liberator.CURRENT_TAB)), t: Mode("Follow hint in a new tab", function (elem) buffer.followLink(elem, liberator.NEW_TAB)), From 2c6015837f218bec1b9c41e0e780488f9d8314e6 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 19 Dec 2008 15:12:38 -0500 Subject: [PATCH 30/41] Fix g<, sort-of. Fix some commandline.echo quirks, as well. --- common/content/ui.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/content/ui.js b/common/content/ui.js index f046cce6..bd5a8dfa 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -568,10 +568,10 @@ function CommandLine() //{{{ * after interpolated data. */ XML.ignoreWhitespace = typeof str != "xml"; - let output = util.xmlToDom(
{template.maybeXML(str)}
, doc); + lastMowOutput =
{template.maybeXML(str)}
; + let output = util.xmlToDom(lastMowOutput, doc); XML.ignoreWhitespace = true; - lastMowOutput = output; // FIXME: need to make sure an open MOW is closed when commands // that don't generate output are executed @@ -778,8 +778,7 @@ function CommandLine() //{{{ function () { if (lastMowOutput) - commandline.echo(lastMowOutput, - commandline.HL_NORMAL, commandline.FORCE_MULTILINE); + echoMultiline(lastMowOutput, commandline.HL_NORMAL); else liberator.beep(); }); @@ -997,7 +996,10 @@ function CommandLine() //{{{ let action = echoLine; if (!single && (!outputContainer.collapsed || messageBox.value == lastEcho)) + { + highlightGroup += " Message"; action = echoMultiline; + } if ((flags & this.FORCE_MULTILINE) || (/\n/.test(str) || typeof str == "xml") && !(flags & this.FORCE_SINGLELINE)) action = echoMultiline; From 313136a1f8ad8066ea5261e2baf12d7334b9d09d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 24 Dec 2008 13:22:54 -0500 Subject: [PATCH 31/41] Cleanup io.js with relation to path separators --- common/content/completion.js | 2 +- common/content/io.js | 33 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/common/content/completion.js b/common/content/completion.js index 60dc0af6..34ed8c5c 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1393,7 +1393,7 @@ function Completion() //{{{ // TODO: use path for the description? io.getRuntimeDirectories("colors").forEach(function (dir) { context.fork(dir.path, 0, null, function (context) { - context.filter = dir.path + io.pathSeparator + context.filter; + context.filter = dir.path + IO.PATH_SEP + context.filter; completion.file(context); context.title = ["Color Scheme"]; context.quote = ["", function (text) text.replace(/\.vimp$/, ""), ""]; diff --git a/common/content/io.js b/common/content/io.js index de7eb73e..8a5ea056 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -104,12 +104,7 @@ function IO() //{{{ .map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir); } - function replacePathSep(path) - { - if (WINDOWS) - return path.replace("/", "\\"); - return path; - } + function replacePathSep(path) path.replace("/", IO.PATH_SEP, "g"); function joinPaths(head, tail) { @@ -272,7 +267,7 @@ function IO() //{{{ function (args) { // TODO: "E172: Only one file name allowed" - let filename = args[0] || "~/" + (WINDOWS ? "_" : ".") + EXTENSION_NAME + "rc"; + let filename = args[0] || io.getRCFile(null, true).path; let file = io.getFile(filename); if (file.exists() && !args.bang) @@ -404,8 +399,6 @@ function IO() //{{{ sourcing: null, - pathSeparator: WINDOWS ? "\\" : "/", - expandPath: IO.expandPath, // TODO: there seems to be no way, short of a new component, to change @@ -456,7 +449,7 @@ function IO() //{{{ return dirs; }, - getRCFile: function (dir) + getRCFile: function (dir, always) { dir = dir || "~"; @@ -470,8 +463,9 @@ function IO() //{{{ return rcFile1; else if (rcFile2.exists() && rcFile2.isFile()) return rcFile2; - else - return null; + else if (always) + return rcFile1; + return null; }, // return a nsILocalFile for path where you can call isDirectory(), etc. on @@ -921,15 +915,19 @@ lookup: }; //}}} -IO.__defineGetter__("runtimePath", function () service["environment"].get(config.name.toUpperCase() + "_RUNTIME") || +IO.PATH_SEP = (function () { + let file = services.create("file"); + file.append("foo"); + return file.path[0]; +})(); + +IO.__defineGetter__("runtimePath", function () services.get("environment").get(config.name.toUpperCase() + "_RUNTIME") || "~/" + (liberator.has("Win32") ? "" : ".") + config.name.toLowerCase()); IO.expandPath = function (path, relative) { // TODO: proper pathname separator translation like Vim - this should be done elsewhere const WINDOWS = liberator.has("Win32"); - if (WINDOWS) - path = path.replace("/", "\\", "g"); // expand any $ENV vars - this is naive but so is Vim and we like to be compatible // TODO: Vim does not expand variables set to an empty string (and documents it). @@ -959,10 +957,7 @@ IO.expandPath = function (path, relative) // TODO: Vim expands paths twice, once before checking for ~, once // after, but doesn't document it. Is this just a bug? --Kris path = expand(path); - - // FIXME: Should we be doing this here? I think it should be done - // by the arg parser or nowhere. --Kris - return path.replace("\\ ", " ", "g"); + return path.replace("/", IO.PATH_SEP, "g"); }; // vim: set fdm=marker sw=4 ts=4 et: From 91d824b4a60747bfff7afc9bd9063034a27a7014 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 24 Dec 2008 14:21:20 -0500 Subject: [PATCH 32/41] Fix io.js --- common/content/io.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/content/io.js b/common/content/io.js index 02e17856..b87e1e6f 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -941,7 +941,8 @@ IO.expandPath = function (path, relative) path = expand(path); // expand ~ - if (!relative && (WINDOWS ? /^~(?:$|[\\\/])/ : /^~(?:$|\/)/).test(path)) + // Yuck. + if (!relative && RegExp("~(?:$|[/" + util.escapeRegex(IO.PATH_SEP) + "])").test(path)) { // Try $HOME first, on all systems let home = services.get("environment").get("HOME"); From d9b07c2ff6dde17ad17a66d2e5772ce8a3f9ca5e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 15 Jan 2009 18:03:04 +1100 Subject: [PATCH 33/41] Set MY_VIMPERATORRC when sourcing the RC file on startup. --- common/content/liberator.js | 11 ++++++++--- vimperator/NEWS | 2 +- vimperator/locale/en-US/starting.txt | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/common/content/liberator.js b/common/content/liberator.js index dd5d396c..864472f0 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -1284,11 +1284,13 @@ const liberator = (function () //{{{ // TODO: we should have some class where all this guioptions stuff fits well hideGUI(); - // finally, read a ~/.vimperatorrc and plugin/**.{vimp,js} + // finally, read the RC file and source plugins // make sourcing asynchronous, otherwise commands that open new tabs won't work setTimeout(function () { - let init = services.get("environment").get(config.name.toUpperCase() + "_INIT"); + let extensionName = config.name.toUpperCase(); + let init = services.get("environment").get(extensionName + "_INIT"); + if (init) liberator.execute(init); else @@ -1296,7 +1298,10 @@ const liberator = (function () //{{{ let rcFile = io.getRCFile("~"); if (rcFile) + { io.source(rcFile.path, true); + services.get("environment").set("MY_" + extensionName + "RC", rcFile.path); + } else liberator.log("No user RC file found", 3); } @@ -1313,7 +1318,7 @@ const liberator = (function () //{{{ // after sourcing the initialization files, this function will set // all gui options to their default values, if they have not been - // set before by any rc file + // set before by any RC file for (let option in options) { if (option.setter) diff --git a/vimperator/NEWS b/vimperator/NEWS index dc72df66..200d56e0 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -22,7 +22,7 @@ * IMPORTANT: $VIMPERATOR_HOME is no longer used. * Added ~/.vimperator/info/{profile}/, similar to viminfo - * added $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT + * add $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT and $MY_VIMPERATORRC * :hardcopy now supports output redirection to a file on Unix and MacUnix * add ";f" extended hint mode to focus a frame * add "r", "l", and "b" to 'guioptions' to toggle the scrollbars. diff --git a/vimperator/locale/en-US/starting.txt b/vimperator/locale/en-US/starting.txt index 0e6d060d..5bbe7b97 100644 --- a/vimperator/locale/en-US/starting.txt +++ b/vimperator/locale/en-US/starting.txt @@ -14,8 +14,9 @@ At startup, Vimperator completes the following tasks in order. .. |$VIMPERATOR_INIT| _$VIMPERATOR_INIT_ -- May contain a single ex command (e.g., "[c]:source {file}[c]"). - .. [a]\~/_vimperatorrc[a] -- Windows only. If this file exists, its - contents are executed. + .. [a]\~/_vimperatorrc[a] -- Windows only. If this file exists, its + contents are executed and + _$MY_VIMPERATORRC_ set to its path. .. [a]\~/.vimperatorrc[a] -- If this file exists, its contents are executed. From 5e811785c2f816c6c04f838cc86f9892d17bb60e Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 15 Jan 2009 22:33:53 +1100 Subject: [PATCH 34/41] Mention the new :silent command in NEWS. --- vimperator/NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vimperator/NEWS b/vimperator/NEWS index 200d56e0..2ddc16d3 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -21,7 +21,8 @@ * IMPORTANT: 'verbose' is now by default at 1, set to 0 to not show any status messages * IMPORTANT: $VIMPERATOR_HOME is no longer used. - * Added ~/.vimperator/info/{profile}/, similar to viminfo + * add :silent + * add ~/.vimperator/info/{profile}/, similar to viminfo * add $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT and $MY_VIMPERATORRC * :hardcopy now supports output redirection to a file on Unix and MacUnix * add ";f" extended hint mode to focus a frame From 53f33e056143fa49a8909c6f34a10baded102930 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 17 Jan 2009 23:43:29 -0500 Subject: [PATCH 35/41] Allow ` as local mark --- common/content/buffer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index e23d4f9b..5c1631de 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1565,7 +1565,7 @@ function Marks() //{{{ } } - function isLocalMark(mark) /^['"a-z]$/.test(mark); + function isLocalMark(mark) /^['`a-z]$/.test(mark); function isURLMark(mark) /^[A-Z0-9]$/.test(mark); function localMarkIter() From eb4c5488b91b662f438df1acba9539176b404fcd Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 5 Feb 2009 11:51:44 +1100 Subject: [PATCH 36/41] Move the MY_VIMPERATORRC NEWS item to the 2.1 section. --- vimperator/NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vimperator/NEWS b/vimperator/NEWS index 41428e93..65fb3371 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -1,6 +1,7 @@ 2009-XX-XX: * version 2.1 (probably) * add :silent + * add $MY_VIMPERATORRC 2008-XX-XX: * version 2.0 (probably) @@ -27,7 +28,7 @@ * [count] now goes to the [count]th next tab rather than the [count]th tab. * add ~/.vimperator/info/{profile}/, similar to viminfo - * add $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT and $MY_VIMPERATORRC + * add $VIMPERATOR_RUNTIME, $VIMPERATOR_INIT * :hardcopy now supports output redirection to a file on Unix and MacUnix * add ";f" extended hint mode to focus a frame * add "r", "l", and "b" to 'guioptions' to toggle the scrollbars. From 62bc7fb9b56cebbbfc161e5decb330df7f61ef74 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Sat, 28 Feb 2009 22:17:59 +1100 Subject: [PATCH 37/41] Add "w" and "W" Normal mode mappings. These work just like o/O and t/T but for new windows. --- vimperator/NEWS | 2 ++ vimperator/content/config.js | 8 ++++++++ vimperator/locale/en-US/browsing.txt | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/vimperator/NEWS b/vimperator/NEWS index ccda9cde..851be046 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -2,6 +2,8 @@ * version 2.1 (probably) * add :silent * add $MY_VIMPERATORRC + * add ' and " local marks + * add "w" and "W" Normal mode mappings for symmetry with o/O and t/T 2008-XX-XX: * version 2.0 (probably) diff --git a/vimperator/content/config.js b/vimperator/content/config.js index 1a37841a..0e8aa67c 100644 --- a/vimperator/content/config.js +++ b/vimperator/content/config.js @@ -210,6 +210,14 @@ const config = { //{{{ "Open one or more URLs in a new tab, based on current location", function () { commandline.open(":", "tabopen " + buffer.URL, modes.EX); }); + mappings.add([modes.NORMAL], ["w"], + "Open one or more URLs in a new window", + function () { commandline.open(":", "winopen ", modes.EX); }); + + mappings.add([modes.NORMAL], ["W"], + "Open one or more URLs in a new window, based on current location", + function () { commandline.open(":", "winopen " + buffer.URL, modes.EX); }); + mappings.add([modes.NORMAL], [""], "Increment last number in URL", function (count) { incrementURL(count > 1 ? count : 1); }, diff --git a/vimperator/locale/en-US/browsing.txt b/vimperator/locale/en-US/browsing.txt index 9b44fa8a..b8cd0b45 100644 --- a/vimperator/locale/en-US/browsing.txt +++ b/vimperator/locale/en-US/browsing.txt @@ -102,11 +102,20 @@ ________________________________________________________________________________ |:winopen| |:wopen| |:winedit| ||:wino[pen][!] [a][arg1][a], [a][arg2][a], ...|| + +||w|| ________________________________________________________________________________ Just like [c]:tabopen[c] but opens the resulting web page(s) in a new window. ________________________________________________________________________________ +|W| + +||W|| +________________________________________________________________________________ +Open one or more URLs in a new window based on current location. Works like +[m]w[m] but preselects current URL in the [c]:winopen[c] query. +________________________________________________________________________________ + + || |p| + ||p|| ________________________________________________________________________________ From 13da8c45191205627e1ae006aa54d1dc9e7407e0 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 11 Mar 2009 01:02:12 +1100 Subject: [PATCH 38/41] Add new :messclear command to clear the message history. --- common/content/ui.js | 10 ++++++++++ vimperator/NEWS | 1 + vimperator/locale/en-US/index.txt | 1 + vimperator/locale/en-US/message.txt | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/common/content/ui.js b/common/content/ui.js index b358aacd..a79f37e1 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -58,6 +58,11 @@ function CommandLine() //{{{ get length() this._messages.length, + clear: function clear() + { + this._messages = []; + }, + add: function add(message) { if (!message) @@ -975,6 +980,11 @@ function CommandLine() //{{{ }, { argCount: "0" }); + commands.add(["messc[lear]"], + "Clear the message history", + function () { messageHistory.clear(); }, + { argCount: "0" }); + commands.add(["sil[ent]"], "Run a command silently", function (args) diff --git a/vimperator/NEWS b/vimperator/NEWS index 851be046..63124c28 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -4,6 +4,7 @@ * add $MY_VIMPERATORRC * add ' and " local marks * add "w" and "W" Normal mode mappings for symmetry with o/O and t/T + * add :messclear 2008-XX-XX: * version 2.0 (probably) diff --git a/vimperator/locale/en-US/index.txt b/vimperator/locale/en-US/index.txt index 5a6a2fbb..9651529c 100644 --- a/vimperator/locale/en-US/index.txt +++ b/vimperator/locale/en-US/index.txt @@ -203,6 +203,7 @@ section:Ex{nbsp}commands[ex-cmd-index,:index] ||[c]:mark[c]|| Mark current location within the web page + ||[c]:marks[c]|| Show all location marks of current web page + ||[c]:messages[c]|| Display previously given messages + +||[c]:messclear[c]|| Clear the message history + ||[c]:mkvimperatorrc[c]|| Write current key mappings and changed options to the config file + ||[c]:nohlsearch[c]|| Remove the search highlighting + ||[c]:noremap[c]|| Map a key sequence without remapping keys + diff --git a/vimperator/locale/en-US/message.txt b/vimperator/locale/en-US/message.txt index 99c1d723..f7c18f9b 100644 --- a/vimperator/locale/en-US/message.txt +++ b/vimperator/locale/en-US/message.txt @@ -12,6 +12,13 @@ Display previously given messages. ________________________________________________________________________________ +|:messc| |:messclear| + +||:messc[lear]|| +________________________________________________________________________________ +Clear the message history. +________________________________________________________________________________ + + |g<| + ||g<|| ________________________________________________________________________________ From 09c653062c9cc1d170917903e8227d15ef58f5ed Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Sat, 28 Mar 2009 23:10:10 +0100 Subject: [PATCH 39/41] Remove text shadow, should fix tabs on mac os --- common/content/bindings.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/content/bindings.xml b/common/content/bindings.xml index 09693199..d2fd0254 100644 --- a/common/content/bindings.xml +++ b/common/content/bindings.xml @@ -47,11 +47,9 @@ - - From 5ab1771e3c00fa4861d7f933f6efeedd47829880 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Sat, 28 Mar 2009 23:38:33 +0100 Subject: [PATCH 40/41] changed my email address --- License.txt | 2 +- common/content/buffer.js | 2 +- common/content/commands.js | 2 +- common/content/completion.js | 2 +- common/content/editor.js | 2 +- common/content/events.js | 2 +- common/content/find.js | 2 +- common/content/help.css | 2 +- common/content/hints.js | 2 +- common/content/io.js | 2 +- common/content/liberator.js | 2 +- common/content/liberator.xul | 2 +- common/content/mappings.js | 2 +- common/content/modes.js | 2 +- common/content/options.js | 2 +- common/content/tabs.js | 2 +- common/content/template.js | 2 +- common/content/ui.js | 2 +- common/content/util.js | 2 +- common/skin/liberator.css | 2 +- muttator/AUTHORS | 2 +- muttator/License.txt | 2 +- muttator/content/compose/compose.xul | 2 +- muttator/content/compose/liberator.xul | 120 ++++++++++++++++++++++++- muttator/content/config.js | 2 +- muttator/content/mail.js | 2 +- muttator/content/muttator.xul | 2 +- muttator/locale/en-US/asciidoc.conf | 2 +- muttator/locale/en-US/intro.txt | 2 +- vimperator/AUTHORS | 2 +- vimperator/Makefile | 2 +- vimperator/content/bookmarks.js | 2 +- vimperator/content/config.js | 2 +- vimperator/content/vimperator.xul | 2 +- vimperator/locale/en-US/asciidoc.conf | 2 +- vimperator/locale/en-US/intro.txt | 2 +- 36 files changed, 154 insertions(+), 36 deletions(-) mode change 120000 => 100644 muttator/content/compose/liberator.xul diff --git a/License.txt b/License.txt index 7efdb050..39f969f2 100644 --- a/License.txt +++ b/License.txt @@ -10,7 +10,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/buffer.js b/common/content/buffer.js index a9cb4831..237e2930 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/commands.js b/common/content/commands.js index d6417a23..6cc8ab97 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/completion.js b/common/content/completion.js index 5c8e9d2d..16e1d1a4 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/editor.js b/common/content/editor.js index 59d1c9dd..073e88cf 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/events.js b/common/content/events.js index 51d1ecb8..8d5dfe29 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/find.js b/common/content/find.js index 90a73868..89ebcb1f 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/help.css b/common/content/help.css index 67bdba86..c8107467 100644 --- a/common/content/help.css +++ b/common/content/help.css @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/hints.js b/common/content/hints.js index 5e27d0c4..c263ae30 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/io.js b/common/content/io.js index ffebc794..bc0d1a15 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Code based on venkman Alternatively, the contents of this file may be used under the terms of diff --git a/common/content/liberator.js b/common/content/liberator.js index 9c0b2279..188bb145 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/liberator.xul b/common/content/liberator.xul index e7609f52..d26700a7 100644 --- a/common/content/liberator.xul +++ b/common/content/liberator.xul @@ -13,7 +13,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/mappings.js b/common/content/mappings.js index 0f222d64..26864c2b 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/modes.js b/common/content/modes.js index b00ec691..5166e3e8 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/options.js b/common/content/options.js index 1442ce23..fb9bbeae 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/tabs.js b/common/content/tabs.js index 3d44fbcb..d990a346 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/template.js b/common/content/template.js index ea6cf3a1..9f4df824 100644 --- a/common/content/template.js +++ b/common/content/template.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/ui.js b/common/content/ui.js index 56abd03b..4048bcb8 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/content/util.js b/common/content/util.js index 24a167e2..ce1705d4 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/common/skin/liberator.css b/common/skin/liberator.css index 677adbef..c4475f59 100644 --- a/common/skin/liberator.css +++ b/common/skin/liberator.css @@ -11,7 +11,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/muttator/AUTHORS b/muttator/AUTHORS index cdad350d..763ced8e 100644 --- a/muttator/AUTHORS +++ b/muttator/AUTHORS @@ -1,5 +1,5 @@ Main developer/Project founder: - * Martin Stubenschrott (stubenschrott@gmx.net) + * Martin Stubenschrott (stubenschrott@vimperator.org) Developers: * Daniel Bainton (dpb .AT. driftaway .DOT. org) diff --git a/muttator/License.txt b/muttator/License.txt index 7efdb050..39f969f2 100644 --- a/muttator/License.txt +++ b/muttator/License.txt @@ -10,7 +10,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/muttator/content/compose/compose.xul b/muttator/content/compose/compose.xul index f7466a7a..a0db3f57 100644 --- a/muttator/content/compose/compose.xul +++ b/muttator/content/compose/compose.xul @@ -13,7 +13,7 @@ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. -Copyright (c) 2006-2009 by Martin Stubenschrott +Copyright (c) 2006-2009 by Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/muttator/content/compose/liberator.xul b/muttator/content/compose/liberator.xul deleted file mode 120000 index e6fca064..00000000 --- a/muttator/content/compose/liberator.xul +++ /dev/null @@ -1 +0,0 @@ -../../../common/content/liberator.xul \ No newline at end of file diff --git a/muttator/content/compose/liberator.xul b/muttator/content/compose/liberator.xul new file mode 100644 index 00000000..d26700a7 --- /dev/null +++ b/muttator/content/compose/liberator.xul @@ -0,0 +1,119 @@ + + + + + + +]> + + + +