[pyrepl-checkins] r5441 - pyrepl/branch/pyrepl-rework-n/pyrepl
mwh at codespeak.net
mwh at codespeak.net
Mon Jul 5 17:25:47 MEST 2004
Author: mwh
Date: Mon Jul 5 17:25:46 2004
New Revision: 5441
Removed:
pyrepl/branch/pyrepl-rework-n/pyrepl/input.py
pyrepl/branch/pyrepl-rework-n/pyrepl/unix_eventqueue.py
Modified:
pyrepl/branch/pyrepl-rework-n/pyrepl/reader.py
pyrepl/branch/pyrepl-rework-n/pyrepl/unix_console.py
Log:
kill some code
Deleted: /pyrepl/branch/pyrepl-rework-n/pyrepl/input.py
==============================================================================
--- /pyrepl/branch/pyrepl-rework-n/pyrepl/input.py Mon Jul 5 17:25:46 2004
+++ (empty file)
@@ -1,97 +0,0 @@
-# Copyright 2000-2004 Michael Hudson mwh at python.net
-#
-# All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# 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.
-
-# (naming modules after builtin functions is not such a hot idea...)
-
-# an KeyTrans instance translates Event objects into Command objects
-
-# hmm, at what level do we want [C-i] and [tab] to be equivalent?
-# [meta-a] and [esc a]? obviously, these are going to be equivalent
-# for the UnixConsole, but should they be for PygameConsole?
-
-# it would in any situation seem to be a bad idea to bind, say, [tab]
-# and [C-i] to *different* things... but should binding one bind the
-# other?
-
-# executive, temporary decision: [tab] and [C-i] are distinct, but
-# [meta-key] is identified with [esc key]. We demand that any console
-# class does quite a lot towards emulating a unix terminal.
-
-import unicodedata
-
-class InputTranslator(object):
- def push(self, evt):
- pass
- def get(self):
- pass
- def empty(self):
- pass
-
-class KeymapTranslator(InputTranslator):
- def __init__(self, keymap, verbose=0,
- invalid_cls=None, character_cls=None):
- self.verbose = verbose
- from pyrepl.keymap import compile_keymap, parse_keys
- self.keymap = keymap
- self.invalid_cls = invalid_cls
- self.character_cls = character_cls
- d = {}
- for keyspec, command in keymap:
- keyseq = tuple(parse_keys(keyspec))
- d[keyseq] = command
- if self.verbose:
- print d
- self.k = self.ck = compile_keymap(d, ())
- self.results = []
- self.stack = []
- def push(self, evt):
- if self.verbose:
- print "pushed", evt.data,
- key = evt.data
- d = self.k.get(key)
- if isinstance(d, dict):
- if self.verbose:
- print "transition"
- self.stack.append(key)
- self.k = d
- else:
- if d is None:
- if self.verbose:
- print "invalid"
- if self.stack or len(key) > 1 or unicodedata.category(key) == 'C':
- self.results.append(
- (self.invalid_cls, self.stack + [key]))
- else:
- # small optimization:
- self.k[key] = self.character_cls
- self.results.append(
- (self.character_cls, [key]))
- else:
- if self.verbose:
- print "matched", d
- self.results.append((d, self.stack + [key]))
- self.stack = []
- self.k = self.ck
- def get(self):
- if self.results:
- return self.results.pop(0)
- else:
- return None
- def empty(self):
- return not self.results
Modified: pyrepl/branch/pyrepl-rework-n/pyrepl/reader.py
==============================================================================
--- pyrepl/branch/pyrepl-rework-n/pyrepl/reader.py (original)
+++ pyrepl/branch/pyrepl-rework-n/pyrepl/reader.py Mon Jul 5 17:25:46 2004
@@ -545,8 +545,8 @@
def bind(self, spec, command):
self.keymap = self.keymap + ((spec, command),)
- self.input_trans = input.KeymapTranslator(
- self.keymap,
+ self.input_trans = commandsm.CommandSM(
+ None, self.console.keys, self.keymap,
invalid_cls='invalid-key',
character_cls='self-insert')
Modified: pyrepl/branch/pyrepl-rework-n/pyrepl/unix_console.py
==============================================================================
--- pyrepl/branch/pyrepl-rework-n/pyrepl/unix_console.py (original)
+++ pyrepl/branch/pyrepl-rework-n/pyrepl/unix_console.py Mon Jul 5 17:25:46 2004
@@ -21,8 +21,7 @@
import signal, re, time, sys
from fcntl import ioctl
from pyrepl.fancy_termios import tcgetattr, tcsetattr
-from pyrepl.console import Console, Event
-from pyrepl import unix_eventqueue
+from pyrepl.console import Console
from pyrepl.dfa import unicodesm, keystrokesm
# there are arguments for changing this to "refresh"
Deleted: /pyrepl/branch/pyrepl-rework-n/pyrepl/unix_eventqueue.py
==============================================================================
--- /pyrepl/branch/pyrepl-rework-n/pyrepl/unix_eventqueue.py Mon Jul 5 17:25:46 2004
+++ (empty file)
@@ -1,83 +0,0 @@
-# Copyright 2000-2004 Michael Hudson mwh at python.net
-#
-# All Rights Reserved
-#
-#
-# Permission to use, copy, modify, and distribute this software and
-# its documentation for any purpose is hereby granted without fee,
-# provided that the above copyright notice appear in all copies and
-# that both that copyright notice and this permission notice appear in
-# supporting documentation.
-#
-# THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
-# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
-# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
-# 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.
-
-# Bah, this would be easier to test if curses/terminfo didn't have so
-# much non-introspectable global state.
-
-from pyrepl import keymap
-from pyrepl.console import Event
-import curses
-from termios import tcgetattr, VERASE
-
-_keynames = {
- "delete" : "kdch1",
- "down" : "kcud1",
- "end" : "kend",
- "enter" : "kent",
- "f1" : "kf1", "f2" : "kf2", "f3" : "kf3", "f4" : "kf4",
- "f5" : "kf5", "f6" : "kf6", "f7" : "kf7", "f8" : "kf8",
- "f9" : "kf9", "f10" : "kf10", "f11" : "kf11", "f12" : "kf12",
- "f13" : "kf13", "f14" : "kf14", "f15" : "kf15", "f16" : "kf16",
- "f17" : "kf17", "f18" : "kf18", "f19" : "kf19", "f20" : "kf20",
- "home" : "khome",
- "insert" : "kich1",
- "left" : "kcub1",
- "page down" : "knp",
- "page up" : "kpp",
- "right" : "kcuf1",
- "up" : "kcuu1",
- }
-
-class EventQueue(object):
- def __init__(self, fd):
- our_keycodes = {}
- for key, tiname in _keynames.items():
- keycode = curses.tigetstr(tiname)
- if keycode:
- our_keycodes[keycode] = unicode(key)
- our_keycodes[tcgetattr(fd)[6][VERASE]] = u'backspace'
- self.k = self.ck = keymap.compile_keymap(our_keycodes)
- self.events = []
- self.buf = []
- def get(self):
- if self.events:
- return self.events.pop(0)
- else:
- return None
- def empty(self):
- return not self.events
- def insert(self, event):
- self.events.append(event)
- def push(self, char):
- if char in self.k:
- k = self.k[char]
- if isinstance(k, dict):
- self.buf.append(char)
- self.k = k
- else:
- self.events.append(Event('key', k, ''.join(self.buf) + char))
- self.buf = []
- self.k = self.ck
- elif self.buf:
- self.events.extend([Event('key', c, c) for c in self.buf])
- self.buf = []
- self.k = self.ck
- self.push(char)
- else:
- self.events.append(Event('key', char, char))
More information about the pyrepl-checkins
mailing list