@@ -53,7 +53,7 @@ replDefaults =
5353 cb err
5454
5555addMultilineHandler = (repl ) ->
56- {rli , inputStream , outputStream } = repl
56+ {inputStream , outputStream } = repl
5757 # Node 0.11.12 changed API, prompt is now _prompt.
5858 origPrompt = repl ._prompt ? repl .prompt
5959
@@ -64,15 +64,15 @@ addMultilineHandler = (repl) ->
6464 buffer : ' '
6565
6666 # Proxy node's line listener
67- nodeLineListener = rli .listeners (' line' )[0 ]
68- rli .removeListener ' line' , nodeLineListener
69- rli .on ' line' , (cmd ) ->
67+ nodeLineListener = repl .listeners (' line' )[0 ]
68+ repl .removeListener ' line' , nodeLineListener
69+ repl .on ' line' , (cmd ) ->
7070 if multiline .enabled
7171 multiline .buffer += " #{ cmd} \n "
72- rli .setPrompt multiline .prompt
73- rli .prompt true
72+ repl .setPrompt multiline .prompt
73+ repl .prompt true
7474 else
75- rli .setPrompt origPrompt
75+ repl .setPrompt origPrompt
7676 nodeLineListener cmd
7777 return
7878
@@ -83,25 +83,25 @@ addMultilineHandler = (repl) ->
8383 # allow arbitrarily switching between modes any time before multiple lines are entered
8484 unless multiline .buffer .match / \n /
8585 multiline .enabled = not multiline .enabled
86- rli .setPrompt origPrompt
87- rli .prompt true
86+ repl .setPrompt origPrompt
87+ repl .prompt true
8888 return
8989 # no-op unless the current line is empty
90- return if rli .line ? and not rli .line .match / ^ \s * $ /
90+ return if repl .line ? and not repl .line .match / ^ \s * $ /
9191 # eval, print, loop
9292 multiline .enabled = not multiline .enabled
93- rli .line = ' '
94- rli .cursor = 0
95- rli .output .cursorTo 0
96- rli .output .clearLine 1
93+ repl .line = ' '
94+ repl .cursor = 0
95+ repl .output .cursorTo 0
96+ repl .output .clearLine 1
9797 # XXX: multiline hack
9898 multiline .buffer = multiline .buffer .replace / \n / g , ' \u FF00'
99- rli .emit ' line' , multiline .buffer
99+ repl .emit ' line' , multiline .buffer
100100 multiline .buffer = ' '
101101 else
102102 multiline .enabled = not multiline .enabled
103- rli .setPrompt multiline .initialPrompt
104- rli .prompt true
103+ repl .setPrompt multiline .initialPrompt
104+ repl .prompt true
105105 return
106106
107107# Store and load command history from a file
@@ -113,32 +113,32 @@ addHistory = (repl, filename, maxSize) ->
113113 size = Math .min maxSize, stat .size
114114 # Read last `size` bytes from the file
115115 readFd = fs .openSync filename, ' r'
116- buffer = new Buffer ( size)
116+ buffer = Buffer . alloc size
117117 fs .readSync readFd, buffer, 0 , size, stat .size - size
118118 # Set the history on the interpreter
119- repl .rli . history = buffer .toString ().split (' \n ' ).reverse ()
119+ repl .history = buffer .toString ().split (' \n ' ).reverse ()
120120 # If the history file was truncated we should pop off a potential partial line
121- repl .rli . history .pop () if stat .size > maxSize
121+ repl .history .pop () if stat .size > maxSize
122122 # Shift off the final blank newline
123- repl .rli . history .shift () if repl . rli .history [0 ] is ' '
124- repl .rli . historyIndex = - 1
125- lastLine = repl .rli . history [0 ]
123+ repl .history .shift () if repl .history [0 ] is ' '
124+ repl .historyIndex = - 1
125+ lastLine = repl .history [0 ]
126126
127127 fd = fs .openSync filename, ' a'
128128
129- repl .rli . addListener ' line' , (code ) ->
129+ repl .addListener ' line' , (code ) ->
130130 if code and code .length and code isnt ' .history' and lastLine isnt code
131131 # Save the latest command in the file
132132 fs .writeSync fd, " #{ code} \n "
133133 lastLine = code
134134
135- repl .rli . on ' exit' , -> fs .close fd, ->
135+ repl .on ' exit' , -> fs .close fd, ->
136136
137137 # Add a command to show the history stack
138138 repl .commands [getCommandId (repl, ' history' )] =
139139 help : ' Show command history'
140140 action : ->
141- repl .outputStream .write " #{ repl .rli . history [.. ].reverse ().join ' \n ' } \n "
141+ repl .outputStream .write " #{ repl .history [.. ].reverse ().join ' \n ' } \n "
142142 repl .displayPrompt ()
143143
144144getCommandId = (repl , commandName ) ->
0 commit comments