]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/completion.jsm
Import 1.0b7.1 supporting Firefox up to 8.*
[dactyl.git] / common / modules / completion.jsm
index b7a34e54938363c25e27ba0a03db622fe190736a..9671e95aad543f8eadf3a5f6acaaf8498bef26c0 100644 (file)
@@ -11,7 +11,7 @@ try {
 Components.utils.import("resource://dactyl/bootstrap.jsm");
 defineModule("completion", {
     exports: ["CompletionContext", "Completion", "completion"],
-    use: ["config", "template", "util"]
+    use: ["config", "messages", "template", "util"]
 }, this);
 
 /**
@@ -331,16 +331,16 @@ var CompletionContext = Class("CompletionContext", {
      * The message displayed at the head of the completions for the
      * current context.
      */
-    get message() this._message || (this.waitingForTab && this.hasItems !== false ? "Waiting for <Tab>" : null),
+    get message() this._message || (this.waitingForTab && this.hasItems !== false ? _("completion.waitingFor", "<Tab>") : null),
     set message(val) this._message = val,
 
     /**
      * The prototype object for items returned by {@link items}.
      */
     get itemPrototype() {
-        let res = {};
+        let res = { highlight: "" };
         function result(quote) {
-            yield ["result", quote ? function () quote[0] + quote[1](this.text) + quote[2]
+            yield ["result", quote ? function () quote[0] + util.trapErrors(1, quote, this.text) + quote[2]
                                    : function () this.text];
         };
         for (let i in iter(this.keys, result(this.quote))) {
@@ -396,7 +396,7 @@ var CompletionContext = Class("CompletionContext", {
             }
             catch (e) {
                 util.reportError(e);
-                this.message = "Error: " + e;
+                this.message = _("error.error", e);
             }
         }
         // XXX
@@ -495,7 +495,7 @@ var CompletionContext = Class("CompletionContext", {
             return this.cache.filtered = filtered;
         }
         catch (e) {
-            this.message = "Error: " + e;
+            this.message = _("error.error", e);
             util.reportError(e);
             return [];
         }
@@ -903,6 +903,13 @@ var Completion = Module("completion", {
     // depending on the 'complete' option
     // if the 'complete' argument is passed like "h", it temporarily overrides the complete option
     url: function url(context, complete) {
+        if (/^jar:[^!]*$/.test(context.filter)) {
+            context.advance(4);
+
+            context.quote = context.quote || ["", util.identity, ""];
+            let quote = context.quote[1];
+            context.quote[1] = function (str) quote(str.replace(/!/g, escape));
+        }
 
         if (this.options["urlseparator"])
             var skip = util.regexp("^.*" + this.options["urlseparator"] + "\\s*")
@@ -953,7 +960,7 @@ var Completion = Module("completion", {
             context.title = ["URL", "Title"];
 
         context.fork("additional", 0, this, function (context) {
-            context.title[0] += " (additional)";
+            context.title[0] += " " + _("completion.additional");
             context.filter = context.parent.filter; // FIXME
             context.completions = context.parent.completions;
             // For items whose URL doesn't exactly match the filter,
@@ -1037,7 +1044,7 @@ var Completion = Module("completion", {
         };
 
         options.add(["altwildmode", "awim"],
-            "Define the behavior of the <A-Tab> key in command-line completion",
+            "Define the behavior of the c_<A-Tab> key in command-line completion",
             "stringlist", "list:full",
             wildmode);
 
@@ -1066,7 +1073,7 @@ var Completion = Module("completion", {
             });
 
         options.add(["wildmode", "wim"],
-            "Define the behavior of the <Tab> key in command-line completion",
+            "Define the behavior of the c_<Tab> key in command-line completion",
             "stringlist", "list:full",
             wildmode);