pyreadline: Added code to make interoperability with emacs work again.

This commit is contained in:
jstenar
2008-01-07 18:46:56 +00:00
parent 66a2fc410e
commit 82e2824891
2 changed files with 15 additions and 2 deletions
+4
View File
@@ -1,3 +1,7 @@
2008-01-07 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
* Reintroduced code to make pyreadline work with emacs. Not tested.
Requested by Frank Wang.
2008-01-04 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
* Chunking calls to WriteConsoleW to ensure not exceeding 64k limit
+11 -2
View File
@@ -13,7 +13,7 @@ This was modeled after the C extension of the same name by Fredrik Lundh.
# primitive debug printing that won't interfere with the screen
import sys
import sys,os
import traceback
import re
from pyreadline.logger import log,log_sock
@@ -145,6 +145,7 @@ funcs = [
'SetConsoleWindowInfo',
'WriteConsoleW',
'WriteConsoleOutputCharacterW',
'WriteFile',
]
# I don't want events for these keys, they are just a bother for my application
@@ -345,7 +346,6 @@ class Console(object):
self.WriteConsoleW(self.hout, short_chunk, len(short_chunk), byref(junk), None)
return n
def write_plain(self, text, attr=None):
'''write text at current cursor position.'''
log('write("%s", %s)' %(text,attr))
@@ -357,6 +357,15 @@ class Console(object):
self.WriteConsoleW(self.hout, ensure_unicode(short_chunk), len(short_chunk), byref(junk), None)
return len(text)
#This function must be used to ensure functioning with EMACS
#Emacs sets the EMACS environment variable
if os.environ.has_key("EMACS"):
def write_color(self, text, attr=None):
junk = c_int(0)
self.WriteFile(self.hout, text, len(text), byref(junk),None)
return len(text)
write_plain = write_color
# make this class look like a file object
def write(self, text):
log('write("%s")' % text)