use the language code $$l as the end of stream marker

cannot use a custom word in the session dictionary due to language
restrictions on allowed characters, e.g. armenian 'hy' does not allow
latin characters
This commit is contained in:
Brian Gough 2015-03-12 12:33:45 +00:00
parent 86d1092f85
commit a91faaf55c

View file

@ -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("!")