Skip to content

Commit

Permalink
Wrap keymap function in terminal only for the ones defined in terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Oct 4, 2017
1 parent 08ac710 commit 2b2b10a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
16 changes: 14 additions & 2 deletions js/jquery.terminal-1.8.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Mon, 02 Oct 2017 18:37:51 +0000
* Date: Wed, 04 Oct 2017 07:07:59 +0000
*/

/* TODO:
Expand Down Expand Up @@ -6489,7 +6489,19 @@
// so we are able to change it using option API method
itrp.completion = 'settings';
}
var new_keymap = $.extend({}, keymap, settings.keymap || {});
var new_keymap = $.extend(
{},
keymap,
$.omap(settings.keymap || {}, function(key, fn) {
if (!keymap[key]) {
return fn;
}
return function(e) {
// new keymap function will get default as 2nd argument
return fn(e, keymap[key]);
};
})
);
interpreters = new Stack($.extend({}, settings.extra, {
name: settings.name,
prompt: settings.prompt,
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-1.8.0.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -6493,6 +6493,9 @@
{},
keymap,
$.omap(settings.keymap || {}, function(key, fn) {
if (!keymap[key]) {
return fn;
}
return function(e) {
// new keymap function will get default as 2nd argument
return fn(e, keymap[key]);
Expand Down
16 changes: 14 additions & 2 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Mon, 02 Oct 2017 18:37:51 +0000
* Date: Wed, 04 Oct 2017 07:07:59 +0000
*/

/* TODO:
Expand Down Expand Up @@ -6489,7 +6489,19 @@
// so we are able to change it using option API method
itrp.completion = 'settings';
}
var new_keymap = $.extend({}, keymap, settings.keymap || {});
var new_keymap = $.extend(
{},
keymap,
$.omap(settings.keymap || {}, function(key, fn) {
if (!keymap[key]) {
return fn;
}
return function(e) {
// new keymap function will get default as 2nd argument
return fn(e, keymap[key]);
};
})
);
interpreters = new Stack($.extend({}, settings.extra, {
name: settings.name,
prompt: settings.prompt,
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

0 comments on commit 2b2b10a

Please sign in to comment.