Andreas Stührk avatar Andreas Stührk committed 2c527ee

urwid: Make C-e and C-a to do the right thing. This closes issue #165.

Comments (0)

Files changed (1)

         return False
 
     def keypress(self, size, key):
+        if urwid.command_map[key] in ['cursor up', 'cursor down']:
+            # Do not handle up/down arrow, leave them for the repl.
+            return key
+
         self._bpy_may_move_cursor = True
         try:
-            # Do not handle up/down arrow, leave them for the repl.
-            if urwid.command_map[key] in ('cursor up', 'cursor down'):
-                return key
+            if urwid.command_map[key] == 'cursor max left':
+                self.edit_pos = 0
+            elif urwid.command_map[key] == 'cursor max right':
+                self.edit_pos = len(self.get_edit_text())
             elif key == 'backspace':
                 line = self.get_edit_text()
                 cpos = len(line) - self.edit_pos
                 if not (cpos or len(line) % self.tab_length or line.strip()):
                     self.set_edit_text(line[:-self.tab_length])
-                    return None
+                else:
+                    return urwid.Edit.keypress(self, size, key)
             elif key == 'pastebin':
                 # do pastebin
                 pass
-            # TODO: Add in specific keypress fetching code here
-            return urwid.Edit.keypress(self, size, key)
+            else:
+                # TODO: Add in specific keypress fetching code here
+                return urwid.Edit.keypress(self, size, key)
+            return None
         finally:
             self._bpy_may_move_cursor = False
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.