diff options
author | Doug Kearns <dougkearns@gmail.com> | 2009-03-29 12:34:05 +1100 |
---|---|---|
committer | Doug Kearns <dougkearns@gmail.com> | 2009-03-29 12:34:05 +1100 |
commit | 3b667419f81866219dc902e55d2e25865c839c0e (patch) | |
tree | 8117e123c586c305f2bf5160f1b83ab1b07f976c /common/content | |
parent | a5c8ebcc5520a3c2ad1ccaf05df462e247917881 (diff) | |
parent | 374297c5da4379fb0058dde4cf47c7c0a4797100 (diff) | |
download | pentadactyl-3b667419f81866219dc902e55d2e25865c839c0e.tar.gz |
Merge branch 'master' into xulmus
Conflicts:
License.txt
Diffstat (limited to 'common/content')
-rw-r--r-- | common/content/bindings.xml | 2 | ||||
-rw-r--r-- | common/content/buffer.js | 36 | ||||
-rw-r--r-- | common/content/commands.js | 2 | ||||
-rw-r--r-- | common/content/completion.js | 2 | ||||
-rw-r--r-- | common/content/editor.js | 2 | ||||
-rw-r--r-- | common/content/events.js | 2 | ||||
-rw-r--r-- | common/content/find.js | 2 | ||||
-rw-r--r-- | common/content/help.css | 2 | ||||
-rw-r--r-- | common/content/hints.js | 2 | ||||
-rw-r--r-- | common/content/io.js | 42 | ||||
-rw-r--r-- | common/content/liberator.js | 12 | ||||
-rw-r--r-- | common/content/liberator.xul | 2 | ||||
-rw-r--r-- | common/content/mappings.js | 2 | ||||
-rw-r--r-- | common/content/modes.js | 2 | ||||
-rw-r--r-- | common/content/options.js | 2 | ||||
-rw-r--r-- | common/content/tabs.js | 2 | ||||
-rw-r--r-- | common/content/template.js | 2 | ||||
-rw-r--r-- | common/content/ui.js | 23 | ||||
-rw-r--r-- | common/content/util.js | 2 |
19 files changed, 87 insertions, 56 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 @@ </xul:vbox> </xul:stack> <xul:stack class="tab-text-stack"> - <xul:label xbl:inherits="value=ordinal" class="tab-text-shadow" liberator:highlight="TabNumber"/> <xul:label xbl:inherits="value=ordinal" class="tab-text" liberator:highlight="TabNumber"/> </xul:stack> <xul:stack class="tab-text-stack" flex="1"> - <xul:label flex="1" xbl:inherits="value=label,crop,accesskey" crop="right" class="tab-text-shadow"/> <xul:label flex="1" xbl:inherits="value=label,crop,accesskey" crop="right" class="tab-text"/> </xul:stack> </xul:hbox> diff --git a/common/content/buffer.js b/common/content/buffer.js index a3e460bf..79dc31ec 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 @@ -125,6 +125,7 @@ function Buffer() //{{{ else v = win.scrollMaxY / 100 * vertical; + marks.add("'", true); win.scrollTo(h, v); } @@ -1303,6 +1304,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); + }, + /** * Scrolls the current buffer laterally to its leftmost. */ @@ -1539,12 +1551,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; } @@ -1589,7 +1600,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() @@ -1750,13 +1761,14 @@ function Marks() //{{{ * @param {string} mark */ // 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; } @@ -1767,7 +1779,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)) { @@ -1777,7 +1790,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); } }, @@ -1847,7 +1861,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; } } @@ -1862,7 +1876,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/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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 c5ee7a1a..aa90fd03 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 8d27087e..a50bfec4 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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..130b005b 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> Code based on venkman Alternatively, the contents of this file may be used under the terms of @@ -105,12 +105,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) { @@ -278,7 +273,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) @@ -460,11 +455,6 @@ function IO() //{{{ sourcing: null, /** - * @property {string} The OS's path separator. - */ - pathSeparator: WINDOWS ? "\\" : "/", - - /** * Expands "~" and environment variables in <b>path</b>. * * "~" is expanded to to the value of $HOME. On Windows if this is not @@ -554,10 +544,12 @@ function IO() //{{{ * Returns the first user RC file found in <b>dir</b>. * * @param {string} dir The directory to search. + * @param {boolean} always When true, return a path whether + * the file exists or not. * @default $HOME. * @returns {nsIFile} The RC file or null if none is found. */ - getRCFile: function (dir) + getRCFile: function (dir, always) { dir = dir || "~"; @@ -571,8 +563,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 @@ -1107,6 +1100,12 @@ lookup: }; //}}} +IO.PATH_SEP = (function () { + let file = services.create("file"); + file.append("foo"); + return file.path[0]; +})(); + /** * @property {string} The value of the $VIMPERATOR_RUNTIME environment * variable. @@ -1126,8 +1125,6 @@ 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). @@ -1141,7 +1138,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"); @@ -1157,11 +1155,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); - - if (WINDOWS) - path = path.replace("/", "\\", "g"); - - return path; + return path.replace("/", IO.PATH_SEP, "g"); }; // vim: set fdm=marker sw=4 ts=4 et: diff --git a/common/content/liberator.js b/common/content/liberator.js index ec08975d..4631ce82 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 @@ -1295,11 +1295,12 @@ 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"); let rcFile = io.getRCFile("~"); if (init) @@ -1307,7 +1308,10 @@ const liberator = (function () //{{{ else { 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); } @@ -1324,7 +1328,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/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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 697396bb..c72f40c5 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 0ae21289..25b65b6b 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 0b19514f..81d71fff 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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..fc55d93a 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 @@ -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,22 @@ 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) + { + commandline.runSilently(function () liberator.execute(args[0])); + }, + { + completer: function (context) completion.ex(context), + literal: 0 + }); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ 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 <stubenschrott@gmx.net> +Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> 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 |