mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 14:02:28 +01:00
add completion.environment for environment variable completion
This commit is contained in:
@@ -32,6 +32,8 @@ liberator.Completion = function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
const WINDOWS = navigator.platform == "Win32";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var completionService = Components.classes["@mozilla.org/browser/global-history;2"]
|
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 []?
|
if (get(-2)[CHAR] != "[" // Are we inside of []?
|
||||||
// Yes. If the [ starts at the begining of a logical
|
// Yes. If the [ starts at the begining of a logical
|
||||||
// statement, we're in an array literal, and we're done.
|
// 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, []];
|
return [0, []];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -705,6 +707,21 @@ liberator.Completion = function () //{{{
|
|||||||
|
|
||||||
dialog: function (filter) [0, this.filter(liberator.config.dialogs || [], filter)],
|
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)],
|
event: function (filter) [0, this.filter(liberator.config.autocommands, filter)],
|
||||||
|
|
||||||
// provides completions for ex commands, including their arguments
|
// provides completions for ex commands, including their arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user