Commits

Anonymous committed ea6de5d

Edit menu item

Comments (0)

Files changed (3)

         fileMenu.add_command(label='Open File ...',
                              command=self._open_file_dialog, underline=0)
         fileMenu.add_separator()
+        fileMenu.add_command(label='Change Editor',
+                             command=self._change_editor_dialog, underline=0)
         fileMenu.add_command(label='Save Editor',
                              command=self.save_file, underline=0)
         fileMenu.add_command(label='Close Editor',
         
         editMenu = Menu(self.menubar, tearoff=0)
         self.menubar.add_cascade(label='Edit', menu=editMenu, underline=3)
+        def set_mark():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().set_mark()
+        editMenu.add_command(label='Emacs Set Mark',
+                             command=set_mark, underline=6)
+        def copy():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().copy_region()
+        editMenu.add_command(label='Emacs Copy', command=copy, underline=6)
+        def cut():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().cut_region()
+        editMenu.add_command(label='Emacs Cut', command=cut, underline=8)
+        def paste():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().paste()
+        editMenu.add_command(label='Paste', command=paste, underline=0)
+
+        editMenu.add_separator()
+        def undo():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().undo()
+        editMenu.add_command(label='Undo', command=undo, underline=0)
+        def redo():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().redo()
+        editMenu.add_command(label='Redo', command=redo, underline=0)
+        editMenu.add_separator()
+        def forward_search():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().start_searching(True)
+
+        editMenu.add_command(label='Forward Search', command=forward_search, underline=0)
+
+        def backward_search():
+            activeEditor = self.editor_manager.active_editor
+            if activeEditor:
+                activeEditor.get_editor().start_searching(False)
+
+        editMenu.add_command(label='Backward Search', 
+                             command=backward_search, underline=0)
 
         codeMenu = Menu(self.menubar, tearoff=0)
-        self.menubar.add_cascade(label='Code', menu=editMenu, underline=1)
+        self.menubar.add_cascade(label='Code', menu=codeMenu, underline=1)
 
         helpMenu = Menu(self.menubar, tearoff=0)
         self.menubar.add_cascade(label='Help', menu=helpMenu, underline=3)
         self.text.event_add('<<ForwardSearch>>', '<Control-s>')
         self.text.event_add('<<BackwardSearch>>', '<Control-r>')
         self.text.bind('<<ForwardSearch>>',
-                       lambda event: self._search_event(True), '+')
+                       lambda event: self.start_searching(True), '+')
         self.text.bind('<<BackwardSearch>>',
-                       lambda event: self._search_event(False))
+                       lambda event: self.start_searching(False))
         self.text.bind('<Any-KeyPress>', self._search_handler)
         self.text.bind('<BackSpace>', backspace, '+')
         self.text.bind('<Alt-slash>', lambda event: self._show_completion_window());
         self.text.see(INSERT)
 
 
-    def _search_event(self, forward):
+    def start_searching(self, forward):
         if self.searcher.is_searching():
             self.searcher.configure_search(forward)
             self.searcher.next_match()

rope/searching.py

 class SearchingState(object):
     
     def append_keyword(self, searcher, postfix):
-        '''Appends postfix to the keyword'''
+        """Appends postfix to the keyword"""
 
     def shorten_keyword(self, searcher):
-        '''Deletes the last char of keyword'''
+        """Deletes the last char of keyword"""
 
     def next_match(self, searcher):
-        '''Go to the next match'''
+        """Go to the next match"""
 
 class ForwardSearching(SearchingState):
+    
     def append_keyword(self, searcher, postfix):
         start = searcher.editor.get_relative(searcher.editor.get_insert(), -len(searcher.keyword))
         searcher.keyword += postfix
         return True
 
 class BackwardSearching(SearchingState):
+    
     def append_keyword(self, searcher, postfix):
         searcher.keyword += postfix
         start = searcher.editor.get_relative(searcher.editor.get_insert(), +len(searcher.keyword))
         return True
 
 class NotSearching(SearchingState):
-    '''A null object for when not searching'''
+    """A null object for when not searching"""
 
     def append_keyword(self, searcher, postfix):
         pass
         return False
 
 class Match(object):
+    
     def __init__(self, start, end, side='right'):
         self.start = start
         self.end = end
         self.side = side
 
 class Searcher(object):
-    '''A class for searching TextEditors'''
+    """A class for searching TextEditors"""
 
     def __init__(self, editor):
         self.editor = editor