Changeset 2132

Show
Ignore:
Timestamp:
03/06/07 13:27:29 (2 years ago)
Author:
jstenar
Message:

pyreadline-branch: added possibility to bind ctrl-c to copy. Changed test for ironpython due to changes in ironpython. Some refactoring/renaming of clipboard files

Files:

Legend:

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

    r1899 r2132  
     12007-03-06 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * Changed tests for ironpython 
     3    * Added possibility to bind ctrl-c to a function 
     4    * Refactor clipboard handling 
     5    * Restructured example config file 
     6     
    172006-11-15 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    28    * moved ironpython specifics from emacs.py->readline to a hook_wrapper 
  • pyreadline/branches/refactor/pyreadline/clipboard/__init__.py

    r1877 r2132  
    11import sys 
    22success=False 
    3 in_ironpython=sys.version.startswith("IronPython") 
    4  
     3in_ironpython="IronPython" in sys.version 
    54if in_ironpython: 
    65    try: 
     
    1110else: 
    1211    try: 
    13         from clipboard import GetClipboardText,SetClipboardText 
     12        from win32_clipboard import GetClipboardText,SetClipboardText 
    1413        success=True 
    1514    except ImportError: 
    16         pass     
     15        raise     
    1716     
    18      
    19      
    20  
    2117 
    2218def send_data(lists): 
  • pyreadline/branches/refactor/pyreadline/clipboard/win32_clipboard.py

    r1419 r2132  
    1414# 
    1515# 
    16  
    1716 
    1817################################################################################### 
  • pyreadline/branches/refactor/pyreadline/configuration/pyreadlineconfig.ini

    r1898 r2132  
    44bind_exit_key("Control-z") 
    55 
    6 #Commands for moving 
    7 bind_key("Home",            "beginning_of_line") 
    8 bind_key("End",             "end_of_line") 
    9 bind_key("Left",       "backward_char") 
    10 bind_key("Control-b",       "backward_char") 
    11 bind_key("Right",           "forward_char") 
    12 bind_key("Control-f",       "forward_char") 
    13 bind_key("Alt-f",           "forward_word") 
    14 bind_key("Alt-b",           "backward_word") 
    15 bind_key("Clear",           "clear_screen") 
    16 bind_key("Control-l",       "clear_screen") 
    17 bind_key("Control-a",       "beginning_of_line") 
    18 bind_key("Control-e",       "end_of_line") 
    19 #bind_key("Control-l",       "redraw_current_line") 
     6#Commands for moving    
     7bind_key("Home",                "beginning_of_line") 
     8bind_key("End",                 "end_of_line") 
     9bind_key("Left",                "backward_char") 
     10bind_key("Control-b",           "backward_char") 
     11bind_key("Right",               "forward_char") 
     12bind_key("Control-f",           "forward_char") 
     13bind_key("Alt-f",               "forward_word") 
     14bind_key("Alt-b",               "backward_word") 
     15bind_key("Clear",               "clear_screen") 
     16bind_key("Control-l",           "clear_screen") 
     17bind_key("Control-a",           "beginning_of_line") 
     18bind_key("Control-e",           "end_of_line") 
     19#bind_key("Control-l",          "redraw_current_line") 
    2020 
    2121#Commands for Manipulating the History 
    22 bind_key("Return",      "accept_line") 
    23 bind_key("Control-p",       "previous_history") 
    24 bind_key("Control-n",       "next_history") 
    25 bind_key("Up",              "history_search_backward") 
    26 bind_key("Down",            "history_search_forward") 
    27 bind_key("Alt-<",           "beginning_of_history") 
    28 bind_key("Alt->",           "end_of_history") 
    29 bind_key("Control-r",       "reverse_search_history") 
    30 bind_key("Control-s",       "forward_search_history") 
    31 bind_key("Alt-p",           "non_incremental_reverse_search_history") 
    32 bind_key("Alt-n",           "non_incremental_forward_search_history") 
     22bind_key("Return",              "accept_line") 
     23bind_key("Control-p",           "previous_history") 
     24bind_key("Control-n",           "next_history") 
     25bind_key("Up",                  "history_search_backward") 
     26bind_key("Down",                "history_search_forward") 
     27bind_key("Alt-<",               "beginning_of_history") 
     28bind_key("Alt->",               "end_of_history") 
     29bind_key("Control-r",           "reverse_search_history") 
     30bind_key("Control-s",           "forward_search_history") 
     31bind_key("Alt-p",               "non_incremental_reverse_search_history") 
     32bind_key("Alt-n",               "non_incremental_forward_search_history") 
     33 
     34bind_key("Control-z",           "undo") 
     35bind_key("Control-_",           "undo") 
    3336 
    3437#Commands for Changing Text 
    35 bind_key("Delete",          "delete_char") 
    36 bind_key("Control-d",       "delete_char") 
    37 bind_key("BackSpace",       "backward_delete_char") 
    38 #bind_key("Control-Shift-v", "quoted_insert") 
    39 bind_key("Control-space",   "self_insert") 
     38bind_key("Delete",              "delete_char") 
     39bind_key("Control-d",           "delete_char") 
     40bind_key("BackSpace",           "backward_delete_char") 
     41#bind_key("Control-Shift-v",     "quoted_insert") 
     42bind_key("Control-space",       "self_insert") 
     43bind_key("Control-BackSpace",   "backward_delete_word") 
    4044 
    4145#Killing and Yanking 
    42 bind_key("Control-k",       "kill_line") 
    43 bind_key("Control-shift-k", "kill_whole_line") 
    44 bind_key("Escape",          "kill_whole_line") 
    45 bind_key("Meta-d",          "kill_word") 
    46 bind_key("Control-w",       "unix_word_rubout") 
    47 bind_key("Meta-Delete",     "backward_kill_word") 
     46bind_key("Control-k",           "kill_line") 
     47bind_key("Control-shift-k",     "kill_whole_line") 
     48bind_key("Escape",              "kill_whole_line") 
     49bind_key("Meta-d",              "kill_word") 
     50bind_key("Control-w",           "unix_word_rubout") 
     51bind_key("Meta-Delete",         "backward_kill_word") 
    4852 
    4953#Copy paste 
    50 bind_key("Control-m",       "set_mark") 
    51 bind_key("Control-q",       "copy_region_to_clipboard") 
    52 bind_key("Control-v",       "paste") 
    53 bind_key("Alt-v",           "ipython_paste") 
    54 bind_key("Control-y",       "paste") 
    55 bind_key("Control-z",       "undo") 
    56 bind_key("Control-_",       "undo") 
    57 bind_key('Control-Shift-v', "paste_mulitline_code") 
     54bind_key("Shift-Right",         "forward_char_extend_selection") 
     55bind_key("Shift-Left",          "backward_char_extend_selection") 
     56bind_key("Shift-Control-Right", "forward_word_extend_selection") 
     57bind_key("Shift-Control-Left",  "backward_word_extend_selection") 
     58bind_key("Control-m",           "set_mark") 
     59 
     60bind_key("Control-Shift-x",     "copy_selection_to_clipboard") 
     61#bind_key("Control-c",           "copy_selection_to_clipboard")  #Needs allow_ctrl_c(True) below to be uncommented 
     62bind_key("Control-q",           "copy_region_to_clipboard") 
     63bind_key('Control-Shift-v',     "paste_mulitline_code") 
     64bind_key("Control-x",           "cut_selection_to_clipboard") 
     65 
     66bind_key("Control-v",           "paste") 
     67bind_key("Control-y",           "paste") 
     68bind_key("Alt-v",               "ipython_paste") 
    5869 
    5970#Unbinding keys: 
    6071#un_bind_key("Home") 
    61  
    62  
    63 #new keybindings 
    64 bind_key("Shift-Right",     "forward_char_extend_selection") 
    65 bind_key("Shift-Left",      "backward_char_extend_selection") 
    66 bind_key("Shift-Control-Right",     "forward_word_extend_selection") 
    67 bind_key("Shift-Control-Left",      "backward_word_extend_selection") 
    68 bind_key("Control-BackSpace", "backward_delete_word") 
    69 bind_key("Control-x",       "cut_selection_to_clipboard") 
    70 bind_key("Control-Shift-x", "copy_selection_to_clipboard") 
    71  
    7272 
    7373#Other 
     
    7777completer_delims(" \t\n\"\\'`@$><=;|&{(?") 
    7878debug_output("off") 
     79#allow_ctrl_c(True)  #(Allows use of ctrl-c as copy key, still propagate keyboardinterrupt when not waiting for input) 
    7980 
    8081history_filename("~/.pythonhistory") 
  • pyreadline/branches/refactor/pyreadline/console/__init__.py

    r1877 r2132  
    22 
    33success=False 
    4 in_ironpython=sys.version.startswith("IronPython") 
     4in_ironpython="IronPython" in sys.version 
    55 
    66if in_ironpython: 
  • pyreadline/branches/refactor/pyreadline/keysyms/__init__.py

    r1895 r2132  
    22 
    33success=False 
    4 in_ironpython=sys.version.startswith("IronPython") 
     4in_ironpython="IronPython" in sys.version 
    55 
    66if in_ironpython: 
     
    99        success=True 
    1010    except ImportError,x: 
    11         pass 
     11        raise 
    1212else: 
    1313    try: 
  • pyreadline/branches/refactor/pyreadline/modes/basemode.py

    r1895 r2132  
    1515import pyreadline.clipboard as clipboard 
    1616from pyreadline.error import ReadlineError,GetSetError 
    17 in_ironpython=sys.version.startswith("IronPython") 
     17in_ironpython="IronPython" in sys.version 
    1818 
    1919class BaseMode(object): 
     
    4949    argument_reset=property(_argreset) 
    5050         
     51    allow_ctrl_c=property(*_gs("allow_ctrl_c")) 
    5152    l_buffer=property(*_gs("l_buffer")) 
    5253    next_meta=property(*_gs("next_meta")) 
  • pyreadline/branches/refactor/pyreadline/modes/emacs.py

    r1899 r2132  
    2222     
    2323    return "(%s,%s,%s,%s,%x)"%k 
    24 in_ironpython=sys.version.startswith("IronPython") 
     24in_ironpython="IronPython" in sys.version 
    2525 
    2626 
     
    4545        while 1: 
    4646            self._update_line() 
    47             event = c.getkeypress() 
     47            try: 
     48                event = c.getkeypress() 
     49            except KeyboardInterrupt: 
     50                from pyreadline.keysyms.common import KeyPress 
     51                from pyreadline.console.event import Event 
     52                event=Event(0,0) 
     53                event.char="c" 
     54                event.keyinfo=KeyPress("c",shift=False,control=True,meta=False,keyname=None) 
     55                log_sock("KBDIRQ") 
     56                if self.allow_ctrl_c: 
     57                    pass 
     58                else: 
     59                    raise 
    4860            if self.next_meta: 
    4961                self.next_meta = False 
  • pyreadline/branches/refactor/pyreadline/rlmain.py

    r1895 r2132  
    2222from modes import editingmodes 
    2323 
    24 in_ironpython=sys.version.startswith("IronPython") 
     24in_ironpython="IronPython" in sys.version 
    2525if in_ironpython:#ironpython does not provide a prompt string to readline 
    2626    import System     
     
    5555        self.next_meta = False # True to force meta on next character 
    5656        self.tabstop = 4 
     57        self.allow_ctrl_c=False 
    5758 
    5859        self.begidx = 0 
     
    8687 
    8788        self.paste_line_buffer=[] 
    88  
    8989 
    9090    #Below is for refactoring, raise errors when using old style attributes  
     
    354354        def sethistorylength(length): 
    355355            self._history.history_length=int(length) 
    356              
     356        def allow_ctrl_c(mode): 
     357            log_sock("allow_ctrl_c:%s:%s"%(self.allow_ctrl_c,mode)) 
     358            self.allow_ctrl_c=mode 
    357359        def setbellstyle(mode): 
    358360            self.bell_style=mode 
     
    394396             "set_prompt_color":set_prompt_color, 
    395397             "set_input_color":set_input_color, 
     398             "allow_ctrl_c":allow_ctrl_c, 
    396399             } 
    397400        if os.path.isfile(inputrcpath):