@@ -148,8 +148,10 @@ function* emitKeys(stream) {
148148 *
149149 * - `;5` part is optional, e.g. it could be `\x1b[24~`
150150 * - first part can contain one or two digits
151+ * - there is also special case when there can be 3 digits
152+ * but without modifier. They are the case of paste bracket mode
151153 *
152- * So the generic regexp is like /^\d\d?(;\d)?[~^$]$/
154+ * So the generic regexp is like /^(?: \d\d?(;\d)?[~^$]|\d{3}~) $/
153155 *
154156 *
155157 * 2. `\x1b[1;5H` should be parsed as { code: '[H', modifier: 5 }
@@ -170,6 +172,10 @@ function* emitKeys(stream) {
170172
171173 if ( ch >= '0' && ch <= '9' ) {
172174 s += ( ch = yield ) ;
175+
176+ if ( ch >= '0' && ch <= '9' ) {
177+ s += ( ch = yield ) ;
178+ }
173179 }
174180 }
175181
@@ -189,9 +195,13 @@ function* emitKeys(stream) {
189195 const cmd = StringPrototypeSlice ( s , cmdStart ) ;
190196 let match ;
191197
192- if ( ( match = RegExpPrototypeExec ( / ^ ( \d \d ? ) ( ; ( \d ) ) ? ( [ ~ ^ $ ] ) $ / , cmd ) ) ) {
193- code += match [ 1 ] + match [ 4 ] ;
194- modifier = ( match [ 3 ] || 1 ) - 1 ;
198+ if ( ( match = RegExpPrototypeExec ( / ^ (?: ( \d \d ? ) (?: ; ( \d ) ) ? [ ~ ^ $ ] | ( \d { 3 } ~ ) ) $ / , cmd ) ) ) {
199+ if ( match [ 3 ] ) {
200+ code += match [ 3 ] ;
201+ } else {
202+ code += match [ 1 ] ;
203+ modifier = ( match [ 2 ] || 1 ) - 1 ;
204+ }
195205 } else if (
196206 ( match = RegExpPrototypeExec ( / ^ ( ( \d ; ) ? ( \d ) ) ? ( [ A - Z a - z ] ) $ / , cmd ) )
197207 ) {
@@ -228,6 +238,10 @@ function* emitKeys(stream) {
228238 case '[13~' : key . name = 'f3' ; break ;
229239 case '[14~' : key . name = 'f4' ; break ;
230240
241+ /* paste bracket mode */
242+ case '[200~' : key . name = 'paste-start' ; break ;
243+ case '[201~' : key . name = 'paste-end' ; break ;
244+
231245 /* from Cygwin and used in libuv */
232246 case '[[A' : key . name = 'f1' ; break ;
233247 case '[[B' : key . name = 'f2' ; break ;
0 commit comments