|
|
@@ -27,10 +27,11 @@ class ASpellWorker
|
|
|
@callback err, []
|
|
|
|
|
|
output = ""
|
|
|
+ endMarker = new RegExp("^(#{language}|Error)$", "m")
|
|
|
@pipe.stdout.on "data", (chunk) =>
|
|
|
output = output + chunk
|
|
|
- # We receive a single "*" from Aspell as the end of data marker
|
|
|
- if chunk.toString().match(/^\*$/m)
|
|
|
+ # We receive the language code from Aspell as the end of data marker
|
|
|
+ if chunk.toString().match(endMarker)
|
|
|
@callback(null, output.slice())
|
|
|
@state = 'ready'
|
|
|
output = ""
|
|
|
@@ -52,7 +53,6 @@ class ASpellWorker
|
|
|
# receive the end of data marker
|
|
|
@state = 'busy'
|
|
|
@callback = callback
|
|
|
- @setEndOfStreamMarker()
|
|
|
@setTerseMode()
|
|
|
@write(words)
|
|
|
@flush()
|
|
|
@@ -67,9 +67,10 @@ class ASpellWorker
|
|
|
|
|
|
flush: () ->
|
|
|
# get aspell to send an end of data marker "*" when ready
|
|
|
- @sendCommand("%") # take the aspell pipe out of terse mode so we can look for a '*'
|
|
|
- @sendCommand("^ENDOFSTREAMMARKER") # send our marker which will generate a '*'
|
|
|
- @sendCommand("!") # go back into terse mode
|
|
|
+ #@sendCommand("%") # take the aspell pipe out of terse mode so we can look for a '*'
|
|
|
+ #@sendCommand("^ENDOFSTREAMMARKER") # send our marker which will generate a '*'
|
|
|
+ #@sendCommand("!") # go back into terse mode
|
|
|
+ @sendCommand("$$l")
|
|
|
|
|
|
shutdown: (reason) ->
|
|
|
logger.log process: @pipe.pid, reason: reason, 'shutting down'
|
|
|
@@ -81,11 +82,6 @@ class ASpellWorker
|
|
|
return if @state == 'killed'
|
|
|
@pipe.kill('SIGKILL')
|
|
|
|
|
|
- setEndOfStreamMarker: () ->
|
|
|
- return if @setup
|
|
|
- @sendCommand("@ENDOFSTREAMMARKER") # make this string a valid word
|
|
|
- @setup = true
|
|
|
-
|
|
|
setTerseMode: () ->
|
|
|
@sendCommand("!")
|
|
|
|