From e65e5e5f5b78f18c52b53d9007d19f7307c3eda7 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 8 Oct 2008 12:01:08 +0000 Subject: [PATCH] add completion.environment for environment variable completion --- content/completion.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/content/completion.js b/content/completion.js index 9849e5e3..d8cc3666 100644 --- a/content/completion.js +++ b/content/completion.js @@ -32,6 +32,8 @@ liberator.Completion = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + const WINDOWS = navigator.platform == "Win32"; + try { var completionService = Components.classes["@mozilla.org/browser/global-history;2"] @@ -353,7 +355,7 @@ liberator.Completion = function () //{{{ if (get(-2)[CHAR] != "[" // Are we inside of []? // Yes. If the [ starts at the begining of a logical // statement, we're in an array literal, and we're done. - || get(-3, 0, STATEMENTS) == get(-2)[OFFSET]) + || get(-3, 0, STATEMENTS) == get(-2)[OFFSET]) return [0, []]; /* @@ -705,6 +707,21 @@ liberator.Completion = function () //{{{ dialog: function (filter) [0, this.filter(liberator.config.dialogs || [], filter)], + environment: function (filter) + { + let command = WINDOWS ? "set" : "export"; + let lines = liberator.io.system(command).split("\n"); + + lines.splice(lines.length - 1, 1); + + let vars = lines.map(function (line) { + let matches = line.match(/([^=]+)=(.+)/); + return [matches[1], matches[2]]; + }); + + return [0, this.filter(vars, filter)]; + }, + event: function (filter) [0, this.filter(liberator.config.autocommands, filter)], // provides completions for ex commands, including their arguments