diff --git a/doc/ChangeLog b/doc/ChangeLog index cd6a147..225f7fe 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2006-10-17 Jörgen Stenarson + * Fixed history search bug. Exception when no match was found + * Added backward_kill_word. (No difference to backward_delete_word) + 2006-09-11 Jörgen Stenarson * Added logserver. Socket based server that can receive logmessage. To be used when debugging keypresses, could be a security risk as a keyboard sniffer. diff --git a/pyreadline/lineeditor/history.py b/pyreadline/lineeditor/history.py index bfe789e..2dd3fcc 100644 --- a/pyreadline/lineeditor/history.py +++ b/pyreadline/lineeditor/history.py @@ -167,9 +167,8 @@ class LineHistory(object): if (self.lastcommand != self.history_search_forward and self.lastcommand != self.history_search_backward): self.query = ''.join(partial[0:partial.point].get_line_text()) - hcstart=self.history_cursor + hcstart=max(self.history_cursor-1,0) hc = self.history_cursor + direction -# print hc,hcstart,self.query while (direction < 0 and hc >= 0) or (direction > 0 and hc < len(self.history)): h = self.history[hc] if not self.query: @@ -182,7 +181,9 @@ class LineHistory(object): return result hc += direction else: - if hc>=len(self.history) and not self.query: + if len(self.history)==0: + pass + elif hc>=len(self.history) and not self.query: return lineobj.ReadLineTextBuffer("",point=0) elif self.history[hcstart].get_line_text().startswith(self.query) and self.query: return lineobj.ReadLineTextBuffer(self.history[hcstart],point=partial.point) diff --git a/pyreadline/lineeditor/lineobj.py b/pyreadline/lineeditor/lineobj.py index b1ceec6..40635a2 100644 --- a/pyreadline/lineeditor/lineobj.py +++ b/pyreadline/lineeditor/lineobj.py @@ -83,6 +83,18 @@ class PrevWordEnd(LinePositioner): return line.prev_end_segment(line.line_buffer,line.is_word_token)[line.point] PrevWordEnd=PrevWordEnd() +class PrevSpace(LinePositioner): + def __call__(self,line): + point=line.point + if line[point-1:point].get_line_text()==" ": + while point>0 and line[point-1:point].get_line_text()==" ": + point-=1 + while point>0 and line[point-1:point].get_line_text()!=" ": + point-=1 + return point +PrevSpace=PrevSpace() + + class StartOfLine(LinePositioner): def __call__(self,line): return 0 @@ -524,35 +536,49 @@ class ReadLineTextBuffer(TextLine): del self.line_buffer[self.point:] def kill_whole_line(self): + clipboard.set_clipboard_text() del self[:] def backward_kill_line(self): + clipboard.set_clipboard_text() del self[StartOfLine:Point] def unix_line_discard(self): + clipboard.set_clipboard_text(self[StartOfLine:Point]) pass def kill_word(self): """Kills to next word ending""" + clipboard.set_clipboard_text(self[Point:NextWordEnd]) del self[Point:NextWordEnd] def backward_kill_word(self): """Kills to next word ending""" - pass + clipboard.set_clipboard_text(self[PrevWordStart:Point]) + if not self.delete_selection(): + del self[PrevWordStart:Point] + self.selection_mark=-1 - def unix_word_rubout(self): - pass + def unix_word_rubout(self): + clipboard.set_clipboard_text(self[PrevSpace:Point]) + if not self.delete_selection(): + del self[PrevSpace:Point] + self.selection_mark=-1 def kill_region(self): + clipboard.set_clipboard_text() pass def copy_region_as_kill(self): + clipboard.set_clipboard_text() pass def copy_backward_word(self): + clipboard.set_clipboard_text() pass def copy_forward_word(self): + clipboard.set_clipboard_text() pass @@ -634,7 +660,7 @@ def test_positioner(buff,points,positioner): print '"%s"'%("".join(out)) if __name__=="__main__": - + import startup print '%-15s "%s"'%("Position",q.get_line_text()) print '%-15s "%s"'%("Point",show_pos(q,q.point)) @@ -645,5 +671,5 @@ if __name__=="__main__": [] print '%-15s "%s"'%(name,show_pos(q,pos,"^")) - l=ReadLineTextBuffer("kjjk") + l=ReadLineTextBuffer("kjjk asads asad") l.point=EndOfLine \ No newline at end of file