Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 5114 - Add greeting and Ctrl-V help to REPL #5159

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/coffeescript/repl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/repl.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ fs = require 'fs'
path = require 'path'
vm = require 'vm'
nodeREPL = require 'repl'
process = require 'process'
CoffeeScript = require './'
{merge, updateSyntaxError} = require './helpers'

sawSIGINT = no
transpile = no

hint = '\n(Press Ctrl-V again to exit multi-line mode.)'

replDefaults =
prompt: 'coffee> ',
historyFile: do ->
Expand Down Expand Up @@ -80,6 +83,8 @@ addMultilineHandler = (repl) ->
origPrompt = repl._prompt ? repl.prompt

multiline =
showHint: true
hint: hint
enabled: off
initialPrompt: origPrompt.replace /^[^> ]*/, (x) -> x.replace /./g, '-'
prompt: origPrompt.replace /^[^> ]*>?/, (x) -> x.replace /./g, '.'
Expand Down Expand Up @@ -121,6 +126,9 @@ addMultilineHandler = (repl) ->
rli.emit 'line', multiline.buffer
multiline.buffer = ''
else
if multiline.showHint
console.log multiline.hint
multiline.showHint = false
multiline.enabled = not multiline.enabled
rli.setPrompt multiline.initialPrompt
rli.prompt true
Expand Down