Hey Ian,

So, I have been developing an emacs-like, curses-based editor in python
(Pmacs[1]) for a couple of years now (which I do all my work in at this
point). After much reflection, I realized that I should actually try to
support Unicode so that non-English speakers would have the option to
use it. This may have been a mistake.

I've seen some emails you sent around 2006 detailing problems you found
with Python's curses bindings. I'm running into some of those same
problems now. However, based on the version of Urwid I have installed
(0.9.7.1) it seems like you have it figured out... my test[2] shows
both the "print" and the "urwid" case working, whereas the "curses"
case falls down.

I read Urwid's curses_display module, but I didn't see anything
substantially different in your use of curses from mine. Do you have
any advice (other than giving up on curses and using Uriwd[3])? I
noticed you still have disclaimers about UTF-8 on your main page--what
is the state of the curses module in your opinion?

Thanks,

-- Erik

[1] http://www.bearhome.net/pmacs

[2] Attached script, run under python 2.4.4 and 2.6a2 on xterm (with
UTF8 enabled). curses module linked to ncursesw (for what it's worth).
LANG=en_US.utf8, TERM=xterm.

[3] After seeing Urwid I feel dumb for having implemented my own
routines for syntax highlighting, search-as-you-type, drawing,
split-window, etc. That said, I also fear reimplementing them *in*
Urwid.
import sys

# data is accented-e, AE, A-with-circle, o-with-slash,
# a-with-circle, --, two more a-with-circles, o-with-slash
data = u'\xe9\xc6\xc5\xf8\xe5\u2013\xe5\xe5\xf8'

arg = None
if sys.argv[1:]: arg = sys.argv[1]

if arg == 'curses':
    import curses
    stdscr = curses.initscr()
    curses.noecho()
    stdscr.addstr(data.encode('utf-8'))
    stdscr.refresh()
    stdscr.getch()
    curses.echo()
    curses.endwin()
elif arg == 'urwid':
    import urwid.curses_display, urwid
    ui = urwid.curses_display.Screen()
    def run():
        canvas = urwid.Canvas([data.encode('utf-8')])
        ui.draw_screen((20, 1), canvas)
        while not ui.get_input():
            pass
    ui.run_wrapper(run)
elif arg == 'print':
    print data.encode('utf-8')
else:
    print "run with 'print', 'urwid', or 'curses' as an argument"
_______________________________________________
Urwid mailing list
[email protected]
http://lists.excess.org/mailman/listinfo/urwid

Reply via email to