Skip to content

Commit 82693cd

Browse files
committed
new API option doubleTab #405
1 parent 2de34b1 commit 82693cd

6 files changed

+84
-32
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* $.jrpc helper now return its own created promise instead of $.ajax
77
* add wcwidth as dependency so it will always show wider characters correctly (in browsers will work the same as optional)
88
* expose terminal exception in $.terminal namespace
9+
* new API option doubleTab [#405](https://github.com/jcubic/jquery.terminal/issues/405)
910

1011
### Bugfix
1112
* disable history in read & login (regression from 1.16.0 history interpreter option)

js/jquery.terminal-1.16.1.js

+27-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
3333
* licensed under 3 clause BSD license
3434
*
35-
* Date: Sat, 23 Jun 2018 13:24:23 +0000
35+
* Date: Sat, 23 Jun 2018 13:48:22 +0000
3636
*/
3737

3838
/* TODO:
@@ -2993,7 +2993,7 @@
29932993
// -------------------------------------------------------------------------
29942994
$.terminal = {
29952995
version: 'DEV',
2996-
date: 'Sat, 23 Jun 2018 13:24:23 +0000',
2996+
date: 'Sat, 23 Jun 2018 13:48:22 +0000',
29972997
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
29982998
color_names: [
29992999
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -4144,6 +4144,7 @@
41444144
response: $.noop,
41454145
describe: 'procs',
41464146
onRPCError: null,
4147+
doubleTab: null,
41474148
completion: false,
41484149
onInit: $.noop,
41494150
onClear: $.noop,
@@ -5492,7 +5493,8 @@
54925493
echo: true,
54935494
word: settings.wordAutocomplete,
54945495
escape: settings.completionEscape,
5495-
caseSensitive: caseSensitive
5496+
caseSensitive: caseSensitive,
5497+
doubleTab: settings.doubleTab
54965498
});
54975499
}
54985500
if (completion) {
@@ -5978,7 +5980,8 @@
59785980
word: true,
59795981
echo: false,
59805982
escape: true,
5981-
caseSensitive: true
5983+
caseSensitive: true,
5984+
doubleTab: null
59825985
}, options || {});
59835986
var sensitive = options.caseSensitive;
59845987
// cursor can be in the middle of the command
@@ -6070,12 +6073,26 @@
60706073
if (++tab_count >= 2) {
60716074
tab_count = 0;
60726075
if (options.echo) {
6073-
echo_command();
6074-
var text = matched.reverse().join('\t');
6075-
self.echo($.terminal.escape_brackets(text), {
6076-
keepWords: true,
6077-
formatters: false
6078-
});
6076+
if (is_function(options.doubleTab)) {
6077+
var ret = options.doubleTab.call(
6078+
self,
6079+
string,
6080+
matched,
6081+
echo_command
6082+
);
6083+
if (typeof ret === 'undefined') {
6084+
return true;
6085+
} else {
6086+
return ret;
6087+
}
6088+
} else {
6089+
echo_command();
6090+
var text = matched.reverse().join('\t');
6091+
self.echo($.terminal.escape_brackets(text), {
6092+
keepWords: true,
6093+
formatters: false
6094+
});
6095+
}
60796096
return true;
60806097
}
60816098
} else {

js/jquery.terminal-1.16.1.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/jquery.terminal-src.js

+25-8
Original file line numberDiff line numberDiff line change
@@ -4144,6 +4144,7 @@
41444144
response: $.noop,
41454145
describe: 'procs',
41464146
onRPCError: null,
4147+
doubleTab: null,
41474148
completion: false,
41484149
onInit: $.noop,
41494150
onClear: $.noop,
@@ -5492,7 +5493,8 @@
54925493
echo: true,
54935494
word: settings.wordAutocomplete,
54945495
escape: settings.completionEscape,
5495-
caseSensitive: caseSensitive
5496+
caseSensitive: caseSensitive,
5497+
doubleTab: settings.doubleTab
54965498
});
54975499
}
54985500
if (completion) {
@@ -5978,7 +5980,8 @@
59785980
word: true,
59795981
echo: false,
59805982
escape: true,
5981-
caseSensitive: true
5983+
caseSensitive: true,
5984+
doubleTab: null
59825985
}, options || {});
59835986
var sensitive = options.caseSensitive;
59845987
// cursor can be in the middle of the command
@@ -6070,12 +6073,26 @@
60706073
if (++tab_count >= 2) {
60716074
tab_count = 0;
60726075
if (options.echo) {
6073-
echo_command();
6074-
var text = matched.reverse().join('\t');
6075-
self.echo($.terminal.escape_brackets(text), {
6076-
keepWords: true,
6077-
formatters: false
6078-
});
6076+
if (is_function(options.doubleTab)) {
6077+
var ret = options.doubleTab.call(
6078+
self,
6079+
string,
6080+
matched,
6081+
echo_command
6082+
);
6083+
if (typeof ret === 'undefined') {
6084+
return true;
6085+
} else {
6086+
return ret;
6087+
}
6088+
} else {
6089+
echo_command();
6090+
var text = matched.reverse().join('\t');
6091+
self.echo($.terminal.escape_brackets(text), {
6092+
keepWords: true,
6093+
formatters: false
6094+
});
6095+
}
60796096
return true;
60806097
}
60816098
} else {

js/jquery.terminal.js

+27-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
3333
* licensed under 3 clause BSD license
3434
*
35-
* Date: Sat, 23 Jun 2018 13:24:23 +0000
35+
* Date: Sat, 23 Jun 2018 13:48:22 +0000
3636
*/
3737

3838
/* TODO:
@@ -2993,7 +2993,7 @@
29932993
// -------------------------------------------------------------------------
29942994
$.terminal = {
29952995
version: 'DEV',
2996-
date: 'Sat, 23 Jun 2018 13:24:23 +0000',
2996+
date: 'Sat, 23 Jun 2018 13:48:22 +0000',
29972997
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
29982998
color_names: [
29992999
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
@@ -4144,6 +4144,7 @@
41444144
response: $.noop,
41454145
describe: 'procs',
41464146
onRPCError: null,
4147+
doubleTab: null,
41474148
completion: false,
41484149
onInit: $.noop,
41494150
onClear: $.noop,
@@ -5492,7 +5493,8 @@
54925493
echo: true,
54935494
word: settings.wordAutocomplete,
54945495
escape: settings.completionEscape,
5495-
caseSensitive: caseSensitive
5496+
caseSensitive: caseSensitive,
5497+
doubleTab: settings.doubleTab
54965498
});
54975499
}
54985500
if (completion) {
@@ -5978,7 +5980,8 @@
59785980
word: true,
59795981
echo: false,
59805982
escape: true,
5981-
caseSensitive: true
5983+
caseSensitive: true,
5984+
doubleTab: null
59825985
}, options || {});
59835986
var sensitive = options.caseSensitive;
59845987
// cursor can be in the middle of the command
@@ -6070,12 +6073,26 @@
60706073
if (++tab_count >= 2) {
60716074
tab_count = 0;
60726075
if (options.echo) {
6073-
echo_command();
6074-
var text = matched.reverse().join('\t');
6075-
self.echo($.terminal.escape_brackets(text), {
6076-
keepWords: true,
6077-
formatters: false
6078-
});
6076+
if (is_function(options.doubleTab)) {
6077+
var ret = options.doubleTab.call(
6078+
self,
6079+
string,
6080+
matched,
6081+
echo_command
6082+
);
6083+
if (typeof ret === 'undefined') {
6084+
return true;
6085+
} else {
6086+
return ret;
6087+
}
6088+
} else {
6089+
echo_command();
6090+
var text = matched.reverse().join('\t');
6091+
self.echo($.terminal.escape_brackets(text), {
6092+
keepWords: true,
6093+
formatters: false
6094+
});
6095+
}
60796096
return true;
60806097
}
60816098
} else {

js/jquery.terminal.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)