I used to be using Ipython but had switch to Dreampie after discover
dreampie. When I use Dreampie, there are some feature which I use in
Ipython but not in Dreampie. One of them is the history code searching
which dreampie will not skip the duplicated code. So, I had added a
request 'Faster history searching using Ctrl-up/Ctrl-down' in the
Dreampie feature request...but it haven't implemented for some time.
And thanks to be open source..I have some time in weekend and spend
some time to look at the code and try to implement it. Thankfully
Dreampie is a very well structure code, I can easily search the code I
am interesting without digging to all the code. Here is my changes for
the feature (I don't use bzr nor git, only svn, so dunno how to submit
code patches). The code I use is the dreampie 1.1.1, not the head of
the development/trunk
--- C:/Users/swong24/Development/dreampie/dreampie-1.1.1/dreampielib/
gui/history.py Tue Feb 23 22:09:07 2010
+++ C:/Users/swong24/Development/dreampie/dreampie-1.1.1 - updategtk/
dreampielib/gui/history.py Sun Dec 11 23:44:34 2011
@@ -149,9 +149,14 @@
and first_line.startswith(self.hist_prefix)
and (len(first_line) > 2 or
self.recall_1_char_commands)):
- command = self.iter_get_command(it).strip()
- sb.set_text(command)
- sb.place_cursor(sb.get_end_iter())
+ ncommand = self.iter_get_command(it).strip()
+ if get_buffer_text(sb).strip() == ncommand:
+ continue
+ sb.set_text(ncommand)
+ if len(ncommand.splitlines()) > 1:
+ sb.place_cursor(sb.get_start_iter())
+ else:
+ sb.place_cursor(sb.get_end_iter())
self._track_change()
tb.move_mark(self.hist_mark, it)
break
@@ -199,13 +204,21 @@
if (first_line
and first_line.startswith(self.hist_prefix)
and (len(first_line) > 2 or
self.recall_1_char_commands)):
-
- command = self.iter_get_command(it).strip()
- sb.set_text(command)
- sb.place_cursor(sb.get_end_iter())
+
+ ncommand = self.iter_get_command(it).strip()
+ if get_buffer_text(sb).strip() == ncommand:
+ continue
+ sb.set_text(ncommand)
+ if len(ncommand.splitlines()) > 1:
+ sb.place_cursor(sb.get_start_iter())
+ else:
+ sb.place_cursor(sb.get_end_iter())
self._track_change()
tb.move_mark(self.hist_mark, it)
break
else:
beep()
+
+def get_buffer_text(tb):
+ return tb.get_text(tb.get_start_iter(), tb.get_end_iter())