[gedit] Add smart home/end in the python console.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Add smart home/end in the python console.
- Date: Sat, 13 Mar 2010 20:30:25 +0000 (UTC)
commit fc6a3fee1b0d7431a752c7c813d9eeb0ea543445
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Mar 13 21:20:41 2010 +0100
Add smart home/end in the python console.
Patch by Garrett Regier
plugins/pythonconsole/pythonconsole/console.py | 40 ++++++++++++++++++++++--
1 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/plugins/pythonconsole/pythonconsole/console.py b/plugins/pythonconsole/pythonconsole/console.py
index 7700242..e9d7a33 100644
--- a/plugins/pythonconsole/pythonconsole/console.py
+++ b/plugins/pythonconsole/pythonconsole/console.py
@@ -199,15 +199,49 @@ class PythonConsole(gtk.ScrolledWindow):
return True
return False
+ # For the console we enable smart/home end behavior incoditionally
+ # since it is useful when editing python
+
elif (event.keyval == gtk.keysyms.KP_Home or event.keyval == gtk.keysyms.Home) and \
event_state == event_state & (gtk.gdk.SHIFT_MASK|gtk.gdk.CONTROL_MASK):
# Go to the begin of the command instead of the begin of the line
buffer = view.get_buffer()
- inp = buffer.get_iter_at_mark(buffer.get_mark("input"))
+ iter = buffer.get_iter_at_mark(buffer.get_mark("input"))
+ ins = buffer.get_iter_at_mark(buffer.get_insert())
+
+ while iter.get_char().isspace():
+ iter.forward_char()
+
+ if iter.equal(ins):
+ iter = buffer.get_iter_at_mark(buffer.get_mark("input"))
+
+ if event_state & gtk.gdk.SHIFT_MASK:
+ buffer.move_mark_by_name("insert", iter)
+ else:
+ buffer.place_cursor(iter)
+ return True
+
+ elif (event.keyval == gtk.keysyms.KP_End or event.keyval == gtk.keysyms.End) and \
+ event_state == event_state & (gtk.gdk.SHIFT_MASK|gtk.gdk.CONTROL_MASK):
+
+ buffer = view.get_buffer()
+ iter = buffer.get_end_iter()
+ ins = buffer.get_iter_at_mark(buffer.get_insert())
+
+ iter.backward_char()
+
+ while iter.get_char().isspace():
+ iter.backward_char()
+
+ iter.forward_char()
+
+ if iter.equal(ins):
+ iter = buffer.get_end_iter()
+
if event_state & gtk.gdk.SHIFT_MASK:
- buffer.move_mark_by_name("insert", inp)
+ buffer.move_mark_by_name("insert", iter)
else:
- buffer.place_cursor(inp)
+ buffer.place_cursor(iter)
return True
def __mark_set_cb(self, buffer, iter, name):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]