mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 18:32:25 +01:00
Add :map <silent>
This commit is contained in:
@@ -851,7 +851,7 @@ function Events() //{{{
|
||||
//
|
||||
// @param keys: a string like "2<C-f>" to pass
|
||||
// if you want < to be taken literally, prepend it with a \\
|
||||
feedkeys: function (keys, noremap)
|
||||
feedkeys: function (keys, noremap, silent)
|
||||
{
|
||||
var doc = window.document;
|
||||
var view = window.document.defaultView;
|
||||
@@ -859,7 +859,12 @@ function Events() //{{{
|
||||
|
||||
var wasFeeding = this.feedingKeys;
|
||||
this.feedingKeys = true;
|
||||
var wasSilent = commandline.silent;
|
||||
if(silent)
|
||||
commandline.silent = silent;
|
||||
|
||||
try
|
||||
{
|
||||
noremap = !!noremap;
|
||||
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
@@ -926,7 +931,13 @@ function Events() //{{{
|
||||
// else // a short break between keys often helps
|
||||
// liberator.sleep(50);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.feedingKeys = wasFeeding;
|
||||
if(silent)
|
||||
commandline.silent = wasSilent;
|
||||
}
|
||||
return i == keys.length;
|
||||
},
|
||||
|
||||
|
||||
@@ -170,14 +170,15 @@ function Mappings() //{{{
|
||||
// 2 args -> map arg1 to arg*
|
||||
function map(args, mode, noremap)
|
||||
{
|
||||
if (!args)
|
||||
if (!args.arguments.length)
|
||||
{
|
||||
mappings.list(mode);
|
||||
return;
|
||||
}
|
||||
|
||||
// ?:\s+ <- don't remember; (...)? optional = rhs
|
||||
var [, lhs, rhs] = args.match(/(\S+)(?:\s+(.+))?/);
|
||||
let [lhs] = args.arguments;
|
||||
let rhs = args.literalArg;
|
||||
|
||||
if (!rhs) // list the mapping
|
||||
{
|
||||
@@ -189,11 +190,11 @@ function Mappings() //{{{
|
||||
{
|
||||
mappings.addUserMap([m], [lhs],
|
||||
"User defined mapping",
|
||||
function (count) { events.feedkeys((count > 1 ? count : "") + rhs, noremap); },
|
||||
function (count) { events.feedkeys((count > 1 ? count : "") + rhs, noremap, "<silent>" in args); },
|
||||
{
|
||||
flags: Mappings.flags.COUNT,
|
||||
rhs: rhs,
|
||||
noremap: noremap
|
||||
noremap: noremap,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -201,10 +202,19 @@ function Mappings() //{{{
|
||||
|
||||
modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
||||
|
||||
const opts = {
|
||||
completer: function (filter) completion.userMapping(filter, modes),
|
||||
options: [
|
||||
[["<silent>", "<Silent>"], commands.OPTION_NOARG]
|
||||
],
|
||||
argCount: 1,
|
||||
literal: true
|
||||
};
|
||||
|
||||
commands.add([ch ? ch + "m[ap]" : "map"],
|
||||
"Map a key sequence" + modeDescription,
|
||||
function (args) { map(args, modes, false); },
|
||||
{ completer: function (filter) completion.userMapping(filter, modes) });
|
||||
opts);
|
||||
|
||||
commands.add([ch + "no[remap]"],
|
||||
"Map a key sequence without remapping keys" + modeDescription,
|
||||
|
||||
@@ -94,6 +94,8 @@ function CommandLine() //{{{
|
||||
};
|
||||
var lastMowOutput = null;
|
||||
|
||||
var silent = false;
|
||||
|
||||
var completionList = new ItemList("liberator-completions");
|
||||
var completions = [];
|
||||
// for the example command "open sometext| othertext" (| is the cursor pos):
|
||||
@@ -108,7 +110,7 @@ function CommandLine() //{{{
|
||||
var statusTimer = new util.Timer(5, 100, function ()
|
||||
statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length));
|
||||
var autocompleteTimer = new util.Timer(201, 300, function (command) {
|
||||
if (modes.isReplaying)
|
||||
if (events.feedingKeys)
|
||||
return;
|
||||
let [start, compl] = completion.ex(command);
|
||||
commandline.setCompletions(compl, start);
|
||||
@@ -549,6 +551,15 @@ function CommandLine() //{{{
|
||||
|
||||
get mode() (modes.extended == modes.EX) ? "cmd" : "search",
|
||||
|
||||
get silent() silent,
|
||||
set silent(val) {
|
||||
silent = val;
|
||||
if(silent)
|
||||
storage.styles.addSheet("silent-mode", "chrome://*", "#liberator-commandline > * { opacity: 0 }", true, true);
|
||||
else
|
||||
storage.styles.removeSheet("silent-mode", null, null, null, true);
|
||||
},
|
||||
|
||||
getCommand: function ()
|
||||
{
|
||||
return commandWidget.value;
|
||||
@@ -717,7 +728,7 @@ function CommandLine() //{{{
|
||||
let mode = currentExtendedMode; // save it here, as setMode() resets it
|
||||
currentExtendedMode = null; /* Don't let modes.pop trigger "cancel" */
|
||||
inputHistory.add(command);
|
||||
modes.pop(true);
|
||||
modes.pop(!commandline.silent);
|
||||
autocompleteTimer.reset();
|
||||
completionList.hide();
|
||||
liberator.focusContent(false);
|
||||
|
||||
Reference in New Issue
Block a user