Changeset 1385

Show
Ignore:
Timestamp:
07/04/06 13:45:28 (2 years ago)
Author:
jstenar
Message:

pyreadline-refactor: First commit on ironpython functionality (very basic, typing text but no editing, requires patched ironpython)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/branches/refactor/doc/ChangeLog

    r1267 r1385  
     12006-07-04 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * First commit for ironpython. Typing in alphabet works but no special keys. 
     3     
     4     
    152006-04-18 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    26    * Added more tests for emacsmode 
  • pyreadline/branches/refactor/pyreadline/__init__.py

    r1216 r1385  
    88#***************************************************************************** 
    99 
    10 import lineeditor,modes 
     10import logger,clipboard,lineeditor,modes 
    1111from rlmain import * 
    1212__all__ = [ 'parse_and_bind', 
  • pyreadline/branches/refactor/pyreadline/clipboard/clipboard.py

    r1267 r1385  
    3535 
    3636from ctypes import * 
    37 from winconstants import CF_TEXT, GHND 
     37from keysyms.winconstants import CF_TEXT, GHND 
    3838 
    3939OpenClipboard = windll.user32.OpenClipboard 
     
    8585    return text 
    8686 
    87 def make_tab(lists): 
    88     if hasattr(lists,"tolist"): 
    89         lists=lists.tolist() 
    90     ut=[] 
    91     for rad in lists: 
    92         if type(rad) in [list,tuple]: 
    93             ut.append("\t".join(["%s"%x for x in rad])) 
    94         else: 
    95             ut.append("%s"%rad) 
    96     return "\n".join(ut)             
    97      
    98 def send_data(lists): 
    99     SetClipboardText(make_tab(lists)) 
    100      
    10187def SetClipboardText(text): 
    10288    buffer = c_buffer(text) 
     
    11298        CloseClipboard() 
    11399 
    114  
    115 def set_clipboard_text(toclipboard): 
    116     SetClipboardText(str(toclipboard)) 
    117  
    118 def make_list_of_list(txt): 
    119     def make_num(x): 
    120         try: 
    121             return int(x) 
    122         except ValueError: 
    123             try: 
    124                 return float(x) 
    125             except ValueError: 
    126                 try: 
    127                     return complex(x) 
    128                 except ValueError: 
    129                     return x 
    130         return x                 
    131     ut=[] 
    132     flag=False 
    133     for rad in [x for x in txt.split("\r\n") if x!=""]: 
    134         raden=[make_num(x) for x in rad.split("\t")] 
    135         if str in map(type,raden): 
    136             flag=True 
    137         ut.append(raden) 
    138     return ut,flag 
    139  
    140  
    141 def get_clipboard_text_and_convert(paste_list=False): 
    142     """Get txt from clipboard. if paste_list==True the convert tab separated  
    143     data to list of lists. Enclose list of list in array() if all elements are  
    144     numeric""" 
    145     txt=GetClipboardText() 
    146     if txt: 
    147         if paste_list and "\t" in txt: 
    148             array,flag=make_list_of_list(txt) 
    149             if flag: 
    150                 txt=repr(array) 
    151             else: 
    152                 txt="array(%s)"%repr(array) 
    153             txt="".join([c for c in txt if c not in " \t\r\n"]) 
    154     return txt 
    155  
    156100if __name__ == '__main__': 
    157101    txt=GetClipboardText()                            # display last text clipped 
  • pyreadline/branches/refactor/pyreadline/console/console.py

    r1219 r1385  
    1717import traceback 
    1818import re 
    19 from logger import log 
     19from pyreadline.logger import log 
    2020 
    2121try: 
     
    2424    from _ctypes import call_function 
    2525except ImportError: 
    26     print 'you need the ctypes module to run this code' 
    27     print 'http://starship.python.net/crew/theller/ctypes/' 
    28     raise 
     26    raise ImportError("You need ctypes to run this code") 
    2927 
    3028# my code 
    31 from keysyms import make_keysym, make_keyinfo 
     29from pyreadline.keysyms import make_keysym, make_keyinfo 
    3230 
    3331# some constants we need 
     
    545543    setattr(Console, func, getattr(windll.kernel32, func)) 
    546544 
    547 class event(object): 
     545from event import Event 
     546 
     547class event(Event): 
    548548    '''Represent events from the console.''' 
    549549    def __init__(self, console, input): 
     
    592592            self.state = input.Event.MenuEvent.dwCommandId 
    593593 
    594     def __repr__(self): 
    595         '''Display an event for debugging.''' 
    596         if self.type in ['KeyPress', 'KeyRelease']: 
    597             s = "%s char='%s'%d keysym='%s' keycode=%d:%x state=%x keyinfo=%s" % \ 
    598                     (self.type, self.char, ord(self.char), self.keysym, self.keycode, self.keycode, 
    599                      self.state, self.keyinfo) 
    600         elif self.type in ['Motion', 'Button']: 
    601             s = '%s x=%d y=%d state=%x' % (self.type, self.x, self.y, self.state) 
    602         elif self.type == 'Configure': 
    603             s = '%s w=%d h=%d' % (self.type, self.width, self.height) 
    604         elif self.type in ['FocusIn', 'FocusOut']: 
    605             s = self.type 
    606         elif self.type == 'Menu': 
    607             s = '%s state=%x' % (self.type, self.state) 
    608         else: 
    609             s = 'unknown event type' 
    610         return s 
    611  
    612594def getconsole(buffer=1): 
    613595        """Get a console handle. 
  • pyreadline/branches/refactor/pyreadline/keysyms/keysyms.py

    r1267 r1385  
    150150        else: 
    151151            if len(keyname) > 1: 
    152                 return (control, meta, shift, sym2code_map[keyname.lower()]
     152                return (control, meta, shift, sym2code_map.get(keyname.lower()," ")
    153153            else: 
    154154                return char_to_keyinfo(keyname, control, meta, shift) 
  • pyreadline/branches/refactor/pyreadline/modes/emacs.py

    r1267 r1385  
    2323        self._keylog=(lambda x,y: None) 
    2424        self.previous_func=None 
    25  
     25        self.prompt="" 
    2626    def __repr__(self): 
    2727        return "<EmacsMode>"