aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-06-15 23:58:33 +0200
committerGravatar Tom Willemse2014-06-15 23:58:33 +0200
commitb618a79a48af73fabae222dbec27a10c9a05054e (patch)
treebac0cfcc964dece266de0801f80d89b389859b83
parent6e73d176507a806b1f11bcc1b7f56ea60371f1bd (diff)
downloadcdispass-master.tar.gz
cdispass-master.zip
Update dispass_completer for new completersHEADmaster
Update `dispass_completer' for the latest Conkeror. Conkeror changed the API for the completers somewhat so the completions were broken.
-rw-r--r--cdispass.js67
1 files changed, 36 insertions, 31 deletions
diff --git a/cdispass.js b/cdispass.js
index adb601e..dd82551 100644
--- a/cdispass.js
+++ b/cdispass.js
@@ -53,38 +53,43 @@ function dispass(label, password)
yield co_return(data);
}
-function dispass_complete(input, pos, conservative)
+function dispass_completer()
{
- if (pos == 0 && conservative)
- yield co_return(undefined);
-
- let str = input.substring(0, pos);
-
- var data = "", error = "", ret = [];
- var result = yield shell_command(
- dispass_executable + " list --script",
- $fds = [{ output: async_binary_string_writer("") },
- { input: async_binary_reader(
- function (s) data += s || "" ) },
- { input: async_binary_reader(
- function (s) error += s || "") }]);
-
- if (result != 0 || error != "")
- throw new Error("result: " + result + ", error: " + error);
- else if (data != "") {
- data.split('\n').forEach(function (row) {
- let match = /(^.{50})/.exec(row);
- if (match && (str == "" || match[1].contains(str)))
- ret.push(match[1].trim());
- });
-
- let c = { count: ret.length,
- get_string: function (i) ret[i],
- get_description: function (i) "",
- get_input_state: function (i) [ret[i]] };
- yield co_return(c);
- }
+ keywords(arguments);
+ completer.call(this, forward_keywords(arguments));
}
+dispass_completer.prototype = {
+ constructor: dispass_completer,
+ __proto__: completer.prototype,
+ toString: function () "#<dispass_completer>",
+ complete: function (input, pos) {
+ if (pos == 0)
+ yield co_return(undefined);
+
+ let str = input.substring(0, pos);
+
+ var data = "", error = "", ret = [];
+ var result = yield shell_command(
+ dispass_executable + " list --script",
+ $fds = [{ output: async_binary_string_writer("") },
+ { input: async_binary_reader(
+ function (s) data += s || "" ) },
+ { input: async_binary_reader(
+ function (s) error += s || "") }]);
+
+ if (result != 0 || error != "")
+ throw new Error("result: " + result + ", error: " + error);
+ else if (data != "") {
+ data.split('\n').forEach(function (row) {
+ let match = /(^.{50})/.exec(row);
+ if (match && (str == "" || match[1].contains(str)))
+ ret.push(match[1].trim());
+ });
+
+ yield co_return(new completions(this, ret));
+ }
+ }
+};
function dispass_interactive(with_submit) {
return function (I) {
@@ -95,7 +100,7 @@ function dispass_interactive(with_submit) {
let label = yield I.minibuffer.read(
$prompt="label:", $auto_complete=true,
- $completer=dispass_complete
+ $completer=new dispass_completer()
);
I.minibuffer.input_element.type = "password";