mirror of
https://github.com/wassname/pyreadline.git
synced 2026-06-27 16:10:38 +08:00
pyreadline: Added code to make interoperability with emacs work again.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user