Skip to content

Commit

Permalink
fix bug on Android with GBoard keyboard #693
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Oct 30, 2021
1 parent 8fd2a6e commit 0a81e7c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
## 2.29.6
### Bugfix
* fix bug on Android with GBoard keyboard [#693](https://github.com/jcubic/jquery.terminal/issues/693)
* fix refresh when scrollbar appear (using `scrollbar-gutter`)

## 2.29.5
### Bugfix
* fix empty prompt when no wcwidth is included
Expand Down
37 changes: 26 additions & 11 deletions js/jquery.terminal-2.29.5.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 23 Oct 2021 08:35:03 +0000
* Date: Sat, 30 Oct 2021 09:43:10 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -231,7 +231,7 @@
/* eslint-disable */
/* istanbul ignore next */
function debug(str) {
if (false) {
if (true) {
console.log(str);
//$.terminal.active().echo(str);
}
Expand Down Expand Up @@ -1932,7 +1932,9 @@
var clip;
if (is_mobile) {
clip = (function() {
var $node = $('<div class="cmd-editable" contenteditable/>').attr({
var $node = $('<div class="cmd-editable" ' +
'contenteditable="plaintext-only"' +
' spellcheck="false"/>').attr({
autocapitalize: 'off',
autocorrect: 'off',
spellcheck: 'false',
Expand Down Expand Up @@ -4099,7 +4101,12 @@
doc.trigger(event);
}
var skip_input = false;
function input_event() {
function finalize_input_event() {
prev_command = command;
skip_insert = false;
no_keydown = true;
}
function input_event(e) {
debug('input ' + no_keydown + ' || ' + process + ' ((' + no_keypress +
' || ' + dead_key + ') && !' + skip_insert + ' && (' + single_key +
' || ' + no_key + ') && !' + backspace + ')');
Expand All @@ -4111,9 +4118,19 @@
// Some Androids don't fire keypress - #39
// if there is dead_key we also need to grab real character #158
// Firefox/Android with google keyboard don't fire keydown and keyup #319
if ((no_keydown || process || ((no_keypress || dead_key) && !skip_insert &&
(single_key || no_key) && !backspace)) &&
val !== command) {
if (no_keydown || process || ((no_keypress || dead_key) &&
!skip_insert &&
(single_key || no_key) && !backspace)) {
if (val && val === command) {
if (is_android) {
// ignore autocomplete on GBoard keyboard #693
if (no_keydown) {
event('keydown', 'Enter', 13);
}
}
finalize_input_event();
return;
}
var pos = position;
// backspace is set in keydown if no keydown we need to get new one
if (no_keydown) {
Expand Down Expand Up @@ -4170,9 +4187,7 @@
self.position(pos + Math.abs(val.length - prev_command.length));
}
}
prev_command = command;
skip_insert = false;
no_keydown = true;
finalize_input_event();
}
doc.bind('keypress.cmd', keypress_event);
doc.bind('keydown.cmd', keydown_event);
Expand Down Expand Up @@ -5071,7 +5086,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 23 Oct 2021 08:35:03 +0000',
date: 'Sat, 30 Oct 2021 09:43:10 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.29.5.min.js

Large diffs are not rendered by default.

33 changes: 24 additions & 9 deletions js/jquery.terminal-src.js
Expand Up @@ -231,7 +231,7 @@
/* eslint-disable */
/* istanbul ignore next */
function debug(str) {
if (false) {
if (true) {
console.log(str);
//$.terminal.active().echo(str);
}
Expand Down Expand Up @@ -1932,7 +1932,9 @@
var clip;
if (is_mobile) {
clip = (function() {
var $node = $('<div class="cmd-editable" contenteditable/>').attr({
var $node = $('<div class="cmd-editable" ' +
'contenteditable="plaintext-only"' +
' spellcheck="false"/>').attr({
autocapitalize: 'off',
autocorrect: 'off',
spellcheck: 'false',
Expand Down Expand Up @@ -4099,7 +4101,12 @@
doc.trigger(event);
}
var skip_input = false;
function input_event() {
function finalize_input_event() {
prev_command = command;
skip_insert = false;
no_keydown = true;
}
function input_event(e) {
debug('input ' + no_keydown + ' || ' + process + ' ((' + no_keypress +
' || ' + dead_key + ') && !' + skip_insert + ' && (' + single_key +
' || ' + no_key + ') && !' + backspace + ')');
Expand All @@ -4111,9 +4118,19 @@
// Some Androids don't fire keypress - #39
// if there is dead_key we also need to grab real character #158
// Firefox/Android with google keyboard don't fire keydown and keyup #319
if ((no_keydown || process || ((no_keypress || dead_key) && !skip_insert &&
(single_key || no_key) && !backspace)) &&
val !== command) {
if (no_keydown || process || ((no_keypress || dead_key) &&
!skip_insert &&
(single_key || no_key) && !backspace)) {
if (val && val === command) {
if (is_android) {
// ignore autocomplete on GBoard keyboard #693
if (no_keydown) {
event('keydown', 'Enter', 13);
}
}
finalize_input_event();
return;
}
var pos = position;
// backspace is set in keydown if no keydown we need to get new one
if (no_keydown) {
Expand Down Expand Up @@ -4170,9 +4187,7 @@
self.position(pos + Math.abs(val.length - prev_command.length));
}
}
prev_command = command;
skip_insert = false;
no_keydown = true;
finalize_input_event();
}
doc.bind('keypress.cmd', keypress_event);
doc.bind('keydown.cmd', keydown_event);
Expand Down
37 changes: 26 additions & 11 deletions js/jquery.terminal.js
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 23 Oct 2021 08:35:03 +0000
* Date: Sat, 30 Oct 2021 09:43:10 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -231,7 +231,7 @@
/* eslint-disable */
/* istanbul ignore next */
function debug(str) {
if (false) {
if (true) {
console.log(str);
//$.terminal.active().echo(str);
}
Expand Down Expand Up @@ -1932,7 +1932,9 @@
var clip;
if (is_mobile) {
clip = (function() {
var $node = $('<div class="cmd-editable" contenteditable/>').attr({
var $node = $('<div class="cmd-editable" ' +
'contenteditable="plaintext-only"' +
' spellcheck="false"/>').attr({
autocapitalize: 'off',
autocorrect: 'off',
spellcheck: 'false',
Expand Down Expand Up @@ -4099,7 +4101,12 @@
doc.trigger(event);
}
var skip_input = false;
function input_event() {
function finalize_input_event() {
prev_command = command;
skip_insert = false;
no_keydown = true;
}
function input_event(e) {
debug('input ' + no_keydown + ' || ' + process + ' ((' + no_keypress +
' || ' + dead_key + ') && !' + skip_insert + ' && (' + single_key +
' || ' + no_key + ') && !' + backspace + ')');
Expand All @@ -4111,9 +4118,19 @@
// Some Androids don't fire keypress - #39
// if there is dead_key we also need to grab real character #158
// Firefox/Android with google keyboard don't fire keydown and keyup #319
if ((no_keydown || process || ((no_keypress || dead_key) && !skip_insert &&
(single_key || no_key) && !backspace)) &&
val !== command) {
if (no_keydown || process || ((no_keypress || dead_key) &&
!skip_insert &&
(single_key || no_key) && !backspace)) {
if (val && val === command) {
if (is_android) {
// ignore autocomplete on GBoard keyboard #693
if (no_keydown) {
event('keydown', 'Enter', 13);
}
}
finalize_input_event();
return;
}
var pos = position;
// backspace is set in keydown if no keydown we need to get new one
if (no_keydown) {
Expand Down Expand Up @@ -4170,9 +4187,7 @@
self.position(pos + Math.abs(val.length - prev_command.length));
}
}
prev_command = command;
skip_insert = false;
no_keydown = true;
finalize_input_event();
}
doc.bind('keypress.cmd', keypress_event);
doc.bind('keydown.cmd', keydown_event);
Expand Down Expand Up @@ -5071,7 +5086,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 23 Oct 2021 08:35:03 +0000',
date: 'Sat, 30 Oct 2021 09:43:10 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 0a81e7c

Please sign in to comment.