From aad4975eaf9e607856e3623c5371a3513934fbde Mon Sep 17 00:00:00 2001 From: jstenar <> Date: Mon, 14 May 2007 20:18:43 +0000 Subject: [PATCH] pyreadline: fix pageup, pagedown scrolling of window. Started work on implementing kill_ring separate from clipboard. ctrl-k and esc no longer puts anything on clipboard --- doc/ChangeLog | 4 +++ pyreadline/configuration/pyreadlineconfig.ini | 2 +- pyreadline/console/console.py | 4 +-- pyreadline/lineeditor/lineobj.py | 30 ++++++++++++------- pyreadline/modes/emacs.py | 6 ++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index aae8e65..ffeea69 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2007-05-14 Jörgen Stenarson + * Fixing pageup pagedown scrolling of window + * Begining work on killring. ctrl-k ctrl-y will not use clipboard anymore + 2007-05-14 Jörgen Stenarson * pre_inputhook and startup_hook were not functioning properly. diff --git a/pyreadline/configuration/pyreadlineconfig.ini b/pyreadline/configuration/pyreadlineconfig.ini index 9e833d7..4b7b956 100644 --- a/pyreadline/configuration/pyreadlineconfig.ini +++ b/pyreadline/configuration/pyreadlineconfig.ini @@ -64,7 +64,7 @@ bind_key('Control-Shift-v', "paste_mulitline_code") bind_key("Control-x", "cut_selection_to_clipboard") bind_key("Control-v", "paste") -bind_key("Control-y", "paste") +bind_key("Control-y", "yank") bind_key("Alt-v", "ipython_paste") #Unbinding keys: diff --git a/pyreadline/console/console.py b/pyreadline/console/console.py index bb6513c..ce6a2ff 100644 --- a/pyreadline/console/console.py +++ b/pyreadline/console/console.py @@ -507,9 +507,9 @@ class Console(object): e = self.get() if e.type == 'KeyPress' and e.keycode not in key_modifiers: log(e) - if e.keysym == 'Next': + if e.keyinfo.keyname == 'next': self.scroll_window(12) - elif e.keysym == 'Prior': + elif e.keyinfo.keyname == 'prior': self.scroll_window(-12) else: return e diff --git a/pyreadline/lineeditor/lineobj.py b/pyreadline/lineeditor/lineobj.py index 852ba62..3969e39 100644 --- a/pyreadline/lineeditor/lineobj.py +++ b/pyreadline/lineeditor/lineobj.py @@ -392,7 +392,7 @@ class ReadLineTextBuffer(TextLine): self.enable_win32_clipboard=True self.selection_mark=-1 self.enable_selection=True - + self.kill_ring=[] def __repr__(self): return 'ReadLineTextBuffer("%s",point=%s,mark=%s,selection_mark=%s)'%(self.line_buffer,self.point,self.mark,self.selection_mark) @@ -634,15 +634,17 @@ class ReadLineTextBuffer(TextLine): ############ Kill def kill_line(self): - self[self.point:].to_clipboard() + #self[self.point:].to_clipboard() + self.add_to_kill_ring(self[self.point:]) del self.line_buffer[self.point:] def kill_whole_line(self): - self[:].to_clipboard() + #self[:].to_clipboard() + self.add_to_kill_ring(self[:]) del self[:] def backward_kill_line(self): - self[StartOfLine:Point].to_clipboard() + #self[StartOfLine:Point].to_clipboard() del self[StartOfLine:Point] def unix_line_discard(self): @@ -651,25 +653,24 @@ class ReadLineTextBuffer(TextLine): def kill_word(self): """Kills to next word ending""" - self[Point:NextWordEnd].to_clipboard() + #self[Point:NextWordEnd].to_clipboard() del self[Point:NextWordEnd] def backward_kill_word(self): """Kills to next word ending""" - self[PrevWordStart:Point].to_clipboard() + #self[PrevWordStart:Point].to_clipboard() if not self.delete_selection(): del self[PrevWordStart:Point] self.selection_mark=-1 def forward_kill_word(self): """Kills to next word ending""" - self[Point:NextWordEnd].to_clipboard() + #self[Point:NextWordEnd].to_clipboard() if not self.delete_selection(): del self[Point:NextWordEnd] self.selection_mark=-1 def unix_word_rubout(self): - self[PrevSpace:Point].to_clipboard() if not self.delete_selection(): del self[PrevSpace:Point] self.selection_mark=-1 @@ -688,12 +689,11 @@ class ReadLineTextBuffer(TextLine): def yank(self): - pass + self.paste_from_kill_ring() def yank_pop(self): pass - ############## Mark def set_mark(self): @@ -734,6 +734,16 @@ class ReadLineTextBuffer(TextLine): ############## Paste +############## Kill ring + def add_to_kill_ring(self,txt): + self.kill_ring=[txt] + + + def paste_from_kill_ring(self): + if self.kill_ring: + self.insert_text(self.kill_ring[0]) + + ################################################################## q=ReadLineTextBuffer("asff asFArw ewrWErhg",point=8) q=TextLine("asff asFArw ewrWErhg",point=8) diff --git a/pyreadline/modes/emacs.py b/pyreadline/modes/emacs.py index 492cb04..b4e93c6 100644 --- a/pyreadline/modes/emacs.py +++ b/pyreadline/modes/emacs.py @@ -365,12 +365,12 @@ class EmacsMode(basemode.BaseMode): def yank(self, e): # (C-y) '''Yank the top of the kill ring into the buffer at point. ''' - pass + self.l_buffer.yank() def yank_pop(self, e): # (M-y) '''Rotate the kill-ring, and yank the new top. You can only do this if the prior command is yank or yank-pop.''' - pass + self.l_buffer.yank_pop() def digit_argument(self, e): # (M-0, M-1, ... M--) @@ -580,7 +580,7 @@ class EmacsMode(basemode.BaseMode): #self._bind_key('Control-Shift-v', self.quoted_insert) self._bind_key('Control-v', self.paste) self._bind_key('Alt-v', self.ipython_paste) - self._bind_key('Control-y', self.paste) + self._bind_key('Control-y', self.yank) self._bind_key('Control-k', self.kill_line) self._bind_key('Control-m', self.set_mark) self._bind_key('Control-q', self.copy_region_to_clipboard)