|
4 | 4 | * __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / |
5 | 5 | * / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ |
6 | 6 | * \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ |
7 | | - * \/ /____/ version 2.44.0 |
| 7 | + * \/ /____/ version DEV |
8 | 8 | * |
9 | 9 | * This file is part of jQuery Terminal. https://terminal.jcubic.pl |
10 | 10 | * |
|
41 | 41 | * |
42 | 42 | * broken image by Sophia Bai from the Noun Project (CC-BY) |
43 | 43 | * |
44 | | - * Date: Tue, 08 Oct 2024 13:21:22 +0000 |
| 44 | + * Date: Tue, 08 Oct 2024 20:17:15 +0000 |
45 | 45 | */ |
46 | 46 | /* global define, Map, BigInt */ |
47 | 47 | /* eslint-disable */ |
|
4077 | 4077 | // we hold text before keydown to fix backspace for Android/Chrome/SwiftKey |
4078 | 4078 | // keyboard that generate keycode 229 for all keys #296 |
4079 | 4079 | var prev_command = ''; |
4080 | | - var prev_key; |
| 4080 | + var prev_shortcut; |
4081 | 4081 | // --------------------------------------------------------------------- |
4082 | 4082 | // :: Keydown Event Handler |
4083 | 4083 | // --------------------------------------------------------------------- |
|
4111 | 4111 | var result; |
4112 | 4112 | process = (e.key || '').toLowerCase() === 'process' || e.which === 0; |
4113 | 4113 | dead_key = no_keypress && single_key && !is_backspace(e); |
| 4114 | + // fake event without key #977 |
| 4115 | + var have_key = typeof e.key !== 'undefined'; |
| 4116 | + var key = String(e.key).toLowerCase(); |
| 4117 | + var unidentified_key = key === 'unidentified'; |
4114 | 4118 | // special keys don't trigger keypress fix #293 |
4115 | 4119 | try { |
4116 | 4120 | if (!e.fake) { |
4117 | 4121 | single_key = is_single(e); |
| 4122 | + no_key = !unidentified_key; |
4118 | 4123 | // chrome on android support key property but it's "Unidentified" |
4119 | | - no_key = String(e.key).toLowerCase() === 'unidentified'; |
4120 | | - backspace = is_backspace(e); |
| 4124 | + backspace = have_key && is_backspace(e); |
4121 | 4125 | } |
4122 | 4126 | } catch (exception) {} |
4123 | 4127 | // keydown created in input will have text already inserted and we |
4124 | 4128 | // want text before input |
4125 | | - if (e.key === "Unidentified") { |
| 4129 | + if (unidentified_key) { |
4126 | 4130 | no_keydown = true; |
4127 | 4131 | // android swift keyboard have always which == 229 we will triger proper |
4128 | 4132 | // event in input with e.fake == true |
4129 | 4133 | return; |
4130 | 4134 | } |
4131 | 4135 | // meta and os are special keydown triggered by Emoji picker on Windows 10 |
4132 | 4136 | // meta is in Google Chrome is is in Firefox |
4133 | | - if (!e.fake && ['meta', 'os'].indexOf(e.key.toLowerCase()) === -1) { |
| 4137 | + if (!e.fake && have_key && ['meta', 'os'].indexOf(key) === -1) { |
4134 | 4138 | no_keydown = false; |
4135 | 4139 | } |
4136 | 4140 | no_keypress = true; |
4137 | 4141 | // Meta+V did bind input but it didin't happen because terminal paste |
4138 | 4142 | // prevent native insert action |
4139 | 4143 | clip.$node.off('input', paste); |
4140 | | - var key = get_key(e); |
| 4144 | + var shortcut = get_key(e); |
4141 | 4145 | if (is_function(settings.keydown)) { |
4142 | | - e.key = ie_key_fix(e); |
| 4146 | + if (have_key) { |
| 4147 | + e.key = ie_key_fix(e); |
| 4148 | + } |
4143 | 4149 | result = settings.keydown.call(self, e); |
4144 | 4150 | if (result !== undefined) { |
4145 | 4151 | //skip_keypress = true; |
|
4149 | 4155 | return result; |
4150 | 4156 | } |
4151 | 4157 | } |
4152 | | - if (key !== prev_key) { |
| 4158 | + if (shortcut !== prev_shortcut) { |
4153 | 4159 | clear_hold(); |
4154 | 4160 | } |
4155 | 4161 | // CTRL+C hanlding is only exception of cmd aware terminal logic |
4156 | 4162 | // cmd need to call CTRL+C keymap when terminal is not enabled |
4157 | | - if (enabled || (key === 'CTRL+C' && is_terminal_selected(self))) { |
| 4163 | + if (enabled || (shortcut === 'CTRL+C' && is_terminal_selected(self))) { |
4158 | 4164 | if (hold) { |
4159 | | - prev_key = key; |
4160 | | - key = 'HOLD+' + key; |
| 4165 | + prev_shortcut = shortcut; |
| 4166 | + shortcut = 'HOLD+' + shortcut; |
4161 | 4167 | if (hold_pause) { |
4162 | 4168 | return; |
4163 | 4169 | } |
4164 | | - if (settings.holdRepeatTimeout > 0 && is_delay_key(key)) { |
| 4170 | + if (settings.holdRepeatTimeout > 0 && is_delay_key(shortcut)) { |
4165 | 4171 | hold_pause = true; |
4166 | 4172 | self.oneTime(settings.holdRepeatTimeout, 'delay', function() { |
4167 | 4173 | hold_pause = false; |
|
4171 | 4177 | self.oneTime(settings.holdTimeout, 'hold', function() { |
4172 | 4178 | hold = true; |
4173 | 4179 | }); |
4174 | | - prev_key = key; |
| 4180 | + prev_shortcut = shortcut; |
4175 | 4181 | } |
4176 | 4182 | // if e.fake ignore of space is handled in input and next keydown |
4177 | 4183 | // is not triggered this is just in case code since on Android |
|
4182 | 4188 | skip_keydown = false; |
4183 | 4189 | return false; |
4184 | 4190 | } |
4185 | | - if (mobile_ignore_key(key)) { |
| 4191 | + if (mobile_ignore_key(shortcut)) { |
4186 | 4192 | skip_keydown = true; |
4187 | | - } else if (mobile_ignore_key(prev_key)) { |
| 4193 | + } else if (mobile_ignore_key(prev_shortcut)) { |
4188 | 4194 | // just in case next key is different then space |
4189 | 4195 | skip_keydown = false; |
4190 | 4196 | } |
4191 | 4197 | } |
4192 | 4198 | restart_animation(); |
4193 | 4199 | // CTRL+V don't fire keypress in IE11 |
4194 | | - skip_insert = ['CTRL+V', 'META+V'].indexOf(key) !== -1; |
| 4200 | + skip_insert = ['CTRL+V', 'META+V'].indexOf(shortcut) !== -1; |
4195 | 4201 | // only enter will reset history (and down arrow on last command) |
4196 | | - if (key.toLowerCase() === 'enter') { |
| 4202 | + if (shortcut === 'ENTER') { |
4197 | 4203 | first_up_history = true; |
4198 | 4204 | } |
4199 | 4205 | if (reverse_search && clear_reverse_search_key(e)) { |
|
4206 | 4212 | if (e.which === 13) { |
4207 | 4213 | keydown_event.call(this, e); |
4208 | 4214 | } |
4209 | | - } else if (is_function(keymap[key])) { |
4210 | | - result = keymap[key](e); |
| 4215 | + } else if (is_function(keymap[shortcut])) { |
| 4216 | + result = keymap[shortcut](e); |
4211 | 4217 | if (result === true) { |
4212 | 4218 | return; |
4213 | 4219 | } |
|
5336 | 5342 | } |
5337 | 5343 | // ------------------------------------------------------------------------- |
5338 | 5344 | $.terminal = { |
5339 | | - version: '2.44.0', |
5340 | | - date: 'Tue, 08 Oct 2024 13:21:22 +0000', |
| 5345 | + version: 'DEV', |
| 5346 | + date: 'Tue, 08 Oct 2024 20:17:15 +0000', |
5341 | 5347 | // colors from https://www.w3.org/wiki/CSS/Properties/color/keywords |
5342 | 5348 | color_names: [ |
5343 | 5349 | 'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white', |
|
0 commit comments