[pyrepl-checkins] pyrepl/pyrepl __init__.py,1.2,1.3 cmdrepl.py,1.2,1.3commands.py,1.8,1.9 completer.py,1.2,1.3 completing_reader.py,1.6,1.7 console.py,1.4,1.5 copy_code.py,1.2,1.3 fancy_termios.py,1.3,1.4 historical_reader.py,1.7,1.8 input.py,1.4,1.5 keymap.py,1.2,1.3 keymaps.py,1.3,1.4 module_lister.py,1.4,1.5 pygame_console.py,1.4,1.5 pygame_keymap.py,1.2,1.3 python_reader.py,1.13,1.14 reader.py,1.11,1.12 unix_console.py,1.9,1.10 unix_eventqueue.py,1.1,1.2

mwh@codespeak.net mwh@codespeak.net
Tue, 11 May 2004 19:20:38 +0200 (MEST)


Update of /cvs/pyrepl/pyrepl/pyrepl
In directory thoth.codespeak.net:/tmp/cvs-serv13715

Modified Files:
	__init__.py cmdrepl.py commands.py completer.py 
	completing_reader.py console.py copy_code.py fancy_termios.py 
	historical_reader.py input.py keymap.py keymaps.py 
	module_lister.py pygame_console.py pygame_keymap.py 
	python_reader.py reader.py unix_console.py unix_eventqueue.py 
Log Message:
Various changes:

 * it's 2004 now!
 * make Reader and subclasses new-style classes
   - make the inheritance hierachy look like this
                     Reader
                    /      \
      HistoricalReader   CompletingReader
                    \      /
                PythonicReader
    - needed to slightly change the way keymaps are built
 * assorted fixes to handle unbound keys and unspecified commands better
 * using codecs.getreader() in unix_console turned out to hurt
 * unshag UnixConsole.getpending()



Index: __init__.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/__init__.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** __init__.py	17 Jan 2003 13:25:54 -0000	1.2
--- __init__.py	11 May 2004 17:20:34 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: cmdrepl.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/cmdrepl.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** cmdrepl.py	17 Jan 2003 13:25:54 -0000	1.2
--- cmdrepl.py	11 May 2004 17:20:34 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 39,47 ****
  import cmd
  
- keymap = cr.completing_keymap + (
-     ("\\M-\\n", "invalid-key"),
-     ("\\n", "accept"))
- 
  class CmdReader(CR):
      CR_init = CR.__init__
      def __init__(self, completions):
--- 39,48 ----
  import cmd
  
  class CmdReader(CR):
+     def collect_keymap(self):
+         return super(CmdReader, self).collect_keymap() + (
+             ("\\M-\\n", "invalid-key"),
+             ("\\n", "accept"))
+     
      CR_init = CR.__init__
      def __init__(self, completions):

Index: commands.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/commands.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** commands.py	29 Apr 2004 13:08:50 -0000	1.8
--- commands.py	11 May 2004 17:20:34 -0000	1.9
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 347,352 ****
  class invalid_key(Command):
      def do(self):
!         s = self.event
!         self.reader.error("`%s' not bound"%s)
  
  class invalid_command(Command):
--- 347,353 ----
  class invalid_key(Command):
      def do(self):
!         pending = self.reader.console.getpending()
!         s = ''.join(self.event) + pending.data
!         self.reader.error("`%r' not bound"%s)
  
  class invalid_command(Command):
***************
*** 358,363 ****
      def do(self):
          r = self.reader
!         #r.insert((self.event + r.console.getpending()) * r.get_arg())
!         r.insert((self.event  ) * r.get_arg())
          r.pop_input_trans()
  
--- 359,363 ----
      def do(self):
          r = self.reader
!         r.insert((self.event + r.console.getpending().data) * r.get_arg())
          r.pop_input_trans()
  
***************
*** 366,372 ****
  class QITrans(object):
      def push(self, evt):
!         self.chars = evt.data
      def get(self):
!         return ('qIHelp', self.chars)
  
  class quoted_insert(Command):
--- 366,372 ----
  class QITrans(object):
      def push(self, evt):
!         self.evt = evt
      def get(self):
!         return ('qIHelp', self.evt.raw)
  
  class quoted_insert(Command):

Index: completer.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/completer.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** completer.py	17 Jan 2003 13:25:54 -0000	1.2
--- completer.py	11 May 2004 17:20:34 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: completing_reader.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/completing_reader.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** completing_reader.py	14 Mar 2004 14:05:43 -0000	1.6
--- completing_reader.py	11 May 2004 17:20:34 -0000	1.7
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 18,26 ****
  # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  
! from pyrepl import historical_reader, commands, reader
! from pyrepl.historical_reader import HistoricalReader as HR
! 
! completing_keymap = historical_reader.history_keymap + (
!     (r'\t', 'complete'),)
  
  def uniqify(l):
--- 18,23 ----
  # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  
! from pyrepl import commands, reader
! from pyrepl.reader import Reader
  
  def uniqify(l):
***************
*** 159,164 ****
                      r.cmpltn_reset()
  
! class CompletingReader(HR):
!     """Adds completion support to the HistoricalReader class.
  
      Adds instance variables:
--- 156,161 ----
                      r.cmpltn_reset()
  
! class CompletingReader(Reader):
!     """Adds completion support
  
      Adds instance variables:
***************
*** 167,175 ****
      """
  
!     keymap = completing_keymap
      
-     HR_init = HR.__init__
      def __init__(self, console):
!         self.HR_init(console)
          self.cmpltn_menu = ["[ menu 1 ]", "[ menu 2 ]"]
          self.cmpltn_menu_vis = 0
--- 164,173 ----
      """
  
!     def collect_keymap(self):
!         return super(CompletingReader, self).collect_keymap() + (
!             (r'\t', 'complete'),)
      
      def __init__(self, console):
!         super(CompletingReader, self).__init__(console)
          self.cmpltn_menu = ["[ menu 1 ]", "[ menu 2 ]"]
          self.cmpltn_menu_vis = 0
***************
*** 179,191 ****
              self.commands[c.__name__.replace('_', '-')] = c        
  
-     HR_after_command = HR.after_command
      def after_command(self, cmd):
!         self.HR_after_command(cmd)
          if not isinstance(cmd, complete) and not isinstance(cmd, self_insert):
              self.cmpltn_reset()
  
-     HR_calc_screen = HR.calc_screen
      def calc_screen(self):
!         screen = self.HR_calc_screen()
          if self.cmpltn_menu_vis:
              ly = self.lxy[1]
--- 177,187 ----
              self.commands[c.__name__.replace('_', '-')] = c        
  
      def after_command(self, cmd):
!         super(CompletingReader, self).after_command(cmd)
          if not isinstance(cmd, complete) and not isinstance(cmd, self_insert):
              self.cmpltn_reset()
  
      def calc_screen(self):
!         screen = super(CompletingReader, self).calc_screen()
          if self.cmpltn_menu_vis:
              ly = self.lxy[1]
***************
*** 195,201 ****
          return screen
  
-     HR_finish = HR.finish
      def finish(self):
!         self.HR_finish()
          self.cmpltn_reset()
  
--- 191,196 ----
          return screen
  
      def finish(self):
!         super(CompletingReader, self).finish()
          self.cmpltn_reset()
  

Index: console.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/console.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** console.py	16 May 2003 13:45:09 -0000	1.4
--- console.py	11 May 2004 17:20:34 -0000	1.5
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 21,27 ****
      """An Event.  `evt' is 'key' or somesuch."""
  
!     def __init__(self, evt, data):
          self.evt = evt
          self.data = data
  
      def __repr__(self):
--- 21,28 ----
      """An Event.  `evt' is 'key' or somesuch."""
  
!     def __init__(self, evt, data, raw=''):
          self.evt = evt
          self.data = data
+         self.raw = raw
  
      def __repr__(self):

Index: copy_code.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/copy_code.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** copy_code.py	17 Jan 2003 13:25:54 -0000	1.2
--- copy_code.py	11 May 2004 17:20:34 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: fancy_termios.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/fancy_termios.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** fancy_termios.py	17 Jan 2003 13:25:54 -0000	1.3
--- fancy_termios.py	11 May 2004 17:20:34 -0000	1.4
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: historical_reader.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/historical_reader.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** historical_reader.py	20 May 2003 13:18:19 -0000	1.7
--- historical_reader.py	11 May 2004 17:20:34 -0000	1.8
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 21,35 ****
  from pyrepl.reader import Reader as R
  
- history_keymap = reader.default_keymap + (
-     (r'\C-n', 'next-history'),
-     (r'\C-p', 'previous-history'),
-     (r'\C-o', 'operate-and-get-next'),
-     (r'\C-r', 'reverse-history-isearch'),
-     (r'\C-s', 'forward-history-isearch'),
-     (r'\M-r', 'restore-history'),
-     (r'\M-.', 'yank-arg'),
-     (r'\<page down>', 'last-history'),
-     (r'\<page up>', 'first-history'))
- 
  isearch_keymap = tuple(
      [('\\%03o'%c, 'isearch-end') for c in range(256) if chr(c) != '\\'] + \
--- 21,24 ----
***************
*** 196,204 ****
      """
  
!     keymap = history_keymap
  
-     R_init = R.__init__
      def __init__(self, console):
!         self.R_init(console)
          self.history = []
          self.historyi = 0
--- 185,203 ----
      """
  
!     def collect_keymap(self):
!         return super(HistoricalReader, self).collect_keymap() + (
!             (r'\C-n', 'next-history'),
!             (r'\C-p', 'previous-history'),
!             (r'\C-o', 'operate-and-get-next'),
!             (r'\C-r', 'reverse-history-isearch'),
!             (r'\C-s', 'forward-history-isearch'),
!             (r'\M-r', 'restore-history'),
!             (r'\M-.', 'yank-arg'),
!             (r'\<page down>', 'last-history'),
!             (r'\<page up>', 'first-history'))
! 
  
      def __init__(self, console):
!         super(HistoricalReader, self).__init__(console)
          self.history = []
          self.historyi = 0
***************
*** 235,241 ****
              return self.transient_history.get(i, self.get_unicode())
  
-     R_prepare = R.prepare
      def prepare(self):
!         self.R_prepare()
          try:
              self.transient_history = {}
--- 234,239 ----
              return self.transient_history.get(i, self.get_unicode())
  
      def prepare(self):
!         super(HistoricalReader, self).prepare()
          try:
              self.transient_history = {}
***************
*** 253,257 ****
              raise
  
-     R_get_prompt = R.get_prompt
      def get_prompt(self, lineno, cursor_on_line):
          if cursor_on_line and self.isearch_direction <> ISEARCH_DIRECTION_NONE:
--- 251,254 ----
***************
*** 259,263 ****
              return "(%s-search `%s') "%(d, self.isearch_term)
          else:
!             return self.R_get_prompt(lineno, cursor_on_line)
  
      def isearch_next(self):
--- 256,260 ----
              return "(%s-search `%s') "%(d, self.isearch_term)
          else:
!             return super(HistoricalReader, self).get_prompt(lineno, cursor_on_line)
  
      def isearch_next(self):
***************
*** 290,296 ****
                      p = len(s)
  
-     R_finish = R.finish
      def finish(self):
!         self.R_finish()
          ret = self.get_unicode()
          for i, t in self.transient_history.items():
--- 287,292 ----
                      p = len(s)
  
      def finish(self):
!         super(HistoricalReader, self).finish()
          ret = self.get_unicode()
          for i, t in self.transient_history.items():

Index: input.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/input.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** input.py	29 Apr 2004 13:08:50 -0000	1.4
--- input.py	11 May 2004 17:20:34 -0000	1.5
***************
*** 1,2 ****
--- 1,21 ----
+ #   Copyright 2000-2004 Michael Hudson mwh@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...)
  

Index: keymap.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/keymap.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** keymap.py	14 Mar 2004 14:08:00 -0000	1.2
--- keymap.py	11 May 2004 17:20:34 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: keymaps.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/keymaps.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** keymaps.py	17 Jan 2003 13:25:54 -0000	1.3
--- keymaps.py	11 May 2004 17:20:34 -0000	1.4
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: module_lister.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/module_lister.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** module_lister.py	24 Jan 2003 10:49:15 -0000	1.4
--- module_lister.py	11 May 2004 17:20:35 -0000	1.5
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: pygame_console.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/pygame_console.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pygame_console.py	20 May 2003 13:17:57 -0000	1.4
--- pygame_console.py	11 May 2004 17:20:35 -0000	1.5
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: pygame_keymap.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/pygame_keymap.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pygame_keymap.py	17 Jan 2003 13:25:54 -0000	1.2
--- pygame_keymap.py	11 May 2004 17:20:35 -0000	1.3
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved

Index: python_reader.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/python_reader.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** python_reader.py	14 Mar 2004 14:09:57 -0000	1.13
--- python_reader.py	11 May 2004 17:20:35 -0000	1.14
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 19,24 ****
  
  # one impressive collections of imports:
! from pyrepl.completing_reader import CompletingReader as CR
! from pyrepl import completing_reader as cr, reader
  from pyrepl import copy_code, commands, completer
  from pyrepl import module_lister
--- 19,25 ----
  
  # one impressive collections of imports:
! from pyrepl.completing_reader import CompletingReader
! from pyrepl.historical_reader import HistoricalReader
! from pyrepl import completing_reader, reader
  from pyrepl import copy_code, commands, completer
  from pyrepl import module_lister
***************
*** 67,81 ****
      return saver
  
! python_keymap = cr.completing_keymap + (
!     (r'\n', 'maybe-accept'),
!     (r'\M-\n', 'insert-nl'))
! 
! class PythonicReader(CR):
!     keymap = python_keymap
      
-     CR_init = CR.__init__
      def __init__(self, console, locals,
                   compiler=None):
!         self.CR_init(console)
          self.completer = completer.Completer(locals)
          st = self.syntax_table
--- 68,80 ----
      return saver
  
! class PythonicReader(CompletingReader, HistoricalReader):
!     def collect_keymap(self):
!         return super(PythonicReader, self).collect_keymap() + (
!             (r'\n', 'maybe-accept'),
!             (r'\M-\n', 'insert-nl'))
      
      def __init__(self, console, locals,
                   compiler=None):
!         super(PythonicReader, self).__init__(console)
          self.completer = completer.Completer(locals)
          st = self.syntax_table
***************
*** 127,131 ****
                          for x in l if x.startswith(mod + '.' + name)]
          try:
!             l = cr.uniqify(self.completer.complete(stem))
              return l
          except (NameError, AttributeError):
--- 126,130 ----
                          for x in l if x.startswith(mod + '.' + name)]
          try:
!             l = completing_reader.uniqify(self.completer.complete(stem))
              return l
          except (NameError, AttributeError):

Index: reader.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/reader.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** reader.py	29 Apr 2004 13:08:50 -0000	1.11
--- reader.py	11 May 2004 17:20:35 -0000	1.12
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 161,165 ****
  del c # from the listcomps
  
! class Reader:    
      """The Reader class implements the bare bones of a command reader,
      handling such details as editing and cursor motion.  What it does
--- 161,165 ----
  del c # from the listcomps
  
! class Reader(object):
      """The Reader class implements the bare bones of a command reader,
      handling such details as editing and cursor motion.  What it does
***************
*** 216,221 ****
      """
  
-     keymap = default_keymap
- 
      help_text = """\
  This is pyrepl.  Hear my roar.
--- 216,219 ----
***************
*** 244,247 ****
--- 242,246 ----
          self.syntax_table = make_default_syntax_table()
          self.input_trans_stack = []
+         self.keymap = self.collect_keymap()
          self.input_trans = input.KeymapTranslator(
              self.keymap,
***************
*** 249,252 ****
--- 248,254 ----
              character_cls='self-insert')
  
+     def collect_keymap(self):
+         return default_keymap
+ 
      def calc_screen(self):
          """The purpose of this method is to translate changes in
***************
*** 503,507 ****
              event = self.console.get_event(block)
              if not event: # can only happen if we're not blocking
!                 return
  
              if event.evt == 'key':
--- 505,509 ----
              event = self.console.get_event(block)
              if not event: # can only happen if we're not blocking
!                 return None
  
              if event.evt == 'key':
***************
*** 520,527 ****
                      continue
                  else:
!                     return 
  
              self.do_cmd(cmd)
!             return 
  
      def readline(self):
--- 522,529 ----
                      continue
                  else:
!                     return None
  
              self.do_cmd(cmd)
!             return 1
  
      def readline(self):

Index: unix_console.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/unix_console.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** unix_console.py	16 May 2003 13:45:09 -0000	1.9
--- unix_console.py	11 May 2004 17:20:35 -0000	1.10
***************
*** 1,3 ****
! #   Copyright 2000-2003 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
--- 1,3 ----
! #   Copyright 2000-2004 Michael Hudson mwh@python.net
  #
  #                        All Rights Reserved
***************
*** 19,23 ****
  
  import termios, curses, select, os, struct, types, errno
! import signal, re, time, sys, codecs, unicodedata
  from fcntl import ioctl
  from pyrepl.fancy_termios import tcgetattr, tcsetattr
--- 19,23 ----
  
  import termios, curses, select, os, struct, types, errno
! import signal, re, time, sys
  from fcntl import ioctl
  from pyrepl.fancy_termios import tcgetattr, tcsetattr
***************
*** 94,101 ****
  
          if isinstance(f_in, int):
-             self.input = codecs.getreader(encoding)(os.fdopen(f_in))
              self.input_fd = f_in
          else:
-             self.input = codecs.getreader(encoding)(f_in)
              self.input_fd = f_in.fileno()
  
--- 94,99 ----
***************
*** 173,177 ****
  
      def change_encoding(self, encoding):
-         self.input = codecs.getreader(encoding)(self.input.stream)
          self.encoding = encoding
      
--- 171,174 ----
***************
*** 401,405 ****
              while 1: # All hail Unix!
                  try:
!                     c = self.input.read(1)
                  except IOError, err:
                      if err.errno == errno.EINTR:
--- 398,411 ----
              while 1: # All hail Unix!
                  try:
!                     c = ''
!                     while 1:
!                         c += os.read(self.input_fd, 1)
!                         try:
!                             c = unicode(c, self.encoding)
!                         except:
!                             continue
!                         else:
!                             break
!                         
                  except IOError, err:
                      if err.errno == errno.EINTR:
***************
*** 506,516 ****
      if FIONREAD:
          def getpending(self):
!             return self.input.read()
              amount = struct.unpack(
                  "i", ioctl(self.input_fd, FIONREAD, "\0\0\0\0"))[0]
!             return os.read(self.input_fd, amount)
      else:
          def getpending(self):
!             return os.read(self.input_fd, 100000) # that should be enough :)
  
      def clear(self):
--- 512,542 ----
      if FIONREAD:
          def getpending(self):
!             e = Event('key', '', '')
! 
!             while not self.event_queue.empty():
!                 e2 = self.event_queue.get()
!                 e.data += e2.data
!                 e.raw += e.raw
!                 
              amount = struct.unpack(
                  "i", ioctl(self.input_fd, FIONREAD, "\0\0\0\0"))[0]
!             raw = unicode(os.read(self.input_fd, amount), self.encoding, 'replace')
!             e.data += raw
!             e.raw += raw
!             return e
      else:
          def getpending(self):
!             e = Event('key', '', '')
! 
!             while not self.event_queue.empty():
!                 e2 = self.event_queue.get()
!                 e.data += e2.data
!                 e.raw += e.raw
!                 
!             amount = 10000
!             raw = unicode(os.read(self.input_fd, amount), self.encoding, 'replace')
!             e.data += raw
!             e.raw += raw
!             return e
  
      def clear(self):

Index: unix_eventqueue.py
===================================================================
RCS file: /cvs/pyrepl/pyrepl/pyrepl/unix_eventqueue.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** unix_eventqueue.py	16 May 2003 13:45:09 -0000	1.1
--- unix_eventqueue.py	11 May 2004 17:20:35 -0000	1.2
***************
*** 1,2 ****
--- 1,21 ----
+ #   Copyright 2000-2004 Michael Hudson mwh@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.
***************
*** 5,8 ****
--- 24,28 ----
  from pyrepl.console import Event
  import curses, termios
+ from termios import tcgetattr, VERASE
  
  _keynames = {
***************
*** 32,37 ****
              if keycode:
                  our_keycodes[keycode] = unicode(key)
!         our_keycodes[termios.tcgetattr(fd)[6][termios.VERASE]] = \
!                                                                u'backspace'
          self.k = self.ck = keymap.compile_keymap(our_keycodes)
          self.events = []
--- 52,56 ----
              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 = []
***************
*** 53,64 ****
                  self.k = k
              else:
!                 self.events.append(Event('key', k))
                  self.buf = []
                  self.k = self.ck
          elif self.buf:
!             self.events.extend([Event('key', c) for c in self.buf])
              self.buf = []
              self.k = self.ck
              self.push(char)
          else:
!             self.events.append(Event('key', char))
--- 72,83 ----
                  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))