Changeset 2921
- Timestamp:
- 01/04/08 10:57:27 (1 year ago)
- Files:
-
- pyreadline/trunk/doc/ChangeLog (modified) (1 diff)
- pyreadline/trunk/pyreadline/console/console.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyreadline/trunk/doc/ChangeLog
r2876 r2921 1 2008-01-04 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 * Chunking calls to WriteConsoleW to ensure not exceeding 64k limit 3 1 4 2007-11-28 Jörgen Stenarson <jorgen.stenarson -at- bostream.nu> 2 5 * Warning messages for failed calls to parse_and_bind now disabled by default pyreadline/trunk/pyreadline/console/console.py
r2868 r2921 154 154 0x5b:1, # windows key 155 155 } 156 157 def split_block(text,size=1000): 158 return [text[start:start+size] for start in range(0, len(text), size)] 159 160 156 161 157 162 class Console(object): … … 330 335 331 336 def write_color(self, text, attr=None): 332 '''write text at current cursor position and interpret color escapes.333 334 return the number of characters written.335 '''336 log('write_color("%s", %s)' % (text, attr))337 chunks = self.terminal_escape.split(text)338 log('chunks=%s' % repr(chunks))339 junk = c_int(0)340 n = 0 # count the characters we actually write, omitting the escapes341 for chunk in chunks:342 m = self.escape_parts.match(chunk)343 if m:344 attr = self.escape_to_color[m.group(1)]345 continue346 n += len(chunk)347 log('attr=%s' % attr)348 if attr is None:349 attr = self.attr350 self.SetConsoleTextAttribute(self.hout, attr)351 #self.WriteConsoleW(self.hout, ensure_str(chunk), len(chunk), byref(junk), None)352 return n353 354 def write_color(self, text, attr=None):355 337 text = ensure_unicode(text) 356 338 n,res= self.ansiwriter.write_color(text,attr) … … 360 342 log(unicode(chunk)) 361 343 self.SetConsoleTextAttribute(self.hout, attr.winattr) 362 self.WriteConsoleW(self.hout, chunk, len(chunk), byref(junk), None) 344 for short_chunk in split_block(chunk): 345 self.WriteConsoleW(self.hout, short_chunk, len(short_chunk), byref(junk), None) 363 346 return n 364 347 … … 371 354 n = c_int(0) 372 355 self.SetConsoleTextAttribute(self.hout, attr) 373 self.WriteConsoleW(self.hout, ensure_unicode(chunk), len(chunk), byref(junk), None) 356 for short_chunk in split_block(chunk): 357 self.WriteConsoleW(self.hout, ensure_unicode(short_chunk), len(short_chunk), byref(junk), None) 374 358 return len(text) 375 359
