Nuutti Kotivuori wrote:
Thanks! I tried the patch and it alleviates the situation a
lot. However, performance is still not good enough. Here is a sample
program to check the performance (not minimal, one of my test files):

...

When run in ISO-8859-1 mode, performance is great - when run in UTF-8
mode, even with the patch, I can easily max out the CPU and have the
display updating really slow by rapidly tapping left and right.

I've updated the patch.  Give this version a try and let me know.

Ian
Index: urwid/canvas.py
===================================================================
RCS file: /home/cvs/urwid/urwid/canvas.py,v
retrieving revision 1.51
diff -r1.51 canvas.py
38c38
< 		cursor = None, maxcol=None):
---
> 		cursor = None, maxcol=None, check_width=True):
48,52c48,57
< 		widths = []
< 		for t in text:
< 			if type(t) != type(""):
< 				raise CanvasError("Canvas text must be plain strings encoded in the screen's encoding", `text`)
< 			widths.append( calc_width( t, 0, len(t)) )
---
> 
> 		if check_width:
> 			widths = []
> 			for t in text:
> 				if type(t) != type(""):
> 					raise CanvasError("Canvas text must be plain strings encoded in the screen's encoding", `text`)
> 				widths.append( calc_width( t, 0, len(t)) )
> 		else:
> 			assert type(maxcol) == type(0)
> 			widths = [maxcol] * len(text)
350c355
< 	d = Canvas( ["".join(lt) for lt in t], a, c, cursor, xw )
---
> 	d = Canvas( ["".join(lt) for lt in t], a, c, cursor, xw, False )
Index: urwid/font.py
===================================================================
RCS file: /home/cvs/urwid/urwid/font.py,v
retrieving revision 1.10
diff -r1.10 font.py
135c135
< 		return Canvas(tl, None, csl, maxcol=width)
---
> 		return Canvas(tl, None, csl, maxcol=width, check_width=False )
Index: urwid/graphics.py
===================================================================
RCS file: /home/cvs/urwid/urwid/graphics.py,v
retrieving revision 1.39
diff -r1.39 graphics.py
86c86
< 		return Canvas([""]*rows, maxcol=0)
---
> 		return Canvas([""]*rows, maxcol=0, check_width=False)
Index: urwid/listbox.py
===================================================================
RCS file: /home/cvs/urwid/urwid/listbox.py,v
retrieving revision 1.76
diff -r1.76 listbox.py
238c238,239
< 			return Canvas([""]*maxrow, maxcol=maxcol)
---
> 			return Canvas([""]*maxrow, maxcol=maxcol, 
> 				check_width=False)
Index: urwid/util.py
===================================================================
RCS file: /home/cvs/urwid/urwid/util.py,v
retrieving revision 1.75
diff -r1.75 util.py
28a29,31
> import re
> 
> SAFE_ASCII_RE = re.compile("^[ -~]*$")
563c566
< 	if type(text) == type(u"") or utfs:
---
> 	if (type(text) == type(u"") or utfs) and not SAFE_ASCII_RE.match(text):
577d579
< 	assert type(text) == type(""), `text`
Index: urwid/widget.py
===================================================================
RCS file: /home/cvs/urwid/urwid/widget.py,v
retrieving revision 1.132
diff -r1.132 widget.py
142c142,143
< 		return Canvas( trow * maxrow, None, csrow*maxrow )
---
> 		return Canvas( trow * maxrow, None, csrow*maxrow, 
> 			maxcol=maxcol, check_width=False )
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to