diff --git a/lib/coffeescript/repl.js b/lib/coffeescript/repl.js index b9c38031b8..557aac77dc 100644 --- a/lib/coffeescript/repl.js +++ b/lib/coffeescript/repl.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript 2.3.2 (function() { - var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, sawSIGINT, transpile, updateSyntaxError, vm; + var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, hint, merge, nodeREPL, path, process, replDefaults, runInContext, sawSIGINT, transpile, updateSyntaxError, vm; fs = require('fs'); @@ -10,6 +10,8 @@ nodeREPL = require('repl'); + process = require('process'); + CoffeeScript = require('./'); ({merge, updateSyntaxError} = require('./helpers')); @@ -18,6 +20,8 @@ transpile = false; + hint = '\n(Press Ctrl-V again to exit multi-line mode.)'; + replDefaults = { prompt: 'coffee> ', historyFile: (function() { @@ -118,6 +122,8 @@ // Node 0.11.12 changed API, prompt is now _prompt. origPrompt = (ref = repl._prompt) != null ? ref : repl.prompt; multiline = { + showHint: true, + hint: hint, enabled: false, initialPrompt: origPrompt.replace(/^[^> ]*/, function(x) { return x.replace(/./g, '-'); @@ -168,6 +174,10 @@ rli.emit('line', multiline.buffer); multiline.buffer = ''; } else { + if (multiline.showHint) { + console.log(multiline.hint); + multiline.showHint = false; + } multiline.enabled = !multiline.enabled; rli.setPrompt(multiline.initialPrompt); rli.prompt(true); diff --git a/src/repl.coffee b/src/repl.coffee index 1896028694..4ffb7955c6 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -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 -> @@ -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, '.' @@ -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