| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3c346b8 commit 7f11c72
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -816,15 +816,20 @@ function _ttyWriteDumb(s, key) { | |||
| 816 | 816 | if (this._sawReturnAt && key.name !== 'enter') | |
| 817 | 817 | this._sawReturnAt = 0; | |
| 818 | 818 | ||
| 819 | - if (key.ctrl && key.name === 'c') { | ||
| 820 | - if (this.listenerCount('SIGINT') > 0) { | ||
| 821 | - this.emit('SIGINT'); | ||
| 822 | - } else { | ||
| 823 | - // This readline instance is finished | ||
| 819 | + if (key.ctrl) { | ||
| 820 | + if (key.name === 'c') { | ||
| 821 | + if (this.listenerCount('SIGINT') > 0) { | ||
| 822 | + this.emit('SIGINT'); | ||
| 823 | + } else { | ||
| 824 | + // This readline instance is finished | ||
| 825 | + this.close(); | ||
| 826 | + } | ||
| 827 | + | ||
| 828 | + return; | ||
| 829 | + } else if (key.name === 'd') { | ||
| 824 | 830 | this.close(); | |
| 831 | + return; | ||
| 825 | 832 | } | |
| 826 | - | ||
| 827 | - return; | ||
| 828 | 833 | } | |
| 829 | 834 | ||
| 830 | 835 | switch (key.name) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,10 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | ||
| 4 | 4 | process.env.TERM = 'dumb'; | |
| 5 | 5 | ||
| 6 | 6 | const repl = require('repl'); | |
| 7 | + const ArrayStream = require('../common/arraystream'); | ||
| 7 | 8 | ||
| 8 | 9 | repl.start('> '); | |
| 9 | 10 | process.stdin.push('console.log("foo")\n'); | |
@@ -13,3 +14,18 @@ process.stdin.push('console.dir({ a: 1 })\n'); | |||
| 13 | 14 | process.stdin.push('{ a: 1 }\n'); | |
| 14 | 15 | process.stdin.push('\n'); | |
| 15 | 16 | process.stdin.push('.exit\n'); | |
| 17 | + | ||
| 18 | + // Verify Control+D support. | ||
| 19 | + { | ||
| 20 | + const stream = new ArrayStream(); | ||
| 21 | + const replServer = repl.start({ | ||
| 22 | + prompt: '> ', | ||
| 23 | + terminal: true, | ||
| 24 | + input: stream, | ||
| 25 | + output: stream, | ||
| 26 | + useColors: false | ||
| 27 | + }); | ||
| 28 | + | ||
| 29 | + replServer.on('close', common.mustCall()); | ||
| 30 | + replServer.write(null, { ctrl: true, name: 'd' }); | ||
| 31 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments