[pyrepl-checkins] r53507 - pyrepl/trunk/pyrepl/pyrepl
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 7 10:52:55 CEST 2008
Author: arigo
Date: Mon Apr 7 10:52:53 2008
New Revision: 53507
Added:
pyrepl/trunk/pyrepl/pyrepl/curses.py (contents, props changed)
Modified:
pyrepl/trunk/pyrepl/pyrepl/__init__.py
pyrepl/trunk/pyrepl/pyrepl/commands.py
pyrepl/trunk/pyrepl/pyrepl/keymap.py
pyrepl/trunk/pyrepl/pyrepl/pygame_keymap.py
pyrepl/trunk/pyrepl/pyrepl/reader.py
pyrepl/trunk/pyrepl/pyrepl/unix_console.py
pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py
Log:
mwh please forgive me: some minor hacking to make the situation on top
of PyPy saner with respect to _minimal_curses. This removes the
dependency on the curses module, provided the _minimal_curses module is
importable (either as a PyPy built-in module, or else the pure Python
ctypes-based version works too).
Modified: pyrepl/trunk/pyrepl/pyrepl/__init__.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/__init__.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/__init__.py Mon Apr 7 10:52:53 2008
@@ -16,6 +16,3 @@
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import commands
-import reader
Modified: pyrepl/trunk/pyrepl/pyrepl/commands.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/commands.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/commands.py Mon Apr 7 10:52:53 2008
@@ -17,7 +17,6 @@
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-from curses import ascii
import sys, os
# Catgories of actions:
@@ -120,7 +119,7 @@
b = r.buffer
eol = r.eol()
for c in b[r.pos:eol]:
- if not ascii.isspace(c):
+ if not c.isspace():
self.kill_range(r.pos, eol)
return
else:
Added: pyrepl/trunk/pyrepl/pyrepl/curses.py
==============================================================================
--- (empty file)
+++ pyrepl/trunk/pyrepl/pyrepl/curses.py Mon Apr 7 10:52:53 2008
@@ -0,0 +1,18 @@
+
+# Some try-import logic for two purposes: avoiding to bring in the whole
+# pure Python curses package if possible; and, in _curses is not actually
+# present, falling back to _minimal_curses (which is either a ctypes-based
+# pure Python module or a PyPy built-in module).
+try:
+ import _curses
+except ImportError:
+ try:
+ import _minimal_curses as _curses
+ except ImportError:
+ # Who knows, maybe some environment has "curses" but not "_curses".
+ # If not, at least the following import gives a clean ImportError.
+ import _curses
+
+setupterm = _curses.setupterm
+tigetstr = _curses.tigetstr
+tparm = _curses.tparm
Modified: pyrepl/trunk/pyrepl/pyrepl/keymap.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/keymap.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/keymap.py Mon Apr 7 10:52:53 2008
@@ -52,8 +52,6 @@
- all of these are the tab character. Can you think of any more?
"""
-from curses import ascii
-
_escapes = {
'\\':'\\',
"'":"'",
@@ -156,7 +154,7 @@
if ctrl:
if len(ret) > 1:
raise KeySpecError, "\\C- must be followed by a character"
- ret = ascii.ctrl(ret)
+ ret = chr(ord(ret) & 0x1f) # curses.ascii.ctrl()
if meta:
ret = ['\033', ret]
else:
Modified: pyrepl/trunk/pyrepl/pyrepl/pygame_keymap.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/pygame_keymap.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/pygame_keymap.py Mon Apr 7 10:52:53 2008
@@ -35,7 +35,6 @@
# XXX it's actually possible to test this module, so it should have a
# XXX test suite.
-from curses import ascii
from pygame.locals import *
_escapes = {
@@ -137,7 +136,8 @@
`c`, s + 2, repr(key))
else:
if ctrl:
- ret = unicode(ascii.ctrl(key[s]))
+ ret = chr(ord(key[s]) & 0x1f) # curses.ascii.ctrl()
+ ret = unicode(ret)
else:
ret = unicode(key[s])
s += 1
Modified: pyrepl/trunk/pyrepl/pyrepl/reader.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/reader.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/reader.py Mon Apr 7 10:52:53 2008
@@ -19,7 +19,6 @@
import types, unicodedata
from pyrepl import commands
-from curses import ascii
from pyrepl import input
def _make_unctrl_map():
Modified: pyrepl/trunk/pyrepl/pyrepl/unix_console.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/unix_console.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/unix_console.py Mon Apr 7 10:52:53 2008
@@ -17,9 +17,10 @@
# CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-import termios, curses, select, os, struct, errno
+import termios, select, os, struct, errno
import signal, re, time, sys
from fcntl import ioctl
+from pyrepl import curses
from pyrepl.fancy_termios import tcgetattr, tcsetattr
from pyrepl.console import Console, Event
from pyrepl import unix_eventqueue
Modified: pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py
==============================================================================
--- pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py (original)
+++ pyrepl/trunk/pyrepl/pyrepl/unix_eventqueue.py Mon Apr 7 10:52:53 2008
@@ -22,7 +22,7 @@
from pyrepl import keymap
from pyrepl.console import Event
-import curses
+from pyrepl import curses
from termios import tcgetattr, VERASE
_keynames = {
More information about the pyrepl-checkins
mailing list