# fribidi does not support ungetting, so force newlines
try:
params['progress_with_newline']=True
importpty
master,slave=pty.openpty()
forfidin['_screen_file','_err_file']:
width=get_term_width()
classFribidiOut(object):
ifwidthisNone:
def__init__(self,outfile,errfile):
width_args=[]
self.outfile=outfile
else:
self.process=subprocess.Popen(
width_args=['-w',str(width)]
['fribidi'],
self._fribidi=subprocess.Popen(
stdin=subprocess.PIPE,
['fribidi','-c','UTF-8']+width_args,
stdout=outfile,
stdin=subprocess.PIPE,
stderr=errfile)
stdout=slave,
stderr=self._err_file)
defwrite(self,s):
self._fribidi_channel=os.fdopen(master,'rb')
res=self.process.stdin.write(s)
exceptOSErrorasose:
self.flush()
ifose.errno==2:
returnres
self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')
else:
defflush(self):
raise
returnself.process.stdin.flush()
defisatty(self):
returnself.outfile.isatty()
try:
vout=FribidiOut(getattr(self,fid),self._err_file)
setattr(self,fid,vout)
exceptOSErrorasose:
ifose.errno==2:
self.report_warning(u'Could not find fribidi executable, ignoring --bidi-workaround . Make sure that fribidi is an executable file in one of the directories in your $PATH.')