Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jul 2, 2017
1 parent 40ff336 commit f895202
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 39 deletions.
26 changes: 14 additions & 12 deletions js/jquery.terminal-1.4.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 02 Jul 2017 08:53:06 +0000
* Date: Sun, 02 Jul 2017 09:12:42 +0000
*/

/* TODO:
Expand Down Expand Up @@ -4963,17 +4963,19 @@
matched.push(match);
}
}
var text;
function replace(input, replacement) {
var text = self.get_command();
var pos = self.get_position();
var re = new RegExp(input + '$');
var pre = text.substring(0, pos).replace(re, '');
var post = text.substring(pos);
var to_insert = replacement + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
}
if (matched.length === 1) {
if (options.escape) {
text = self.get_command();
var pos = self.get_position();
var end_re = new RegExp(safe + '$');
var pre = text.substring(0, pos).replace(end_re, '');
var post = text.substring(pos);
var to_insert = matched[0] + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
replace(safe, matched[0]);
} else {
self.insert(matched[0].replace(regex, '') + (quote || ''));
}
Expand All @@ -4984,7 +4986,7 @@
tab_count = 0;
if (options.echo) {
echo_command();
text = matched.reverse().join('\t');
var text = matched.reverse().join('\t');
self.echo($.terminal.escape_brackets(text), {
keepWords: true
});
Expand All @@ -4993,7 +4995,7 @@
} else {
var common = common_string(string, matched);
if (common) {
self.insert(common.replace(regex, ''));
replace(string, common);
command = self.before_cursor(options.word);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-1.4.3.min.js

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -4963,17 +4963,19 @@
matched.push(match);
}
}
var text;
function replace(input, replacement) {
var text = self.get_command();
var pos = self.get_position();
var re = new RegExp(input + '$');
var pre = text.substring(0, pos).replace(re, '');
var post = text.substring(pos);
var to_insert = replacement + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
}
if (matched.length === 1) {
if (options.escape) {
text = self.get_command();
var pos = self.get_position();
var end_re = new RegExp(safe + '$');
var pre = text.substring(0, pos).replace(end_re, '');
var post = text.substring(pos);
var to_insert = matched[0] + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
replace(safe, matched[0]);
} else {
self.insert(matched[0].replace(regex, '') + (quote || ''));
}
Expand All @@ -4984,7 +4986,7 @@
tab_count = 0;
if (options.echo) {
echo_command();
text = matched.reverse().join('\t');
var text = matched.reverse().join('\t');
self.echo($.terminal.escape_brackets(text), {
keepWords: true
});
Expand All @@ -4993,7 +4995,7 @@
} else {
var common = common_string(string, matched);
if (common) {
self.insert(common.replace(regex, ''));
replace(string, common);
command = self.before_cursor(options.word);
return true;
}
Expand Down
26 changes: 14 additions & 12 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 02 Jul 2017 08:53:06 +0000
* Date: Sun, 02 Jul 2017 09:12:42 +0000
*/

/* TODO:
Expand Down Expand Up @@ -4963,17 +4963,19 @@
matched.push(match);
}
}
var text;
function replace(input, replacement) {
var text = self.get_command();
var pos = self.get_position();
var re = new RegExp(input + '$');
var pre = text.substring(0, pos).replace(re, '');
var post = text.substring(pos);
var to_insert = replacement + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
}
if (matched.length === 1) {
if (options.escape) {
text = self.get_command();
var pos = self.get_position();
var end_re = new RegExp(safe + '$');
var pre = text.substring(0, pos).replace(end_re, '');
var post = text.substring(pos);
var to_insert = matched[0] + (quote || '');
self.set_command(pre + to_insert + post);
self.set_position((pre + to_insert).length);
replace(safe, matched[0]);
} else {
self.insert(matched[0].replace(regex, '') + (quote || ''));
}
Expand All @@ -4984,7 +4986,7 @@
tab_count = 0;
if (options.echo) {
echo_command();
text = matched.reverse().join('\t');
var text = matched.reverse().join('\t');
self.echo($.terminal.escape_brackets(text), {
keepWords: true
});
Expand All @@ -4993,7 +4995,7 @@
} else {
var common = common_string(string, matched);
if (common) {
self.insert(common.replace(regex, ''));
replace(string, common);
command = self.before_cursor(options.word);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

0 comments on commit f895202

Please sign in to comment.