mirror of
https://github.com/wassname/pyreadline.git
synced 2026-06-27 16:10:38 +08:00
pyreadline: patch from pan to remove cursor flickering when inputting chinese characters
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
2007-11-20 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
|
||||
* Applying patch from pan to fix flickering cursor problem when doing input
|
||||
of chinese.
|
||||
|
||||
2007-11-09 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu>
|
||||
* make all conversion is done by ensure_unicode or ensure_str to ensure uniform
|
||||
handling of unicode issues.
|
||||
|
||||
@@ -359,13 +359,6 @@ class Console(object):
|
||||
log(unicode(attr))
|
||||
log(unicode(chunk))
|
||||
self.SetConsoleTextAttribute(self.hout, attr.winattr)
|
||||
x,y = self.pos()
|
||||
x1,y1 = self.size()
|
||||
if y == y1 - 1:
|
||||
self.scroll_window(-1)
|
||||
self.scroll((0,0,x1,y1),0,-1)
|
||||
self.pos(x,y-1)
|
||||
|
||||
self.WriteConsoleW(self.hout, chunk, len(chunk), byref(junk), None)
|
||||
return n
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ def start_log(on,filename):
|
||||
|
||||
def log(s):
|
||||
if _logfile:
|
||||
s = ensure_str(s)
|
||||
print >>_logfile, s
|
||||
_logfile.flush()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import pyreadline.lineeditor.lineobj as lineobj
|
||||
import pyreadline.lineeditor.history as history
|
||||
import pyreadline.clipboard as clipboard
|
||||
from pyreadline.error import ReadlineError,GetSetError
|
||||
from pyreadline.unicode_helper import ensure_str, ensure_unicode
|
||||
in_ironpython="IronPython" in sys.version
|
||||
|
||||
class BaseMode(object):
|
||||
@@ -127,12 +128,12 @@ class BaseMode(object):
|
||||
if buf[self.begidx] in self.completer_delims:
|
||||
self.begidx += 1
|
||||
break
|
||||
text = ''.join(buf[self.begidx:self.endidx])
|
||||
text = ensure_str(''.join(buf[self.begidx:self.endidx]))
|
||||
log('complete text="%s"' % text)
|
||||
i = 0
|
||||
while 1:
|
||||
try:
|
||||
r = self.completer(text, i)
|
||||
r = ensure_unicode(self.completer(text, i))
|
||||
except:
|
||||
break
|
||||
i += 1
|
||||
@@ -148,9 +149,9 @@ class BaseMode(object):
|
||||
if buf[self.begidx] in ' \t\n':
|
||||
self.begidx += 1
|
||||
break
|
||||
text = ''.join(buf[self.begidx:self.endidx])
|
||||
text = ensure_str(''.join(buf[self.begidx:self.endidx]))
|
||||
log('file complete text="%s"' % text)
|
||||
completions = glob.glob(os.path.expanduser(text) + '*')
|
||||
completions = map(ensure_unicode, glob.glob(os.path.expanduser(text) + '*'))
|
||||
if self.mark_directories == 'on':
|
||||
mc = []
|
||||
for f in completions:
|
||||
|
||||
@@ -307,6 +307,7 @@ class Readline(object):
|
||||
|
||||
def _update_line(self):
|
||||
c=self.console
|
||||
c.cursor(0) #Hide cursor avoiding flicking
|
||||
c.pos(*self.prompt_end_pos)
|
||||
ltext = self.l_buffer.quoted_text()
|
||||
if self.l_buffer.enable_selection and self.l_buffer.selection_mark>=0:
|
||||
@@ -319,11 +320,20 @@ class Readline(object):
|
||||
n = c.write_scrolling(ltext[stop:], self.command_color)
|
||||
else:
|
||||
n = c.write_scrolling(ltext, self.command_color)
|
||||
|
||||
x,y = c.pos() #Preserve one line for Asian IME(Input Method Editor) statusbar
|
||||
w,h = c.size()
|
||||
if y >= h - 1 or n > 0:
|
||||
c.scroll_window(-1)
|
||||
c.scroll((0,0,w,h),0,-1)
|
||||
n += 1
|
||||
|
||||
self._update_prompt_pos(n)
|
||||
if hasattr(c,"clear_to_end_of_window"): #Work around function for ironpython due
|
||||
c.clear_to_end_of_window() #to System.Console's lack of FillFunction
|
||||
else:
|
||||
self._clear_after()
|
||||
c.cursor(1) #Show cursor
|
||||
self._set_cursor()
|
||||
|
||||
def readline(self, prompt=''):
|
||||
|
||||
Reference in New Issue
Block a user