sagemathinc / cowasm-python

CoWasm-Python: WebAssembly Python for Servers and Browsers
6 stars 0 forks source link

fully support the curses module #8

Open williamstein opened 1 year ago

williamstein commented 1 year ago

I've been putting a ton of work into supporting curses in Python on the web, but it's not quite there. I still don't have it fully done. If you go to https://cowasm.sh/ and type "rogue" or "hanoi" you can see some games running using curses purely in the browser.

If in cowasm.org you try

>>> import curses
>>> curses.initscr()

there's a bunch of errors involving my termcap file parsing. I haven't got around to solving that problem yet, but I'm sure I will, since I won't fully old-school ipython support, and also the ability to quickly run a little vim session from python or cowasm.sh, and I'm almost there.

Anyway, this ticket is about figuring this out. Basically all the examples that come with curses work, but third party stuff mostly doesn't. It's probably just one little tiny detail somewhere to fix this, but figuring out what that detail is...

martin12333 commented 1 year ago

I am studying this topic now.

After the error messages,


>>> curses.initscr()
Name collision 'xterm-new' between
        xf|xterm-new|modern xterm:,
and     xf|xterm-new|modern xterm:,
...now  modern xterm:,
Cannot remove alias 'modern xterm:,'

........

Name collision 'xterm+kbs' between
        xterm+kbs|fragment for backspace key:,
and     xterm+kbs|fragment for backspace key:,
...now  fragment for backspace key:,
Cannot remove alias 'fragment for backspace key:,'

there is


<_curses.window object at 0xd7f3d0>

So I tried

w=curses.initscr()
w.getch(  )  # works

I plan to try some Python-curses examples and demos.

williamstein commented 1 year ago

Thanks. I don't understand yet why curses fails in some cases, but all the examples that come with ncurses itself (such as hanoi) do work. If you find out anything, please post!