GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — readline: add paste bracket mode - fixes #45213 by jcubic · Pull Request #47150 · nodejs/node Conversation
|
|
I was testing this code with something like this, this is a basic test: const readline = require('readline'); let cmd = ''; const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); // add the paste bracket markers to output code process.stdin.on('keypress', (c, k) => { if (k?.name?.match(/^paste-/)) { cmd += k.sequence; } }); // enable paste bracket mode process.stdout.write('\x1b[?2004h'); rl.on('line', function(line) { cmd += line; // we clear old paste brackets that we don't need anymore if (cmd.match(/\x1b\[201~$/)) { cmd = cmd.replace(/\x1b\[(200|201)~/g, ''); } cmd += '\n'; // get rid of the opening paste bracket const code = cmd.replace(/\x1b\[200~/g, ''); // first you check if this is multiline if the code ends // my case is lisp code it's easy to check // if there are balanced parentheses if (/* multi-line */) { if (cmd.match(/\x1b\[200~/)) { // do indentation when copy-pasting the code // you can check if the code is indented or not } else { // user pressed enter so you can use normal auto-indent } } else { // evaluate the code } }); in the base case when you want to indent the next line you check if cmd has paste brackets code and you evaluate the code variable. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
What's now? When this will be merged? It's been two months since this issue was approved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@bnoordhuis what is the status? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@nodejs/repl - review requested |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Will check the test when I get back home. Any clue why tests failed on Linux? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150 Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
|
Landed in 87af913 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150 Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150 Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150 Fixes: #45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150 Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150 Fixes: #45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150 Fixes: #45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150 Fixes: #45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs/node#47150 Fixes: nodejs/node#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs/node#47150 Fixes: nodejs/node#45213 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Kohei Ueno <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Readline paste bracket mode
There was an error while loading. Please reload this page.