GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — readline: add paste bracket mode · nodejs/node@a625f22

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/readline
    • utils.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/readline/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/readline/utils.js
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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[4]) {
200+
code += match[4];
201+
} else {
202+
code += match[1] + match[3];
203+
modifier = (match[2] || 1) - 1;
204+
}
195205
} else if (
196206
(match = RegExpPrototypeExec(/^((\d;)?(\d))?([A-Za-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

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.